@sentry/junior 0.52.0 → 0.54.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 (222) hide show
  1. package/README.md +3 -2
  2. package/dist/api-reference.d.ts +7 -0
  3. package/dist/app.d.ts +5 -10
  4. package/dist/app.js +1671 -1219
  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/app/factory.d.ts +10 -0
  10. package/dist/chat/app/production.d.ts +6 -0
  11. package/dist/chat/app/services.d.ts +17 -0
  12. package/dist/chat/capabilities/catalog.d.ts +16 -0
  13. package/dist/chat/capabilities/factory.d.ts +10 -0
  14. package/dist/chat/capabilities/jr-rpc-command.d.ts +26 -0
  15. package/dist/chat/capabilities/router.d.ts +19 -0
  16. package/dist/chat/coerce.d.ts +6 -0
  17. package/dist/chat/config.d.ts +46 -0
  18. package/dist/chat/configuration/defaults.d.ts +4 -0
  19. package/dist/chat/configuration/service.d.ts +2 -0
  20. package/dist/chat/configuration/types.d.ts +37 -0
  21. package/dist/chat/configuration/validation.d.ts +2 -0
  22. package/dist/chat/credentials/broker.d.ts +22 -0
  23. package/dist/chat/credentials/header-transforms.d.ts +3 -0
  24. package/dist/chat/credentials/oauth-scope.d.ts +4 -0
  25. package/dist/chat/credentials/state-adapter-token-store.d.ts +9 -0
  26. package/dist/chat/credentials/test-broker.d.ts +19 -0
  27. package/dist/chat/credentials/unlink-provider.d.ts +2 -0
  28. package/dist/chat/credentials/user-token-store.d.ts +11 -0
  29. package/dist/chat/discovery.d.ts +47 -0
  30. package/dist/chat/ingress/junior-chat.d.ts +26 -0
  31. package/dist/chat/ingress/message-changed.d.ts +50 -0
  32. package/dist/chat/ingress/message-router.d.ts +9 -0
  33. package/dist/chat/ingress/slash-command.d.ts +3 -0
  34. package/dist/chat/ingress/workspace-membership.d.ts +10 -0
  35. package/dist/chat/interruption-marker.d.ts +2 -0
  36. package/dist/chat/logging.d.ts +88 -0
  37. package/dist/chat/mcp/auth-store.d.ts +41 -0
  38. package/dist/chat/mcp/client.d.ts +34 -0
  39. package/dist/chat/mcp/errors.d.ts +8 -0
  40. package/dist/chat/mcp/oauth-provider.d.ts +27 -0
  41. package/dist/chat/mcp/oauth.d.ts +17 -0
  42. package/dist/chat/mcp/tool-manager.d.ts +60 -0
  43. package/dist/chat/oauth-flow.d.ts +45 -0
  44. package/dist/chat/optional-string.d.ts +5 -0
  45. package/dist/chat/pi/client.d.ts +49 -0
  46. package/dist/chat/pi/messages.d.ts +3 -0
  47. package/dist/chat/pi/traced-stream.d.ts +9 -0
  48. package/dist/chat/plugins/auth/api-headers-broker.d.ts +6 -0
  49. package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +3 -0
  50. package/dist/chat/plugins/auth/github-app-broker.d.ts +4 -0
  51. package/dist/chat/plugins/auth/oauth-bearer-broker.d.ts +6 -0
  52. package/dist/chat/plugins/auth/oauth-request.d.ts +18 -0
  53. package/dist/chat/plugins/command-env.d.ts +3 -0
  54. package/dist/chat/plugins/manifest.d.ts +3 -0
  55. package/dist/chat/plugins/package-discovery.d.ts +14 -0
  56. package/dist/chat/plugins/registry.d.ts +23 -0
  57. package/dist/chat/plugins/types.d.ts +146 -0
  58. package/dist/chat/prompt.d.ts +39 -0
  59. package/dist/chat/queue/thread-message-dispatcher.d.ts +33 -0
  60. package/dist/chat/respond-helpers.d.ts +77 -0
  61. package/dist/chat/respond.d.ts +64 -0
  62. package/dist/chat/runtime/auth-pause-state.d.ts +11 -0
  63. package/dist/chat/runtime/delivered-turn-state.d.ts +15 -0
  64. package/dist/chat/runtime/dev-agent-trace.d.ts +1 -0
  65. package/dist/chat/runtime/processing-reaction.d.ts +25 -0
  66. package/dist/chat/runtime/reply-executor.d.ts +56 -0
  67. package/dist/chat/runtime/report-progress.d.ts +3 -0
  68. package/dist/chat/runtime/slack-resume.d.ts +50 -0
  69. package/dist/chat/runtime/slack-runtime.d.ts +100 -0
  70. package/dist/chat/runtime/thread-context.d.ts +22 -0
  71. package/dist/chat/runtime/thread-state.d.ts +28 -0
  72. package/dist/chat/runtime/turn-preparation.d.ts +43 -0
  73. package/dist/chat/runtime/turn-user-message.d.ts +12 -0
  74. package/dist/chat/runtime/turn.d.ts +69 -0
  75. package/dist/chat/sandbox/credentials.d.ts +11 -0
  76. package/dist/chat/sandbox/egress-oidc.d.ts +3 -0
  77. package/dist/chat/sandbox/egress-policy.d.ts +11 -0
  78. package/dist/chat/sandbox/egress-proxy.d.ts +10 -0
  79. package/dist/chat/sandbox/egress-session.d.ts +27 -0
  80. package/dist/chat/sandbox/errors.d.ts +12 -0
  81. package/dist/chat/sandbox/eval-gh-stub.d.ts +2 -0
  82. package/dist/chat/sandbox/eval-oauth-stub.d.ts +2 -0
  83. package/dist/chat/sandbox/eval-sentry-stub.d.ts +2 -0
  84. package/dist/chat/sandbox/fault-injection.d.ts +2 -0
  85. package/dist/chat/sandbox/http-error-details.d.ts +18 -0
  86. package/dist/chat/sandbox/noninteractive-command.d.ts +17 -0
  87. package/dist/chat/sandbox/paths.d.ts +5 -0
  88. package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +20 -0
  89. package/dist/chat/sandbox/sandbox.d.ts +52 -0
  90. package/dist/chat/sandbox/session.d.ts +53 -0
  91. package/dist/chat/sandbox/skill-sandbox.d.ts +42 -0
  92. package/dist/chat/sandbox/skill-sync.d.ts +17 -0
  93. package/dist/chat/sandbox/workspace.d.ts +55 -0
  94. package/dist/chat/sentry.d.ts +2 -0
  95. package/dist/chat/services/attachment-claims.d.ts +2 -0
  96. package/dist/chat/services/auth-pause-response.d.ts +2 -0
  97. package/dist/chat/services/auth-pause.d.ts +12 -0
  98. package/dist/chat/services/channel-intent.d.ts +2 -0
  99. package/dist/chat/services/conversation-memory.d.ts +33 -0
  100. package/dist/chat/services/mcp-auth-orchestration.d.ts +29 -0
  101. package/dist/chat/services/pending-auth.d.ts +27 -0
  102. package/dist/chat/services/plugin-auth-orchestration.d.ts +36 -0
  103. package/dist/chat/services/provider-default-config.d.ts +9 -0
  104. package/dist/chat/services/provider-retry.d.ts +6 -0
  105. package/dist/chat/services/reply-delivery-plan.d.ts +17 -0
  106. package/dist/chat/services/subscribed-decision.d.ts +63 -0
  107. package/dist/chat/services/subscribed-reply-policy.d.ts +23 -0
  108. package/dist/chat/services/timeout-resume.d.ts +17 -0
  109. package/dist/chat/services/turn-checkpoint.d.ts +74 -0
  110. package/dist/chat/services/turn-continuation-response.d.ts +2 -0
  111. package/dist/chat/services/turn-failure-response.d.ts +15 -0
  112. package/dist/chat/services/turn-result.d.ts +55 -0
  113. package/dist/chat/services/turn-thinking-level.d.ts +49 -0
  114. package/dist/chat/services/vision-context.d.ts +61 -0
  115. package/dist/chat/skills.d.ts +48 -0
  116. package/dist/chat/slack/adapter.d.ts +9 -0
  117. package/dist/chat/slack/app-home.d.ts +11 -0
  118. package/dist/chat/slack/assistant-thread/lifecycle.d.ts +13 -0
  119. package/dist/chat/slack/assistant-thread/status-render.d.ts +28 -0
  120. package/dist/chat/slack/assistant-thread/status-scheduler.d.ts +23 -0
  121. package/dist/chat/slack/assistant-thread/status-send.d.ts +31 -0
  122. package/dist/chat/slack/assistant-thread/status.d.ts +36 -0
  123. package/dist/chat/slack/assistant-thread/title.d.ts +28 -0
  124. package/dist/chat/slack/canvas-references.d.ts +2 -0
  125. package/dist/chat/slack/channel.d.ts +48 -0
  126. package/dist/chat/slack/client.d.ts +52 -0
  127. package/dist/chat/slack/context.d.ts +9 -0
  128. package/dist/chat/slack/emoji.d.ts +1 -0
  129. package/dist/chat/slack/errors.d.ts +6 -0
  130. package/dist/chat/slack/footer.d.ts +42 -0
  131. package/dist/chat/slack/legacy-attachments.d.ts +4 -0
  132. package/dist/chat/slack/message.d.ts +6 -0
  133. package/dist/chat/slack/mrkdwn.d.ts +12 -0
  134. package/dist/chat/slack/outbound.d.ts +57 -0
  135. package/dist/chat/slack/output.d.ts +54 -0
  136. package/dist/chat/slack/reply.d.ts +33 -0
  137. package/dist/chat/slack/status-format.d.ts +2 -0
  138. package/dist/chat/slack/turn-continuation-notice.d.ts +8 -0
  139. package/dist/chat/slack/user.d.ts +7 -0
  140. package/dist/chat/slack/users.d.ts +39 -0
  141. package/dist/chat/state/adapter.d.ts +9 -0
  142. package/dist/chat/state/artifacts.d.ts +29 -0
  143. package/dist/chat/state/conversation.d.ts +81 -0
  144. package/dist/chat/state/pi-session-message-store.d.ts +15 -0
  145. package/dist/chat/state/turn-id.d.ts +2 -0
  146. package/dist/chat/state/turn-session-store.d.ts +49 -0
  147. package/dist/chat/tools/advisor/session-store.d.ts +9 -0
  148. package/dist/chat/tools/advisor/tool.d.ts +33 -0
  149. package/dist/chat/tools/agent-tools.d.ts +9 -0
  150. package/dist/chat/tools/channel-capabilities.d.ts +11 -0
  151. package/dist/chat/tools/definition.d.ts +17 -0
  152. package/dist/chat/tools/execution/build-sandbox-input.d.ts +2 -0
  153. package/dist/chat/tools/execution/normalize-result.d.ts +6 -0
  154. package/dist/chat/tools/execution/tool-error-handler.d.ts +3 -0
  155. package/dist/chat/tools/execution/tool-input-error.d.ts +6 -0
  156. package/dist/chat/tools/idempotency.d.ts +1 -0
  157. package/dist/chat/tools/index.d.ts +5 -0
  158. package/dist/chat/tools/runtime/report-progress.d.ts +4 -0
  159. package/dist/chat/tools/sandbox/attach-file.d.ts +7 -0
  160. package/dist/chat/tools/sandbox/bash.d.ts +5 -0
  161. package/dist/chat/tools/sandbox/edit-file.d.ts +37 -0
  162. package/dist/chat/tools/sandbox/file-utils.d.ts +52 -0
  163. package/dist/chat/tools/sandbox/find-files.d.ts +24 -0
  164. package/dist/chat/tools/sandbox/grep.d.ts +33 -0
  165. package/dist/chat/tools/sandbox/list-dir.d.ts +22 -0
  166. package/dist/chat/tools/sandbox/read-file.d.ts +32 -0
  167. package/dist/chat/tools/sandbox/text-edits.d.ts +28 -0
  168. package/dist/chat/tools/sandbox/write-file.d.ts +5 -0
  169. package/dist/chat/tools/skill/call-mcp-tool.d.ts +7 -0
  170. package/dist/chat/tools/skill/load-skill.d.ts +22 -0
  171. package/dist/chat/tools/skill/mcp-tool-summary.d.ts +31 -0
  172. package/dist/chat/tools/skill/search-mcp-tools.d.ts +8 -0
  173. package/dist/chat/tools/slack/canvas-tools.d.ts +29 -0
  174. package/dist/chat/tools/slack/canvases.d.ts +45 -0
  175. package/dist/chat/tools/slack/channel-list-messages.d.ts +9 -0
  176. package/dist/chat/tools/slack/channel-post-message.d.ts +4 -0
  177. package/dist/chat/tools/slack/list-tools.d.ts +21 -0
  178. package/dist/chat/tools/slack/lists.d.ts +42 -0
  179. package/dist/chat/tools/slack/message-add-reaction.d.ts +4 -0
  180. package/dist/chat/tools/slack/slack-message-url.d.ts +18 -0
  181. package/dist/chat/tools/slack/thread-read.d.ts +9 -0
  182. package/dist/chat/tools/slack/user-lookup.d.ts +8 -0
  183. package/dist/chat/tools/system-time.d.ts +1 -0
  184. package/dist/chat/tools/types.d.ts +55 -0
  185. package/dist/chat/tools/web/constants.d.ts +6 -0
  186. package/dist/chat/tools/web/fetch-content.d.ts +23 -0
  187. package/dist/chat/tools/web/fetch-tool.d.ts +5 -0
  188. package/dist/chat/tools/web/image-generate.d.ts +4 -0
  189. package/dist/chat/tools/web/network.d.ts +6 -0
  190. package/dist/chat/tools/web/search.d.ts +5 -0
  191. package/dist/chat/turn-context-tag.d.ts +6 -0
  192. package/dist/chat/usage.d.ts +24 -0
  193. package/dist/chat/xml.d.ts +1 -0
  194. package/dist/{chunk-XPXD3FCE.js → chunk-5LUISFEY.js} +189 -35
  195. package/dist/{chunk-KCOKQLBF.js → chunk-7WTXNEPF.js} +120 -15
  196. package/dist/{chunk-ZNFNY53B.js → chunk-QCHPJ4FD.js} +2 -2
  197. package/dist/{chunk-Q3FDONU7.js → chunk-YITDDLS3.js} +34 -28
  198. package/dist/cli/check.js +3 -3
  199. package/dist/cli/init.js +1 -0
  200. package/dist/cli/snapshot-warmup.js +3 -3
  201. package/dist/handlers/diagnostics-dashboard.d.ts +2 -0
  202. package/dist/handlers/diagnostics.d.ts +2 -0
  203. package/dist/handlers/health.d.ts +4 -0
  204. package/dist/handlers/mcp-oauth-callback.d.ts +2 -0
  205. package/dist/handlers/oauth-callback.d.ts +2 -0
  206. package/dist/handlers/oauth-html.d.ts +2 -0
  207. package/dist/handlers/sandbox-egress-proxy.d.ts +4 -0
  208. package/dist/handlers/turn-resume.d.ts +3 -0
  209. package/dist/handlers/types.d.ts +2 -0
  210. package/dist/handlers/webhooks.d.ts +15 -0
  211. package/dist/instrumentation.d.ts +1 -3
  212. package/dist/nitro.d.ts +4 -7
  213. package/dist/nitro.js +112 -54
  214. package/dist/package-resolution.d.ts +13 -0
  215. package/dist/vercel.d.ts +2 -4
  216. package/package.json +25 -25
  217. package/dist/cli/check.d.ts +0 -8
  218. package/dist/cli/env.d.ts +0 -7
  219. package/dist/cli/init.d.ts +0 -3
  220. package/dist/cli/run.d.ts +0 -12
  221. package/dist/cli/snapshot-warmup.d.ts +0 -3
  222. package/dist/types-X_iCClPb.d.ts +0 -75
@@ -0,0 +1,42 @@
1
+ import type { TurnThinkingSelection } from "@/chat/services/turn-thinking-level";
2
+ import type { AgentTurnUsage } from "@/chat/usage";
3
+ interface SlackMrkdwnTextObject {
4
+ text: string;
5
+ type: "mrkdwn";
6
+ }
7
+ /** Slack-flavored Markdown block — accepts a standard Markdown subset and Slack renders it natively. */
8
+ interface SlackMarkdownBlock {
9
+ text: string;
10
+ type: "markdown";
11
+ }
12
+ interface SlackSectionBlock {
13
+ text: SlackMrkdwnTextObject;
14
+ type: "section";
15
+ }
16
+ interface SlackContextBlock {
17
+ elements: SlackMrkdwnTextObject[];
18
+ type: "context";
19
+ }
20
+ export type SlackMessageBlock = SlackMarkdownBlock | SlackSectionBlock | SlackContextBlock;
21
+ interface SlackReplyFooterItem {
22
+ label: string;
23
+ url?: string;
24
+ value: string;
25
+ }
26
+ export interface SlackReplyFooter {
27
+ items: SlackReplyFooterItem[];
28
+ }
29
+ /**
30
+ * Build a compact footer for the finalized Slack reply.
31
+ *
32
+ * This is reply metadata, not part of the in-flight assistant loading state.
33
+ */
34
+ export declare function buildSlackReplyFooter(args: {
35
+ conversationId?: string;
36
+ durationMs?: number;
37
+ thinkingLevel?: TurnThinkingSelection["thinkingLevel"];
38
+ usage?: AgentTurnUsage;
39
+ }): SlackReplyFooter | undefined;
40
+ /** Build Slack blocks for a reply chunk using the Slack-flavored markdown block for the body. */
41
+ export declare function buildSlackReplyBlocks(text: string, footer: SlackReplyFooter | undefined): SlackMessageBlock[] | undefined;
42
+ export {};
@@ -0,0 +1,4 @@
1
+ /** Render legacy Slack attachment fields so attachment-only messages still carry context. */
2
+ export declare function renderSlackLegacyAttachmentText(input: unknown): string;
3
+ /** Append legacy Slack attachment text to the message text used by routing and replies. */
4
+ export declare function appendSlackLegacyAttachmentText(baseText: string | undefined, rawMessageOrAttachments: unknown): string;
@@ -0,0 +1,6 @@
1
+ import type { Message } from "chat";
2
+ /**
3
+ * Preserve the native Slack message timestamp when a synthetic message ID is
4
+ * used for routing or deduplication.
5
+ */
6
+ export declare function getSlackMessageTs(message: Pick<Message, "id" | "raw">): string;
@@ -0,0 +1,12 @@
1
+ /** Insert blank lines between content blocks so Slack renders them with visual separation. */
2
+ export declare function ensureBlockSpacing(text: string): string;
3
+ /**
4
+ * Render model-authored markdown into Slack-friendly `mrkdwn`.
5
+ *
6
+ * Slack reply delivery owns chunking and continuation markers separately.
7
+ * This helper only normalizes text into the repository's canonical Slack
8
+ * rendering form.
9
+ */
10
+ export declare function renderSlackMrkdwn(text: string): string;
11
+ /** Normalize assistant status text before handing it to Slack. */
12
+ export declare function normalizeSlackStatusText(text: string): string;
@@ -0,0 +1,57 @@
1
+ import type { SlackMessageBlock } from "@/chat/slack/footer";
2
+ /** Post Slack `mrkdwn` text to a conversation or thread via the shared outbound boundary. */
3
+ export declare function postSlackMessage(input: {
4
+ blocks?: SlackMessageBlock[];
5
+ channelId: string;
6
+ text: string;
7
+ threadTs?: string;
8
+ includePermalink?: boolean;
9
+ }): Promise<{
10
+ ts: string;
11
+ permalink?: string;
12
+ }>;
13
+ /** Delete a previously posted Slack message through the shared outbound boundary. */
14
+ export declare function deleteSlackMessage(input: {
15
+ channelId: string;
16
+ timestamp: string;
17
+ }): Promise<void>;
18
+ /**
19
+ * Post an ephemeral Slack message. Delivery is best-effort on Slack's side, but
20
+ * request validation and Web API behavior are centralized here.
21
+ */
22
+ export declare function postSlackEphemeralMessage(input: {
23
+ channelId: string;
24
+ userId: string;
25
+ text: string;
26
+ threadTs?: string;
27
+ }): Promise<{
28
+ messageTs?: string;
29
+ }>;
30
+ /** Upload files into a Slack thread via the shared outbound file boundary. */
31
+ export declare function uploadFilesToThread(input: {
32
+ channelId: string;
33
+ threadTs: string;
34
+ files: Array<{
35
+ data: Buffer;
36
+ filename: string;
37
+ }>;
38
+ }): Promise<void>;
39
+ /** Add a reaction to a Slack message, treating `already_reacted` as idempotent success. */
40
+ export declare function addReactionToMessage(input: {
41
+ channelId: string;
42
+ timestamp: string;
43
+ emoji: string;
44
+ }): Promise<{
45
+ ok: true;
46
+ }>;
47
+ /** Remove a reaction from a Slack message, treating `no_reaction` as idempotent success. */
48
+ export declare function removeReactionFromMessage(input: {
49
+ channelId: string;
50
+ timestamp: string;
51
+ emoji: string;
52
+ }): Promise<{
53
+ ok: true;
54
+ }>;
55
+ export declare const slackOutboundPolicy: {
56
+ maxMessageTextChars: number;
57
+ };
@@ -0,0 +1,54 @@
1
+ import type { FileUpload, PostableMessage } from "chat";
2
+ /** Return the first continuation-safe chunk plus any remaining text. */
3
+ export declare function takeSlackContinuationPrefix(text: string, options?: {
4
+ forceSplit?: boolean;
5
+ maxChars?: number;
6
+ maxLines?: number;
7
+ }): {
8
+ prefix: string;
9
+ renderedPrefix: string;
10
+ rest: string;
11
+ };
12
+ /**
13
+ * Take the largest Slack-safe inline prefix from `text` under the configured
14
+ * character and line budgets. Returns the consumed prefix plus remaining text.
15
+ */
16
+ export declare function takeSlackInlinePrefix(text: string, options?: {
17
+ maxChars?: number;
18
+ maxLines?: number;
19
+ }): {
20
+ prefix: string;
21
+ rest: string;
22
+ };
23
+ /**
24
+ * Split a normalized Slack reply into multiple inline-safe thread messages.
25
+ *
26
+ * Replies split across more than two messages receive explicit continuation
27
+ * markers on non-final chunks. When
28
+ * `interrupted` is true, the final chunk receives an interruption marker.
29
+ */
30
+ export declare function splitSlackReplyText(text: string, options?: {
31
+ interrupted?: boolean;
32
+ }): string[];
33
+ /** Return the marker added to non-final overflow chunks. */
34
+ export declare function getSlackContinuationMarker(): string;
35
+ /** Return the marker added when a visible reply ended mid-execution. */
36
+ export declare function getSlackInterruptionMarker(): string;
37
+ /**
38
+ * Return true when `text` already fits the repository's inline Slack reply
39
+ * budget without needing continuation messages.
40
+ */
41
+ export declare function fitsSlackInlineBudget(text: string): boolean;
42
+ /**
43
+ * Reserve enough inline budget for a continuation suffix on the current chunk.
44
+ */
45
+ export declare function getSlackContinuationBudget(): {
46
+ maxChars: number;
47
+ maxLines: number;
48
+ };
49
+ /** Normalize text for Slack and wrap it as a PostableMessage with optional file attachments. */
50
+ export declare function buildSlackOutputMessage(text: string, files?: FileUpload[]): PostableMessage;
51
+ export declare const slackOutputPolicy: {
52
+ maxInlineChars: number;
53
+ maxInlineLines: number;
54
+ };
@@ -0,0 +1,33 @@
1
+ import type { FileUpload } from "chat";
2
+ import type { AssistantReply } from "@/chat/respond";
3
+ import { type SlackReplyFooter } from "@/chat/slack/footer";
4
+ export type PlannedSlackReplyStage = "thread_reply" | "thread_reply_continuation" | "thread_reply_files_followup";
5
+ export interface PlannedSlackReplyPost {
6
+ files?: FileUpload[];
7
+ stage: PlannedSlackReplyStage;
8
+ text: string;
9
+ }
10
+ /**
11
+ * Plan the Slack thread posts needed to realize a completed assistant reply,
12
+ * including chunking, interruption markers, and file delivery.
13
+ */
14
+ export declare function planSlackReplyPosts(args: {
15
+ reply: AssistantReply;
16
+ }): PlannedSlackReplyPost[];
17
+ /**
18
+ * Deliver planned Slack reply posts over raw Slack Web API calls for resume and
19
+ * callback handlers that do not have a Chat SDK thread object.
20
+ */
21
+ export declare function postSlackApiReplyPosts(args: {
22
+ beforePost?: () => Promise<void>;
23
+ footer?: SlackReplyFooter;
24
+ channelId: string;
25
+ fileUploadFailureMode?: "best_effort" | "strict";
26
+ onPostError?: (context: {
27
+ error: unknown;
28
+ messageTs?: string;
29
+ stage: PlannedSlackReplyStage;
30
+ }) => Promise<void> | void;
31
+ threadTs: string;
32
+ posts: PlannedSlackReplyPost[];
33
+ }): Promise<string | undefined>;
@@ -0,0 +1,2 @@
1
+ /** Truncate a status string to fit Slack's 50-char assistant status limit. */
2
+ export declare function truncateStatusText(text: string): string;
@@ -0,0 +1,8 @@
1
+ import { type SlackMessageBlock } from "@/chat/slack/footer";
2
+ /** Build the Slack timeout-continuation acknowledgement with correlation-only metadata. */
3
+ export declare function buildSlackTurnContinuationNotice(args: {
4
+ conversationId?: string;
5
+ }): {
6
+ blocks?: SlackMessageBlock[];
7
+ text: string;
8
+ };
@@ -0,0 +1,7 @@
1
+ interface SlackUserLookupResult {
2
+ userName?: string;
3
+ fullName?: string;
4
+ }
5
+ /** Fetch Slack user profile info with in-memory TTL cache to avoid repeated API calls. */
6
+ export declare function lookupSlackUser(userId?: string): Promise<SlackUserLookupResult | null>;
7
+ export {};
@@ -0,0 +1,39 @@
1
+ /** Normalized Slack user profile with custom fields from the Slack workspace. */
2
+ export interface SlackUserProfile {
3
+ id: string;
4
+ team_id?: string;
5
+ name?: string;
6
+ real_name?: string;
7
+ display_name?: string;
8
+ title?: string;
9
+ email?: string;
10
+ status_text?: string;
11
+ status_emoji?: string;
12
+ is_bot: boolean;
13
+ is_deleted: boolean;
14
+ timezone?: string;
15
+ profile_fields?: Array<{
16
+ id: string;
17
+ label?: string;
18
+ value?: string;
19
+ alt?: string;
20
+ }>;
21
+ }
22
+ /** Look up a Slack user by ID, returning the full profile including custom fields. */
23
+ export declare function lookupSlackUserProfile(userId: string): Promise<SlackUserProfile>;
24
+ /** Look up a Slack user by email. Returns null when no user matches. */
25
+ export declare function lookupSlackUserByEmail(email: string): Promise<SlackUserProfile | null>;
26
+ export interface SlackUserSearchResult {
27
+ users: SlackUserProfile[];
28
+ searched_pages: number;
29
+ searched_user_count: number;
30
+ truncated: boolean;
31
+ }
32
+ /** Search workspace users by name with bounded pagination through `users.list`. */
33
+ export declare function searchSlackUsers(options: {
34
+ query: string;
35
+ limit?: number;
36
+ maxPages?: number;
37
+ includeDeleted?: boolean;
38
+ includeBots?: boolean;
39
+ }): Promise<SlackUserSearchResult>;
@@ -0,0 +1,9 @@
1
+ import type { RedisStateAdapter } from "@chat-adapter/state-redis";
2
+ import type { StateAdapter } from "chat";
3
+ export declare const ACTIVE_LOCK_TTL_MS = 90000;
4
+ export declare function getConnectedStateContext(): Promise<{
5
+ redisStateAdapter?: RedisStateAdapter;
6
+ stateAdapter: StateAdapter;
7
+ }>;
8
+ export declare function getStateAdapter(): StateAdapter;
9
+ export declare function disconnectStateAdapter(): Promise<void>;
@@ -0,0 +1,29 @@
1
+ export interface ListColumnMap {
2
+ titleColumnId?: string;
3
+ completedColumnId?: string;
4
+ assigneeColumnId?: string;
5
+ dueDateColumnId?: string;
6
+ }
7
+ export interface CanvasArtifactSummary {
8
+ id: string;
9
+ title?: string;
10
+ url?: string;
11
+ createdAt?: string;
12
+ }
13
+ export interface ThreadArtifactsState {
14
+ assistantContextChannelId?: string;
15
+ assistantTitleSourceMessageId?: string;
16
+ lastCanvasId?: string;
17
+ lastCanvasUrl?: string;
18
+ recentCanvases?: CanvasArtifactSummary[];
19
+ lastListId?: string;
20
+ lastListUrl?: string;
21
+ listColumnMap?: ListColumnMap;
22
+ updatedAt?: string;
23
+ }
24
+ /** Safely coerce an unknown value into a ThreadArtifactsState, discarding invalid fields. */
25
+ export declare function coerceThreadArtifactsState(value: unknown): ThreadArtifactsState;
26
+ /** Wrap a partial artifact update into the storage envelope with an updatedAt timestamp. */
27
+ export declare function buildArtifactStatePatch(patch: Partial<ThreadArtifactsState>): {
28
+ artifacts: ThreadArtifactsState;
29
+ };
@@ -0,0 +1,81 @@
1
+ import type { PiMessage } from "@/chat/pi/messages";
2
+ import type { AuthorizationPauseKind } from "@/chat/services/auth-pause";
3
+ type ConversationRole = "assistant" | "system" | "user";
4
+ export interface ConversationAuthor {
5
+ fullName?: string;
6
+ isBot?: boolean;
7
+ userId?: string;
8
+ userName?: string;
9
+ }
10
+ export interface ConversationMessageMeta {
11
+ attachmentCount?: number;
12
+ explicitMention?: boolean;
13
+ imageAttachmentCount?: number;
14
+ imageFileIds?: string[];
15
+ imagesHydrated?: boolean;
16
+ replied?: boolean;
17
+ slackTs?: string;
18
+ skippedReason?: string;
19
+ }
20
+ export interface ConversationMessage {
21
+ author?: ConversationAuthor;
22
+ createdAtMs: number;
23
+ id: string;
24
+ meta?: ConversationMessageMeta;
25
+ role: ConversationRole;
26
+ text: string;
27
+ }
28
+ export interface ConversationCompaction {
29
+ coveredMessageIds: string[];
30
+ createdAtMs: number;
31
+ id: string;
32
+ summary: string;
33
+ }
34
+ export interface ConversationBackfillState {
35
+ completedAtMs?: number;
36
+ source?: "recent_messages" | "thread_fetch";
37
+ }
38
+ export interface ConversationProcessingState {
39
+ activeTurnId?: string;
40
+ lastCompletedAtMs?: number;
41
+ lastSessionId?: string;
42
+ pendingAuth?: ConversationPendingAuthState;
43
+ }
44
+ export interface ConversationPendingAuthState {
45
+ kind: AuthorizationPauseKind;
46
+ linkSentAtMs: number;
47
+ provider: string;
48
+ requesterId: string;
49
+ sessionId: string;
50
+ }
51
+ export interface ConversationStats {
52
+ compactedMessageCount: number;
53
+ estimatedContextTokens: number;
54
+ totalMessageCount: number;
55
+ updatedAtMs: number;
56
+ }
57
+ export interface ConversationVisionSummary {
58
+ analyzedAtMs: number;
59
+ summary: string;
60
+ }
61
+ export interface ConversationVisionState {
62
+ backfillCompletedAtMs?: number;
63
+ byFileId: Record<string, ConversationVisionSummary>;
64
+ }
65
+ export interface ThreadConversationState {
66
+ backfill: ConversationBackfillState;
67
+ compactions: ConversationCompaction[];
68
+ messages: ConversationMessage[];
69
+ piMessages: PiMessage[];
70
+ processing: ConversationProcessingState;
71
+ schemaVersion: 1;
72
+ stats: ConversationStats;
73
+ vision: ConversationVisionState;
74
+ }
75
+ /** Safely coerce an unknown persisted value into a ThreadConversationState. */
76
+ export declare function coerceThreadConversationState(value: unknown): ThreadConversationState;
77
+ /** Wrap a conversation state into the storage envelope for persistence. */
78
+ export declare function buildConversationStatePatch(conversation: ThreadConversationState): {
79
+ conversation: ThreadConversationState;
80
+ };
81
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { PiMessage } from "@/chat/pi/messages";
2
+ interface PiSessionScope {
3
+ conversationId: string;
4
+ sessionId: string;
5
+ }
6
+ /** Load the exact stable Pi message prefix for a session. */
7
+ export declare function loadPiSessionMessages(args: PiSessionScope & {
8
+ messageCount: number;
9
+ }): Promise<PiMessage[] | undefined>;
10
+ /** Commit new stable Pi messages before the caller advances its cursor. */
11
+ export declare function commitPiSessionMessages(args: PiSessionScope & {
12
+ messages: PiMessage[];
13
+ ttlMs: number;
14
+ }): Promise<void>;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Build a stable turn identifier from a message ID. */
2
+ export declare function buildDeterministicTurnId(messageId: string): string;
@@ -0,0 +1,49 @@
1
+ import type { PiMessage } from "@/chat/pi/messages";
2
+ import type { AgentTurnUsage } from "@/chat/usage";
3
+ export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "superseded";
4
+ export type AgentTurnResumeReason = "timeout" | "auth";
5
+ export interface AgentTurnSessionCheckpoint {
6
+ checkpointVersion: number;
7
+ conversationId: string;
8
+ cumulativeDurationMs?: number;
9
+ cumulativeUsage?: AgentTurnUsage;
10
+ errorMessage?: string;
11
+ loadedSkillNames?: string[];
12
+ piMessages: PiMessage[];
13
+ resumeReason?: AgentTurnResumeReason;
14
+ resumedFromSliceId?: number;
15
+ sessionId: string;
16
+ sliceId: number;
17
+ state: AgentTurnSessionStatus;
18
+ updatedAtMs: number;
19
+ }
20
+ /** Read a materialized turn-session checkpoint for resume and history loading. */
21
+ export declare function getAgentTurnSessionCheckpoint(conversationId: string, sessionId: string): Promise<AgentTurnSessionCheckpoint | undefined>;
22
+ /** Commit stable Pi session state and advance the turn-session checkpoint cursor. */
23
+ export declare function upsertAgentTurnSessionCheckpoint(args: {
24
+ conversationId: string;
25
+ cumulativeDurationMs?: number;
26
+ cumulativeUsage?: AgentTurnUsage;
27
+ sessionId: string;
28
+ sliceId: number;
29
+ state: AgentTurnSessionStatus;
30
+ piMessages: PiMessage[];
31
+ loadedSkillNames?: string[];
32
+ resumeReason?: AgentTurnResumeReason;
33
+ errorMessage?: string;
34
+ resumedFromSliceId?: number;
35
+ ttlMs?: number;
36
+ }): Promise<AgentTurnSessionCheckpoint>;
37
+ /** Mark an unfinished turn-session checkpoint as superseded when a newer turn wins. */
38
+ export declare function supersedeAgentTurnSessionCheckpoint(args: {
39
+ conversationId: string;
40
+ sessionId: string;
41
+ errorMessage?: string;
42
+ }): Promise<AgentTurnSessionCheckpoint | undefined>;
43
+ /** Mark an unfinished turn-session checkpoint as failed so it cannot resume. */
44
+ export declare function failAgentTurnSessionCheckpoint(args: {
45
+ conversationId: string;
46
+ expectedCheckpointVersion?: number;
47
+ sessionId: string;
48
+ errorMessage?: string;
49
+ }): Promise<AgentTurnSessionCheckpoint | undefined>;
@@ -0,0 +1,9 @@
1
+ import type { PiMessage } from "@/chat/pi/messages";
2
+ export interface AdvisorSessionStore {
3
+ load: (conversationId: string) => Promise<PiMessage[]>;
4
+ save: (conversationId: string, messages: PiMessage[]) => Promise<void>;
5
+ }
6
+ /** Return the durable advisor session key for an opaque parent conversation id. */
7
+ export declare function getAdvisorSessionKey(conversationId: string): string;
8
+ /** Create the production advisor message store backed by the chat state adapter. */
9
+ export declare function createStateAdvisorSessionStore(): AdvisorSessionStore;
@@ -0,0 +1,33 @@
1
+ import { type AgentTool, type StreamFn } from "@earendil-works/pi-agent-core";
2
+ import type { AdvisorConfig } from "@/chat/config";
3
+ import { type LogContext } from "@/chat/logging";
4
+ import { type AdvisorSessionStore } from "@/chat/tools/advisor/session-store";
5
+ import { type ToolDefinition } from "@/chat/tools/definition";
6
+ export type AdvisorErrorCode = "invalid_context" | "invalid_question" | "missing_conversation_id" | "session_unavailable" | "unavailable";
7
+ export interface AdvisorToolResult {
8
+ content: [{
9
+ type: "text";
10
+ text: string;
11
+ }];
12
+ details: {
13
+ ok: true;
14
+ } | {
15
+ error_code: AdvisorErrorCode;
16
+ ok: false;
17
+ };
18
+ }
19
+ export interface AdvisorToolRuntimeContext {
20
+ config: AdvisorConfig;
21
+ conversationId?: string;
22
+ getTools: () => AgentTool[];
23
+ logContext?: LogContext;
24
+ store?: AdvisorSessionStore;
25
+ streamFn?: StreamFn;
26
+ }
27
+ /** Build the advisor's read-only tool definition subset. */
28
+ export declare function createAdvisorToolDefinitions(definitions: Record<string, ToolDefinition<any>>): Record<string, ToolDefinition<any>>;
29
+ /** Create the advisor tool backed by conversation-scoped message history. */
30
+ export declare function createAdvisorTool(context: AdvisorToolRuntimeContext): ToolDefinition<import("@sinclair/typebox").TObject<{
31
+ question: import("@sinclair/typebox").TString;
32
+ context: import("@sinclair/typebox").TString;
33
+ }>>;
@@ -0,0 +1,9 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import { type LogContext } from "@/chat/logging";
3
+ import type { PluginAuthOrchestration } from "@/chat/services/plugin-auth-orchestration";
4
+ import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
5
+ import type { SandboxExecutor } from "@/chat/sandbox/sandbox";
6
+ import type { SkillSandbox } from "@/chat/sandbox/skill-sandbox";
7
+ import type { ToolDefinition } from "@/chat/tools/definition";
8
+ /** Wrap tool definitions into Pi Agent tool objects with logging, validation, and sandbox execution. */
9
+ export declare function createAgentTools(tools: Record<string, ToolDefinition<any>>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void): AgentTool[];
@@ -0,0 +1,11 @@
1
+ /** Declared capabilities of the current channel context. */
2
+ export interface ChannelCapabilities {
3
+ /** Can create canvases in this channel (C/G/D channels). */
4
+ canCreateCanvas: boolean;
5
+ /** Can post standalone messages to this channel (C/G channels only). */
6
+ canPostToChannel: boolean;
7
+ /** Can add reactions to messages (C/G/D channels). */
8
+ canAddReactions: boolean;
9
+ }
10
+ /** Resolve channel capabilities from a Slack channel ID. */
11
+ export declare function resolveChannelCapabilities(channelId: string | undefined): ChannelCapabilities;
@@ -0,0 +1,17 @@
1
+ import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { Static, TSchema } from "@sinclair/typebox";
3
+ import type { ToolExecutionMode } from "@earendil-works/pi-agent-core";
4
+ export interface ToolDefinition<TInputSchema extends TSchema = TSchema> {
5
+ description: string;
6
+ inputSchema: TInputSchema;
7
+ annotations?: ToolAnnotations;
8
+ promptSnippet?: string;
9
+ promptGuidelines?: string[];
10
+ prepareArguments?: (args: unknown) => Static<TInputSchema>;
11
+ executionMode?: ToolExecutionMode;
12
+ execute?: (input: Static<TInputSchema>, options: {
13
+ experimental_context?: unknown;
14
+ }) => Promise<unknown> | unknown;
15
+ }
16
+ /** Infer execute parameter types from the inputSchema via generic binding. */
17
+ export declare function tool<TInputSchema extends TSchema>(definition: ToolDefinition<TInputSchema>): ToolDefinition<TInputSchema>;
@@ -0,0 +1,2 @@
1
+ /** Normalize LLM tool params into the shape expected by the sandbox executor. */
2
+ export declare function buildSandboxInput(toolName: string, params: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,6 @@
1
+ import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
2
+ /** Unwrap sandbox envelope and detect structured results. */
3
+ export declare function normalizeToolResult(result: unknown, isSandboxResult: boolean): {
4
+ content: Array<TextContent | ImageContent>;
5
+ details: unknown;
6
+ };
@@ -0,0 +1,3 @@
1
+ import { type LogContext } from "@/chat/logging";
2
+ /** Handle tool execution errors: set span attributes, log, and rethrow. */
3
+ export declare function handleToolExecutionError(error: unknown, toolName: string, toolCallId: string | undefined, shouldTrace: boolean, traceContext: LogContext): never;
@@ -0,0 +1,6 @@
1
+ /** Thrown when a tool fails due to invalid model/user input, not a system error. */
2
+ export declare class ToolInputError extends Error {
3
+ constructor(message: string, options?: {
4
+ cause?: unknown;
5
+ });
6
+ }
@@ -0,0 +1 @@
1
+ export declare function createOperationKey(toolName: string, input: Record<string, unknown>): string;
@@ -0,0 +1,5 @@
1
+ import type { SkillMetadata } from "@/chat/skills";
2
+ import type { ToolDefinition } from "@/chat/tools/definition";
3
+ import type { ToolHooks, ToolRuntimeContext } from "@/chat/tools/types";
4
+ export type { ToolHooks, ToolRuntimeContext };
5
+ export declare function createTools(availableSkills: SkillMetadata[], hooks: ToolHooks | undefined, context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
@@ -0,0 +1,4 @@
1
+ /** Create the internal tool the model uses for sparse progress updates. */
2
+ export declare function createReportProgressTool(): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
+ message: import("@sinclair/typebox").TString;
4
+ }>>;
@@ -0,0 +1,7 @@
1
+ import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
2
+ import type { ToolHooks } from "@/chat/tools/types";
3
+ export declare function createAttachFileTool(sandbox: SandboxWorkspace, hooks?: ToolHooks): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
4
+ path: import("@sinclair/typebox").TString;
5
+ filename: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
6
+ mimeType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
7
+ }>>;
@@ -0,0 +1,5 @@
1
+ /** Create the sandbox shell tool definition exposed to the agent. */
2
+ export declare function createBashTool(): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
+ command: import("@sinclair/typebox").TString;
4
+ timeoutMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
5
+ }>>;
@@ -0,0 +1,37 @@
1
+ import { type SandboxFileSystem } from "@/chat/tools/sandbox/file-utils";
2
+ import { type TextReplacement } from "@/chat/tools/sandbox/text-edits";
3
+ type EditReplacement = TextReplacement;
4
+ interface EditFileResult {
5
+ content: [{
6
+ type: "text";
7
+ text: string;
8
+ }];
9
+ details: {
10
+ diff: string;
11
+ first_changed_line?: number;
12
+ ok: true;
13
+ path: string;
14
+ replacements: number;
15
+ };
16
+ }
17
+ interface EditFileInput {
18
+ path: string;
19
+ edits: EditReplacement[];
20
+ }
21
+ /** Accept common edit argument variants before Pi validates the canonical schema. */
22
+ export declare function prepareEditFileArguments(input: unknown): EditFileInput;
23
+ /** Apply exact, ordered file replacements through the sandbox filesystem API. */
24
+ export declare function editFile(params: {
25
+ edits: EditReplacement[];
26
+ fs: SandboxFileSystem;
27
+ path: string;
28
+ }): Promise<EditFileResult>;
29
+ /** Create the sandbox edit tool definition exposed to the agent. */
30
+ export declare function createEditFileTool(): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
31
+ path: import("@sinclair/typebox").TString;
32
+ edits: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
33
+ oldText: import("@sinclair/typebox").TString;
34
+ newText: import("@sinclair/typebox").TString;
35
+ }>>;
36
+ }>>;
37
+ export {};