@sentry/junior 0.88.0 → 0.90.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 (158) hide show
  1. package/README.md +16 -5
  2. package/dist/{agent-hooks-RIJ5TSWP.js → agent-hooks-MXAF7RQL.js} +10 -10
  3. package/dist/api/people/list.js +8 -8
  4. package/dist/api/people/profile.js +8 -8
  5. package/dist/api-reference.d.ts +1 -1
  6. package/dist/app.js +716 -732
  7. package/dist/{catalog-runtime-MW7XERSU.js → catalog-runtime-DXE6NXHT.js} +5 -5
  8. package/dist/chat/agent/index.d.ts +4 -0
  9. package/dist/chat/agent/prompt.d.ts +78 -0
  10. package/dist/chat/{respond.d.ts → agent/request.d.ts} +98 -55
  11. package/dist/chat/agent/resume.d.ts +65 -0
  12. package/dist/chat/agent/sandbox.d.ts +15 -0
  13. package/dist/chat/agent/session.d.ts +20 -0
  14. package/dist/chat/agent/skills.d.ts +26 -0
  15. package/dist/chat/agent/tools.d.ts +78 -0
  16. package/dist/chat/agent-dispatch/runner.d.ts +3 -5
  17. package/dist/chat/app/production.d.ts +3 -1
  18. package/dist/chat/app/services.d.ts +1 -4
  19. package/dist/chat/logging.d.ts +2 -0
  20. package/dist/chat/mcp/tool-manager.d.ts +1 -6
  21. package/dist/chat/pi/messages.d.ts +18 -2
  22. package/dist/chat/pi/transcript.d.ts +31 -0
  23. package/dist/chat/plugins/agent-hooks.d.ts +2 -2
  24. package/dist/chat/prompt.d.ts +1 -1
  25. package/dist/chat/runtime/agent-continue-runner.d.ts +5 -5
  26. package/dist/chat/runtime/agent-run-outcome.d.ts +21 -0
  27. package/dist/chat/runtime/agent-runner.d.ts +11 -0
  28. package/dist/chat/runtime/delivered-turn-state.d.ts +2 -2
  29. package/dist/chat/runtime/generated-artifacts.d.ts +16 -0
  30. package/dist/chat/runtime/reply-executor.d.ts +2 -2
  31. package/dist/chat/runtime/slack-resume.d.ts +21 -12
  32. package/dist/chat/runtime/turn.d.ts +5 -39
  33. package/dist/chat/services/reply-delivery-plan.d.ts +0 -8
  34. package/dist/chat/services/turn-failure-response.d.ts +4 -4
  35. package/dist/chat/services/turn-result.d.ts +4 -7
  36. package/dist/chat/slack/channel.d.ts +9 -5
  37. package/dist/chat/slack/client.d.ts +3 -1
  38. package/dist/chat/slack/context.d.ts +17 -5
  39. package/dist/chat/slack/id-param.d.ts +25 -0
  40. package/dist/chat/slack/ids.d.ts +18 -4
  41. package/dist/chat/slack/outbound.d.ts +16 -0
  42. package/dist/chat/slack/output.d.ts +3 -3
  43. package/dist/chat/slack/reply.d.ts +4 -7
  44. package/dist/chat/slack/timestamp-param.d.ts +25 -0
  45. package/dist/chat/slack/tools/canvas/context.d.ts +18 -0
  46. package/dist/chat/slack/tools/canvas/create.d.ts +4 -0
  47. package/dist/chat/slack/tools/canvas/edit.d.ts +3 -0
  48. package/dist/chat/slack/tools/canvas/read.d.ts +6 -0
  49. package/dist/chat/slack/tools/canvas/write.d.ts +3 -0
  50. package/dist/chat/{tools/slack → slack/tools}/channel-access.d.ts +4 -3
  51. package/dist/chat/{tools → slack/tools}/channel-capabilities.d.ts +2 -0
  52. package/dist/chat/slack/tools/channel-list-messages.d.ts +3 -0
  53. package/dist/chat/{tools/slack → slack/tools}/context.d.ts +5 -4
  54. package/dist/chat/slack/tools/list/add-items.d.ts +3 -0
  55. package/dist/chat/{tools/slack/lists.d.ts → slack/tools/list/api.d.ts} +2 -1
  56. package/dist/chat/slack/tools/list/create.d.ts +3 -0
  57. package/dist/chat/slack/tools/list/get-items.d.ts +3 -0
  58. package/dist/chat/slack/tools/list/update-item.d.ts +3 -0
  59. package/dist/chat/slack/tools/message-add-reaction.d.ts +4 -0
  60. package/dist/chat/slack/tools/send-message.d.ts +11 -0
  61. package/dist/chat/{tools/slack → slack/tools}/slack-message-url.d.ts +5 -5
  62. package/dist/chat/slack/tools/thread-read.d.ts +6 -0
  63. package/dist/chat/slack/tools/user-lookup.d.ts +2 -0
  64. package/dist/chat/slack/users.d.ts +2 -1
  65. package/dist/chat/{services → slack}/vision-context.d.ts +4 -2
  66. package/dist/chat/state/session-log.d.ts +1 -1
  67. package/dist/chat/tool-exposure.d.ts +10 -0
  68. package/dist/chat/tool-support/catalog-tool-call.d.ts +10 -0
  69. package/dist/chat/{tools/execution → tool-support}/normalize-result.d.ts +4 -1
  70. package/dist/chat/{tools/agent-tools.d.ts → tool-support/pi-tool-adapter.d.ts} +3 -9
  71. package/dist/chat/tool-support/schema-summary.d.ts +2 -0
  72. package/dist/chat/{tools → tool-support}/skill/mcp-tool-summary.d.ts +0 -6
  73. package/dist/chat/tool-support/structured-result.d.ts +73 -0
  74. package/dist/chat/tool-support/text-range-result.d.ts +58 -0
  75. package/dist/chat/tool-support/tool-execution-report.d.ts +7 -0
  76. package/dist/chat/tool-support/zod-tool.d.ts +27 -0
  77. package/dist/chat/tools/advisor/tool.d.ts +9 -18
  78. package/dist/chat/tools/definition.d.ts +56 -9
  79. package/dist/chat/tools/execute-tool.d.ts +3 -0
  80. package/dist/chat/tools/index.d.ts +3 -2
  81. package/dist/chat/tools/resource-events.d.ts +3 -13
  82. package/dist/chat/tools/runtime/report-progress.d.ts +1 -3
  83. package/dist/chat/tools/sandbox/bash.d.ts +1 -4
  84. package/dist/chat/tools/sandbox/edit-file.d.ts +25 -7
  85. package/dist/chat/tools/sandbox/file-uploads.d.ts +30 -0
  86. package/dist/chat/tools/sandbox/file-utils.d.ts +10 -1
  87. package/dist/chat/tools/sandbox/find-files.d.ts +12 -11
  88. package/dist/chat/tools/sandbox/grep.d.ts +18 -12
  89. package/dist/chat/tools/sandbox/list-dir.d.ts +15 -7
  90. package/dist/chat/tools/sandbox/read-file.d.ts +2 -31
  91. package/dist/chat/tools/sandbox/write-file.d.ts +1 -4
  92. package/dist/chat/tools/search-tools.d.ts +4 -0
  93. package/dist/chat/tools/skill/call-mcp-tool.d.ts +1 -4
  94. package/dist/chat/tools/skill/load-skill.d.ts +4 -5
  95. package/dist/chat/tools/skill/search-mcp-tools.d.ts +1 -5
  96. package/dist/chat/tools/system-time.d.ts +1 -1
  97. package/dist/chat/tools/types.d.ts +15 -5
  98. package/dist/chat/tools/web/fetch-content.d.ts +4 -2
  99. package/dist/chat/tools/web/fetch-tool.d.ts +4 -4
  100. package/dist/chat/tools/web/image-generate.d.ts +4 -3
  101. package/dist/chat/tools/web/search.d.ts +1 -4
  102. package/dist/{chunk-4IXHIV37.js → chunk-2S7M37HY.js} +6 -8
  103. package/dist/{chunk-L7OHKDOX.js → chunk-3MPOMK3K.js} +58 -7
  104. package/dist/{chunk-V6XDCS3X.js → chunk-5GBUZI6M.js} +4 -4
  105. package/dist/{chunk-7ES37H6U.js → chunk-AN2437E3.js} +4 -4
  106. package/dist/chunk-AOISHLSF.js +747 -0
  107. package/dist/{chunk-NYJLQI42.js → chunk-BKSZL4QO.js} +11257 -11957
  108. package/dist/{chunk-XS6NLQPA.js → chunk-DACFZ5CI.js} +474 -33
  109. package/dist/chunk-GCWD2VHP.js +1216 -0
  110. package/dist/chunk-GHGPTPBL.js +53 -0
  111. package/dist/{chunk-S35CPNPT.js → chunk-HXL2ZV74.js} +40 -216
  112. package/dist/{chunk-PBV4ZIVM.js → chunk-IRRMABQD.js} +1 -1
  113. package/dist/{chunk-2DPZRS3B.js → chunk-IX76WFJV.js} +8 -8
  114. package/dist/{chunk-66NX7MNW.js → chunk-KC42JAAQ.js} +1 -1
  115. package/dist/chunk-LFLTJQVR.js +90 -0
  116. package/dist/{chunk-IATAYWFU.js → chunk-NW7AXDA5.js} +2 -2
  117. package/dist/{chunk-F22AM3OW.js → chunk-NYWPISSO.js} +1 -1
  118. package/dist/chunk-OB42YVAE.js +16 -0
  119. package/dist/chunk-ONFOWI2D.js +955 -0
  120. package/dist/chunk-PHZHJTCK.js +1062 -0
  121. package/dist/{chunk-6UPQ5GTJ.js → chunk-QCKGI74V.js} +7 -7
  122. package/dist/{chunk-YPAE5RH3.js → chunk-RS6ANWVT.js} +1 -1
  123. package/dist/{chunk-C5NCV3OB.js → chunk-TYUXD3FN.js} +1 -1
  124. package/dist/{chunk-KBFQXJL4.js → chunk-XP7F4LYB.js} +5 -7
  125. package/dist/{chunk-VMBZFPZM.js → chunk-ZUK7BL63.js} +187 -9
  126. package/dist/cli/chat.js +55 -40
  127. package/dist/cli/check.js +6 -6
  128. package/dist/cli/init.js +30 -36
  129. package/dist/cli/plugins.js +16 -16
  130. package/dist/cli/snapshot-warmup.js +9 -9
  131. package/dist/cli/upgrade.js +21 -21
  132. package/dist/db-CXI7PR5U.js +18 -0
  133. package/dist/handlers/agent-dispatch.d.ts +3 -3
  134. package/dist/handlers/mcp-oauth-callback.d.ts +3 -3
  135. package/dist/handlers/oauth-callback.d.ts +3 -3
  136. package/dist/instrumentation.js +6 -5
  137. package/dist/nitro.js +3 -7
  138. package/dist/reporting.js +23 -25
  139. package/dist/{runner-BCRF2FCI.js → runner-FKL3RAHA.js} +89 -77
  140. package/dist/{validation-FMJO3L5P.js → validation-I7GD2YWS.js} +6 -6
  141. package/package.json +6 -6
  142. package/dist/chat/respond-helpers.d.ts +0 -82
  143. package/dist/chat/services/attachment-claims.d.ts +0 -2
  144. package/dist/chat/services/channel-intent.d.ts +0 -2
  145. package/dist/chat/tools/sandbox/attach-file.d.ts +0 -7
  146. package/dist/chat/tools/slack/canvas-tools.d.ts +0 -30
  147. package/dist/chat/tools/slack/channel-list-messages.d.ts +0 -9
  148. package/dist/chat/tools/slack/channel-post-message.d.ts +0 -5
  149. package/dist/chat/tools/slack/list-tools.d.ts +0 -21
  150. package/dist/chat/tools/slack/message-add-reaction.d.ts +0 -5
  151. package/dist/chat/tools/slack/thread-read.d.ts +0 -12
  152. package/dist/chat/tools/slack/user-lookup.d.ts +0 -8
  153. package/dist/chunk-AHLSXMOU.js +0 -506
  154. package/dist/chunk-FTMXFBDC.js +0 -49
  155. package/dist/chunk-KBSLCOGE.js +0 -2226
  156. package/dist/chunk-KQKIA4CU.js +0 -186
  157. package/dist/db-37HOGLI7.js +0 -18
  158. /package/dist/chat/{tools/slack/canvases.d.ts → slack/tools/canvas/api.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { PluginConversations, PluginRoute, PluginOperationalReport, PluginRouteApp, SlackConversationLink, PluginRegistration } from "@sentry/junior-plugin-api";
2
2
  import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
3
- import type { ToolDefinition } from "@/chat/tools/definition";
3
+ import type { AnyToolDefinition } from "@/chat/tools/definition";
4
4
  import type { ToolRuntimeContext } from "@/chat/tools/types";
5
5
  import type { SandboxInstance } from "@/chat/sandbox/workspace";
6
6
  import type { Requester } from "@/chat/requester";
@@ -40,7 +40,7 @@ export declare function getPluginUserPromptContributions(args: {
40
40
  context: Pick<ToolRuntimeContext, "conversationId" | "destination" | "requester" | "source" | "userText">;
41
41
  }): Promise<PluginPromptContributionContext[]>;
42
42
  /** Collect turn-scoped tools exposed by plugins. */
43
- export declare function getPluginTools(context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
43
+ export declare function getPluginTools(context: ToolRuntimeContext): Record<string, AnyToolDefinition>;
44
44
  /** Collect route handlers exposed by plugins for app-level mounting. */
45
45
  export declare function getPluginRoutes(): PluginRouteRegistration[];
46
46
  /** Collect authenticated product API route apps exposed by plugins. */
@@ -1,7 +1,7 @@
1
1
  import type { SlackConversationContext } from "@/chat/slack/conversation-context";
2
2
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
3
3
  import type { SkillMetadata, SkillInvocation } from "@/chat/skills";
4
- import type { ActiveMcpCatalogSummary } from "@/chat/tools/skill/mcp-tool-summary";
4
+ import type { ActiveMcpCatalogSummary } from "@/chat/tool-support/skill/mcp-tool-summary";
5
5
  import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
6
6
  import type { Destination, Source } from "@sentry/junior-plugin-api";
7
7
  export declare const JUNIOR_PERSONALITY: string;
@@ -1,9 +1,9 @@
1
1
  import { resumeSlackTurn } from "@/chat/runtime/slack-resume";
2
2
  import { type AgentContinueRequest } from "@/chat/services/agent-continue";
3
- import type { generateAssistantReply } from "@/chat/respond";
3
+ import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
4
  /** Runtime ports for agent continuation scheduling. */
5
5
  export interface AgentContinueRunnerOptions {
6
- generateReply?: typeof generateAssistantReply;
6
+ agentRunner: AgentRunner;
7
7
  resumeTurn?: typeof resumeSlackTurn;
8
8
  scheduleAgentContinue?: (request: AgentContinueRequest) => Promise<void>;
9
9
  scheduleSessionCompletedPluginTasks?: (params: {
@@ -16,9 +16,9 @@ export interface AgentContinueRunnerOptions {
16
16
  *
17
17
  * Returns false when the session became stale before generation began.
18
18
  */
19
- export declare function continueSlackAgentRun(payload: AgentContinueRequest, options?: AgentContinueRunnerOptions): Promise<boolean>;
19
+ export declare function continueSlackAgentRun(payload: AgentContinueRequest, options: AgentContinueRunnerOptions): Promise<boolean>;
20
20
  /** Resume the first valid paused Slack session for an idle conversation. */
21
- export declare function resumeAwaitingSlackContinuation(conversationId: string, options?: AgentContinueRunnerOptions): Promise<boolean>;
21
+ export declare function resumeAwaitingSlackContinuation(conversationId: string, options: AgentContinueRunnerOptions): Promise<boolean>;
22
22
  /**
23
23
  * Retry agent continuation when the normal Slack thread lock is briefly busy.
24
24
  *
@@ -26,4 +26,4 @@ export declare function resumeAwaitingSlackContinuation(conversationId: string,
26
26
  * lock that is rescheduled still returns true because runnable work remains
27
27
  * durable.
28
28
  */
29
- export declare function continueSlackAgentRunWithLockRetry(payload: AgentContinueRequest, options?: AgentContinueRunnerOptions): Promise<boolean>;
29
+ export declare function continueSlackAgentRunWithLockRetry(payload: AgentContinueRequest, options: AgentContinueRunnerOptions): Promise<boolean>;
@@ -0,0 +1,21 @@
1
+ import type { AgentRunResult } from "@/chat/services/turn-result";
2
+ /**
3
+ * How an agent run ended. `completed` carries the terminal result (success or
4
+ * failure — `result.diagnostics` distinguishes them). `suspended` means the run
5
+ * persisted an awaiting_resume session record and stopped at a safe boundary;
6
+ * the caller resumes it by scheduling a continuation against `resumeVersion`,
7
+ * the session record's optimistic-concurrency version. `awaiting_auth` means
8
+ * the run parked for user authorization.
9
+ */
10
+ export type AgentRunOutcome = {
11
+ status: "completed";
12
+ result: AgentRunResult;
13
+ } | {
14
+ status: "suspended";
15
+ resumeVersion: number;
16
+ } | {
17
+ status: "awaiting_auth";
18
+ providerDisplayName: string;
19
+ };
20
+ /** Wrap a terminal result (successful or failed per its diagnostics) as an outcome. */
21
+ export declare function completedAgentRun(result: AgentRunResult): AgentRunOutcome;
@@ -0,0 +1,11 @@
1
+ import type { AgentRunRequest } from "@/chat/agent/request";
2
+ import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
3
+ import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
4
+ /** Run one agent-run slice behind runtime-owned orchestration boundaries. */
5
+ export interface AgentRunner {
6
+ run(request: AgentRunRequest): Promise<AgentRunOutcome>;
7
+ }
8
+ /** Adapt the Pi-facing agent-run executor behind the runtime-owned runner seam. */
9
+ export declare function createAgentRunner(run: AgentRunner["run"], options?: {
10
+ tracePropagation?: SandboxEgressTracePropagationConfig;
11
+ }): AgentRunner;
@@ -1,4 +1,4 @@
1
- import type { AssistantReply } from "@/chat/respond";
1
+ import type { AgentRunResult } from "@/chat/services/turn-result";
2
2
  import type { ThreadConversationState } from "@/chat/state/conversation";
3
3
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
4
4
  import { type ThreadStatePatch } from "@/chat/runtime/thread-state";
@@ -7,7 +7,7 @@ export declare function buildDeliveredTurnStatePatch(args: {
7
7
  artifactStatePatch?: Partial<ThreadArtifactsState>;
8
8
  artifacts: ThreadArtifactsState;
9
9
  conversation: ThreadConversationState;
10
- reply: AssistantReply;
10
+ reply: AgentRunResult;
11
11
  sessionId: string;
12
12
  userMessageId?: string;
13
13
  }): ThreadStatePatch & {
@@ -0,0 +1,16 @@
1
+ import type { FileUpload } from "chat";
2
+ import type { GeneratedArtifactFileRef } from "@/chat/tools/types";
3
+ import type { SandboxCommandResult } from "@/chat/sandbox/workspace";
4
+ /** Sandbox operations needed to make generated artifacts visible to later tools. */
5
+ export interface GeneratedArtifactSandbox {
6
+ runCommand(input: {
7
+ args?: string[];
8
+ cmd: string;
9
+ }): Promise<SandboxCommandResult>;
10
+ writeFiles(files: Array<{
11
+ content: string | Uint8Array;
12
+ path: string;
13
+ }>): Promise<void>;
14
+ }
15
+ /** Persist generated artifacts into the sandbox before returning model-visible handles. */
16
+ export declare function writeSandboxGeneratedArtifacts(sandbox: GeneratedArtifactSandbox, files: FileUpload[]): Promise<GeneratedArtifactFileRef[]>;
@@ -1,7 +1,7 @@
1
1
  import type { Message, Thread } from "chat";
2
2
  import type { SlackAdapter } from "@chat-adapter/slack";
3
3
  import { type Destination } from "@sentry/junior-plugin-api";
4
- import { generateAssistantReply as generateAssistantReplyImpl } from "@/chat/respond";
4
+ import type { AgentRunner } from "@/chat/runtime/agent-runner";
5
5
  import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
6
6
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnToolInvocation } from "@/chat/runtime/turn-input";
7
7
  import { type ConversationMemoryService } from "@/chat/services/conversation-memory";
@@ -9,8 +9,8 @@ import type { ContextCompactor } from "@/chat/services/context-compaction";
9
9
  import { lookupSlackUser } from "@/chat/slack/user";
10
10
  import type { AgentContinueRequest } from "@/chat/services/agent-continue";
11
11
  export interface ReplyExecutorServices {
12
+ agentRunner: AgentRunner;
12
13
  contextCompactor: ContextCompactor;
13
- generateAssistantReply: typeof generateAssistantReplyImpl;
14
14
  generateThreadTitle: ConversationMemoryService["generateThreadTitle"];
15
15
  getAwaitingAgentContinueRequest: (args: {
16
16
  conversationId: string;
@@ -1,5 +1,6 @@
1
- import { generateAssistantReply, type AssistantReply, type AssistantReplyRequestContext } from "@/chat/respond";
2
- import type { Source } from "@sentry/junior-plugin-api";
1
+ import type { AgentRunRequest } from "@/chat/agent/request";
2
+ import type { AgentRunResult } from "@/chat/services/turn-result";
3
+ import type { AgentRunner } from "@/chat/runtime/agent-runner";
3
4
  import type { SlackMessageTs } from "@/chat/slack/timestamp";
4
5
  /** Error raised when another worker already owns the resume lock. */
5
6
  export declare class ResumeTurnBusyError extends Error {
@@ -13,21 +14,25 @@ interface ResumeSlackTurnArgs {
13
14
  replyContext?: ResumeReplyContext;
14
15
  lockKey?: string;
15
16
  initialText?: string;
16
- generateReply?: typeof generateAssistantReply;
17
+ agentRunner: AgentRunner;
17
18
  scheduleSessionCompletedPluginTasks?: (params: {
18
19
  conversationId: string;
19
20
  sessionId: string;
20
21
  }) => Promise<void>;
21
- onSuccess?: (reply: AssistantReply) => Promise<void>;
22
+ onSuccess?: (reply: AgentRunResult) => Promise<void>;
22
23
  onFailure?: (error: unknown) => Promise<void>;
23
- onAuthPause?: (error: unknown) => Promise<void>;
24
- onTimeoutPause?: (error: unknown) => Promise<void>;
24
+ onAuthPause?: (pause: {
25
+ providerDisplayName: string;
26
+ }) => Promise<void>;
27
+ onTimeoutPause?: (resume: {
28
+ resumeVersion: number;
29
+ }) => Promise<void>;
25
30
  onPostDeliveryCommitFailure?: (error: unknown) => Promise<void>;
26
31
  beforeStart?: () => Promise<Partial<ResumeSlackTurnArgs> | false | void>;
27
32
  replyTimeoutMs?: number;
28
33
  }
29
- type ResumeReplyContext = AssistantReplyRequestContext & {
30
- source: Source;
34
+ type ResumeReplyContext = Omit<AgentRunRequest, "input"> & {
35
+ input?: Omit<AgentRunRequest["input"], "messageText">;
31
36
  };
32
37
  /**
33
38
  * Resume a paused Slack turn under the normal thread lock.
@@ -46,11 +51,15 @@ export declare function resumeAuthorizedRequest(args: {
46
51
  connectedText: string;
47
52
  replyContext?: ResumeReplyContext;
48
53
  lockKey?: string;
49
- generateReply?: typeof generateAssistantReply;
50
- onSuccess?: (reply: AssistantReply) => Promise<void>;
54
+ agentRunner: AgentRunner;
55
+ onSuccess?: (reply: AgentRunResult) => Promise<void>;
51
56
  onFailure?: (error: unknown) => Promise<void>;
52
- onAuthPause?: (error: unknown) => Promise<void>;
53
- onTimeoutPause?: (error: unknown) => Promise<void>;
57
+ onAuthPause?: (pause: {
58
+ providerDisplayName: string;
59
+ }) => Promise<void>;
60
+ onTimeoutPause?: (resume: {
61
+ resumeVersion: number;
62
+ }) => Promise<void>;
54
63
  onPostDeliveryCommitFailure?: (error: unknown) => Promise<void>;
55
64
  beforeStart?: () => Promise<Partial<ResumeSlackTurnArgs> | false | void>;
56
65
  replyTimeoutMs?: number;
@@ -1,44 +1,10 @@
1
1
  import type { ThreadConversationState } from "@/chat/state/conversation";
2
- import type { AuthorizationPauseDisposition, AuthorizationPauseKind } from "@/chat/services/auth-pause";
3
- import type { TurnThinkingSelection } from "@/chat/services/turn-thinking-level";
4
- import type { AgentTurnUsage } from "@/chat/usage";
5
2
  export { buildDeterministicTurnId } from "@/chat/state/turn-id";
6
- export type RetryableTurnReason = "mcp_auth_resume" | "plugin_auth_resume" | "agent_continue";
7
- /** Auth-pause reasons require a known provider before a resume can be parked. */
8
- export type AuthResumeRetryableTurnReason = Extract<RetryableTurnReason, "mcp_auth_resume" | "plugin_auth_resume">;
9
- export interface RetryableTurnMetadata {
10
- authDisposition?: AuthorizationPauseDisposition;
11
- authDurationMs?: number;
12
- authKind?: AuthorizationPauseKind;
13
- authProvider?: string;
14
- authProviderDisplayName?: string;
15
- authThinkingLevel?: TurnThinkingSelection["thinkingLevel"];
16
- authUsage?: AgentTurnUsage;
17
- version?: number;
18
- conversationId?: string;
19
- sessionId?: string;
20
- sliceId?: number;
21
- }
22
- export interface AuthResumeRetryableTurnMetadata extends RetryableTurnMetadata {
23
- authProvider: string;
24
- authProviderDisplayName: string;
25
- }
26
- export type AuthResumeRetryableTurnError = RetryableTurnError & {
27
- readonly reason: AuthResumeRetryableTurnReason;
28
- readonly metadata: AuthResumeRetryableTurnMetadata;
29
- };
30
- /** Error indicating an agent run can continue later after timeout or auth pause. */
31
- export declare class RetryableTurnError extends Error {
32
- readonly code = "retryable_turn";
33
- readonly metadata?: RetryableTurnMetadata;
34
- readonly reason: RetryableTurnReason;
35
- constructor(reason: AuthResumeRetryableTurnReason, message: string, metadata: AuthResumeRetryableTurnMetadata);
36
- constructor(reason: "agent_continue", message: string, metadata?: RetryableTurnMetadata);
37
- }
38
- export declare function isRetryableTurnError(error: unknown, reason?: RetryableTurnReason): error is RetryableTurnError;
39
- /** Return whether a retryable turn is waiting for provider authorization. */
40
- export declare function isAuthResumeRetryableTurnError(error: unknown): error is AuthResumeRetryableTurnError;
41
- /** Error indicating the turn paused voluntarily at a safe continuation boundary. */
3
+ /**
4
+ * Queue-worker yield routing: respond.ts returns a suspended AgentRunOutcome
5
+ * and the Slack executor raises this at the worker boundary so the lease owner
6
+ * requeues the conversation.
7
+ */
42
8
  export declare class CooperativeTurnYieldError extends Error {
43
9
  readonly code = "cooperative_turn_yield";
44
10
  constructor(message?: string);
@@ -1,13 +1,5 @@
1
1
  export type ReplyDeliveryMode = "thread" | "channel_only";
2
- export type ReplyFileDelivery = "none" | "inline" | "followup";
3
2
  export interface ReplyDeliveryPlan {
4
3
  mode: ReplyDeliveryMode;
5
4
  postThreadText: boolean;
6
- attachFiles: ReplyFileDelivery;
7
5
  }
8
- /** Determine how a reply should be delivered (thread vs channel, file handling). */
9
- export declare function buildReplyDeliveryPlan(args: {
10
- explicitChannelPostIntent: boolean;
11
- channelPostPerformed: boolean;
12
- hasFiles: boolean;
13
- }): ReplyDeliveryPlan;
@@ -1,15 +1,15 @@
1
1
  import type { LogContext } from "@/chat/logging";
2
- import type { AssistantReply } from "@/chat/services/turn-result";
2
+ import type { AgentRunResult } from "@/chat/services/turn-result";
3
3
  type LogException = (error: unknown, eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string) => string | undefined;
4
4
  /** Require captured turn failures to carry a real Sentry event reference. */
5
5
  export declare function requireTurnFailureEventId(eventId: string | undefined, eventName: string): string;
6
6
  /** Keep failed-turn Sentry captures and completion spans on the same keys. */
7
- export declare function getAgentTurnDiagnosticsAttributes(reply: AssistantReply): Record<string, unknown>;
7
+ export declare function getAgentTurnDiagnosticsAttributes(reply: AgentRunResult): Record<string, unknown>;
8
8
  /** Enforce one captured, event-ID-bearing failure response before delivery. */
9
9
  export declare function finalizeFailedTurnReply(args: {
10
- reply: AssistantReply;
10
+ reply: AgentRunResult;
11
11
  logException: LogException;
12
12
  context: LogContext;
13
13
  attributes?: Record<string, unknown>;
14
- }): AssistantReply;
14
+ }): AgentRunResult;
15
15
  export {};
@@ -1,9 +1,8 @@
1
- import type { FileUpload } from "chat";
2
1
  import type { LogContext } from "@/chat/logging";
3
2
  import type { PiMessage } from "@/chat/pi/messages";
4
3
  import type { TurnThinkingSelection } from "@/chat/services/turn-thinking-level";
5
4
  import type { AgentTurnUsage } from "@/chat/usage";
6
- import { type ReplyDeliveryPlan } from "@/chat/services/reply-delivery-plan";
5
+ import type { ReplyDeliveryPlan } from "@/chat/services/reply-delivery-plan";
7
6
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
8
7
  export interface AgentTurnDiagnostics {
9
8
  assistantMessageCount: number;
@@ -20,9 +19,8 @@ export interface AgentTurnDiagnostics {
20
19
  usage?: AgentTurnUsage;
21
20
  usedPrimaryText: boolean;
22
21
  }
23
- export interface AssistantReply {
22
+ export interface AgentRunResult {
24
23
  text: string;
25
- files?: FileUpload[];
26
24
  artifactStatePatch?: Partial<ThreadArtifactsState>;
27
25
  deliveryPlan?: ReplyDeliveryPlan;
28
26
  deliveryMode?: "thread" | "channel_only";
@@ -34,7 +32,6 @@ export interface AssistantReply {
34
32
  export interface TurnResultInput {
35
33
  newMessages: unknown[];
36
34
  userInput: string;
37
- replyFiles: FileUpload[];
38
35
  artifactStatePatch: Partial<ThreadArtifactsState>;
39
36
  toolCalls: string[];
40
37
  sandboxId?: string;
@@ -54,5 +51,5 @@ export interface TurnResultInput {
54
51
  };
55
52
  assistantUserName?: string;
56
53
  }
57
- /** Process raw agent messages into a structured AssistantReply. */
58
- export declare function buildTurnResult(input: TurnResultInput): AssistantReply;
54
+ /** Process raw agent messages into a structured AgentRunResult. */
55
+ export declare function buildTurnResult(input: TurnResultInput): AgentRunResult;
@@ -1,3 +1,5 @@
1
+ import type { SlackChannelId } from "@/chat/slack/ids";
2
+ import type { SlackMessageTs } from "@/chat/slack/timestamp";
1
3
  export interface SlackChannelMessage {
2
4
  ts?: string;
3
5
  user?: string;
@@ -27,21 +29,23 @@ export interface SlackThreadReply {
27
29
  files?: SlackFileRef[];
28
30
  attachments?: unknown[];
29
31
  }
32
+ /** List channel history using Slack-native, pre-validated timestamp bounds. */
30
33
  export declare function listChannelMessages(input: {
31
- channelId: string;
34
+ channelId: SlackChannelId;
32
35
  limit: number;
33
36
  cursor?: string;
34
- oldest?: string;
35
- latest?: string;
37
+ oldest?: SlackMessageTs;
38
+ latest?: SlackMessageTs;
36
39
  inclusive?: boolean;
37
40
  maxPages?: number;
38
41
  }): Promise<{
39
42
  messages: SlackChannelMessage[];
40
43
  nextCursor?: string;
41
44
  }>;
45
+ /** Read replies from a Slack thread identified by a validated native thread timestamp. */
42
46
  export declare function listThreadReplies(input: {
43
- channelId: string;
44
- threadTs: string;
47
+ channelId: SlackChannelId;
48
+ threadTs: SlackMessageTs;
45
49
  limit?: number;
46
50
  maxPages?: number;
47
51
  targetMessageTs?: string[];
@@ -1,4 +1,5 @@
1
1
  import { WebClient } from "@slack/web-api";
2
+ import { type SlackChannelId } from "@/chat/slack/ids";
2
3
  export type SlackActionErrorCode = "missing_token" | "missing_scope" | "rate_limited" | "feature_unavailable" | "canvas_creation_failed" | "canvas_editing_failed" | "invalid_arguments" | "not_found" | "not_in_channel" | "already_reacted" | "no_reaction" | "read_only_channel" | "internal_error";
3
4
  export declare class SlackActionError extends Error {
4
5
  code: SlackActionErrorCode;
@@ -47,7 +48,8 @@ export declare function getHeaderString(headers: unknown, name: string): string
47
48
  * credentials rather than the env fallback token.
48
49
  */
49
50
  export declare function runWithSlackInstallationToken<T>(token: string, fn: () => T): T;
50
- export declare function normalizeSlackConversationId(channelId: string | undefined): string | undefined;
51
+ /** Normalize Junior Slack references to native Slack conversation IDs. */
52
+ export declare function normalizeSlackConversationId(channelId: string | undefined): SlackChannelId | undefined;
51
53
  /**
52
54
  * Run a Slack Web API call with bounded retries so transient platform
53
55
  * failures do not surface as turn failures, while non-idempotent posts are
@@ -1,9 +1,21 @@
1
- /** Extract channelId and threadTs from a `slack:<channel>:<ts>` thread identifier. */
1
+ import { type SlackChannelId, type SlackTeamId } from "@/chat/slack/ids";
2
+ import { type SlackMessageTs } from "@/chat/slack/timestamp";
3
+ export interface SlackRawMessageContext {
4
+ authorTeamId?: SlackTeamId;
5
+ channelId?: SlackChannelId;
6
+ messageTs?: SlackMessageTs;
7
+ nestedMessageTs?: SlackMessageTs;
8
+ teamId?: SlackTeamId;
9
+ threadTs?: SlackMessageTs;
10
+ }
11
+ /** Project only the Slack raw fields consumed by runtime thread context. */
12
+ export declare function readSlackRawMessageContext(message: unknown): SlackRawMessageContext | undefined;
13
+ /** Extract a channel ID and validated Slack timestamp from `slack:<channel>:<ts>`. */
2
14
  export declare function parseSlackThreadId(threadId: string | undefined): {
3
- channelId: string;
4
- threadTs: string;
15
+ channelId: SlackChannelId;
16
+ threadTs: SlackMessageTs;
5
17
  } | undefined;
6
18
  /** Resolve the Slack channel ID from a `slack:<channel>:<ts>` thread identifier. */
7
- export declare function resolveSlackChannelIdFromThreadId(threadId: string | undefined): string | undefined;
19
+ export declare function resolveSlackChannelIdFromThreadId(threadId: string | undefined): SlackChannelId | undefined;
8
20
  /** Best-effort channel ID extraction from a raw Slack message payload. */
9
- export declare function resolveSlackChannelIdFromMessage(message: unknown): string | undefined;
21
+ export declare function resolveSlackChannelIdFromMessage(message: unknown): SlackChannelId | undefined;
@@ -0,0 +1,25 @@
1
+ import { type SlackChannelId, type SlackUserId } from "@/chat/slack/ids";
2
+ import { z } from "zod";
3
+ type RequiredSlackChannelIdParamResult = {
4
+ ok: true;
5
+ value: SlackChannelId;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ };
10
+ type RequiredSlackUserIdParamResult = {
11
+ ok: true;
12
+ value: SlackUserId;
13
+ } | {
14
+ ok: false;
15
+ error: string;
16
+ };
17
+ /** Define a model-facing Slack channel ID parameter. */
18
+ export declare function slackChannelIdParam(description: string): z.ZodString;
19
+ /** Define a model-facing Slack user ID parameter. */
20
+ export declare function slackUserIdParam(description: string): z.ZodString;
21
+ /** Parse a required tool input channel ID into a branded Slack channel ID. */
22
+ export declare function parseRequiredSlackChannelIdParam(field: string, value: unknown): RequiredSlackChannelIdParamResult;
23
+ /** Parse a required tool input user ID into a branded Slack user ID. */
24
+ export declare function parseRequiredSlackUserIdParam(field: string, value: unknown): RequiredSlackUserIdParamResult;
25
+ export {};
@@ -1,4 +1,18 @@
1
- /** Return true when a value is a Slack workspace/team id. */
2
- export declare function isSlackTeamId(value: string): boolean;
3
- /** Return true when a value is a Slack conversation id. */
4
- export declare function isSlackConversationId(value: string): boolean;
1
+ import { z } from "zod";
2
+ declare const slackChannelIdSchema: z.core.$ZodBranded<z.ZodString, "SlackChannelId", "out">;
3
+ declare const slackTeamIdSchema: z.core.$ZodBranded<z.ZodString, "SlackTeamId", "out">;
4
+ declare const slackUserIdSchema: z.core.$ZodBranded<z.ZodString, "SlackUserId", "out">;
5
+ export type SlackChannelId = z.output<typeof slackChannelIdSchema>;
6
+ export type SlackTeamId = z.output<typeof slackTeamIdSchema>;
7
+ export type SlackUserId = z.output<typeof slackUserIdSchema>;
8
+ /** Parse an exact Slack channel/conversation ID from untrusted input. */
9
+ export declare function parseSlackChannelId(value: unknown): SlackChannelId | undefined;
10
+ /** Parse a Slack channel ID from native IDs or Junior Slack reference strings. */
11
+ export declare function parseSlackChannelReferenceId(value: unknown): SlackChannelId | undefined;
12
+ /** Parse a Slack workspace/team ID from untrusted metadata. */
13
+ export declare function parseSlackTeamId(value: unknown): SlackTeamId | undefined;
14
+ /** Parse a Slack user ID from untrusted metadata. */
15
+ export declare function parseSlackUserId(value: unknown): SlackUserId | undefined;
16
+ /** Return true when a value is exactly a Slack workspace/team id. */
17
+ export declare function isSlackTeamId(value: string): value is SlackTeamId;
18
+ export {};
@@ -28,6 +28,22 @@ export declare function postSlackEphemeralMessage(input: {
28
28
  }): Promise<{
29
29
  messageTs?: string;
30
30
  }>;
31
+ /** Minimal Slack file metadata exposed outside the Slack client boundary. */
32
+ export interface SlackUploadedFile {
33
+ id?: string;
34
+ }
35
+ /** Upload files into a Slack conversation or thread via the shared outbound file boundary. */
36
+ export declare function uploadFilesToConversation(input: {
37
+ channelId: string;
38
+ initialComment?: string;
39
+ threadTs?: string;
40
+ files: Array<{
41
+ data: Buffer;
42
+ filename: string;
43
+ }>;
44
+ }): Promise<{
45
+ files?: SlackUploadedFile[];
46
+ }>;
31
47
  /** Upload files into a Slack thread via the shared outbound file boundary. */
32
48
  export declare function uploadFilesToThread(input: {
33
49
  channelId: string;
@@ -1,4 +1,4 @@
1
- import type { FileUpload, PostableMessage } from "chat";
1
+ import type { PostableMessage } from "chat";
2
2
  /** Return the first continuation-safe chunk plus any remaining text. */
3
3
  export declare function takeSlackContinuationPrefix(text: string, options?: {
4
4
  forceSplit?: boolean;
@@ -46,8 +46,8 @@ export declare function getSlackContinuationBudget(): {
46
46
  maxChars: number;
47
47
  maxLines: number;
48
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;
49
+ /** Normalize text for Slack and wrap it as a PostableMessage. */
50
+ export declare function buildSlackOutputMessage(text: string): PostableMessage;
51
51
  export declare const slackOutputPolicy: {
52
52
  maxInlineChars: number;
53
53
  maxInlineLines: number;
@@ -1,18 +1,16 @@
1
- import type { FileUpload } from "chat";
2
- import type { AssistantReply } from "@/chat/respond";
1
+ import type { AgentRunResult } from "@/chat/services/turn-result";
3
2
  import { type SlackReplyFooter } from "@/chat/slack/footer";
4
- export type PlannedSlackReplyStage = "thread_reply" | "thread_reply_continuation" | "thread_reply_files_followup";
3
+ export type PlannedSlackReplyStage = "thread_reply" | "thread_reply_continuation";
5
4
  export interface PlannedSlackReplyPost {
6
- files?: FileUpload[];
7
5
  stage: PlannedSlackReplyStage;
8
6
  text: string;
9
7
  }
10
8
  /**
11
9
  * Plan the Slack thread posts needed to realize a completed assistant reply,
12
- * including chunking, interruption markers, and file delivery.
10
+ * including chunking and interruption markers.
13
11
  */
14
12
  export declare function planSlackReplyPosts(args: {
15
- reply: AssistantReply;
13
+ reply: AgentRunResult;
16
14
  }): PlannedSlackReplyPost[];
17
15
  /**
18
16
  * Deliver planned Slack reply posts over raw Slack Web API calls for resume and
@@ -22,7 +20,6 @@ export declare function postSlackApiReplyPosts(args: {
22
20
  beforePost?: () => Promise<void>;
23
21
  footer?: SlackReplyFooter;
24
22
  channelId: string;
25
- fileUploadFailureMode?: "best_effort" | "strict";
26
23
  onPostError?: (context: {
27
24
  error: unknown;
28
25
  messageTs?: string;
@@ -0,0 +1,25 @@
1
+ import { type SlackMessageTs } from "@/chat/slack/timestamp";
2
+ import { z } from "zod";
3
+ type SlackTimestampParamResult = {
4
+ ok: true;
5
+ value: SlackMessageTs | undefined;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ };
10
+ type RequiredSlackTimestampParamResult = {
11
+ ok: true;
12
+ value: SlackMessageTs;
13
+ } | {
14
+ ok: false;
15
+ error: string;
16
+ };
17
+ /** Define a model-facing Slack timestamp, normalizing numeric model args to strings. */
18
+ export declare function slackTimestampParam(description: string): z.ZodPreprocess<z.ZodString>;
19
+ /** Define an optional model-facing Slack timestamp string parameter. */
20
+ export declare function optionalSlackTimestampParam(description: string): z.ZodOptional<z.ZodPreprocess<z.ZodString>>;
21
+ /** Parse tool input into a branded Slack timestamp before provider calls. */
22
+ export declare function parseSlackTimestampParam(field: string, value: string | number | undefined): SlackTimestampParamResult;
23
+ /** Parse a required tool input timestamp into a branded Slack timestamp. */
24
+ export declare function parseRequiredSlackTimestampParam(field: string, value: string | number): RequiredSlackTimestampParamResult;
25
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { CanvasArtifactSummary } from "@/chat/state/artifacts";
2
+ import type { ToolState } from "@/chat/tools/types";
3
+ /** Merge a created canvas into artifact state without growing context forever. */
4
+ export declare function mergeRecentCanvases(existing: CanvasArtifactSummary[] | undefined, created: {
5
+ id: string;
6
+ title: string;
7
+ url?: string;
8
+ }): CanvasArtifactSummary[];
9
+ /** Resolve model-provided canvas references before Slack API calls. */
10
+ export declare function resolveCanvasTarget(canvas: string): {
11
+ ok: true;
12
+ canvasId: string;
13
+ } | {
14
+ ok: false;
15
+ error: string;
16
+ };
17
+ /** Preserve known canvas permalinks when tools only receive an ID. */
18
+ export declare function storedCanvasUrl(state: ToolState, canvasId: string): string | undefined;
@@ -0,0 +1,4 @@
1
+ import type { SlackToolContext } from "@/chat/slack/tools/context";
2
+ import type { ToolState } from "@/chat/tools/types";
3
+ /** Create a tool that provisions a new Slack canvas in the active channel. */
4
+ export declare function createSlackCanvasCreateTool(context: SlackToolContext, state: ToolState): import("../../../tools/definition").AnyToolDefinition;
@@ -0,0 +1,3 @@
1
+ import type { ToolState } from "@/chat/tools/types";
2
+ /** Create a tool that edits a Slack canvas like a markdown file. */
3
+ export declare function createSlackCanvasEditTool(state: ToolState): import("../../../tools/definition").AnyToolDefinition;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Create a tool that reads a Slack canvas the bot has access to. Accepts
3
+ * either a canvas/file ID (`F...`) or a Slack canvas/docs URL and returns the
4
+ * canvas body downloaded via the bot's file access.
5
+ */
6
+ export declare function createSlackCanvasReadTool(): import("../../../tools/definition").AnyToolDefinition;
@@ -0,0 +1,3 @@
1
+ import type { ToolState } from "@/chat/tools/types";
2
+ /** Create a tool that deliberately replaces a Slack canvas body. */
3
+ export declare function createSlackCanvasWriteTool(state: ToolState): import("../../../tools/definition").AnyToolDefinition;
@@ -1,4 +1,5 @@
1
1
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
2
+ import type { SlackChannelId, SlackTeamId } from "@/chat/slack/ids";
2
3
  /** Minimal persisted-visibility port for cross-conversation read gates. */
3
4
  export interface DestinationVisibilityReader {
4
5
  getDestinationVisibility(args: {
@@ -22,8 +23,8 @@ export type SlackChannelReadAccess = {
22
23
  * ids), so missing or private destinations fail closed.
23
24
  */
24
25
  export declare function checkSlackChannelReadAccess(args: {
25
- currentChannelIds: Array<string | undefined>;
26
+ currentChannelIds: Array<SlackChannelId | undefined>;
26
27
  store?: DestinationVisibilityReader;
27
- targetChannelId: string;
28
- teamId: string;
28
+ targetChannelId: SlackChannelId;
29
+ teamId: SlackTeamId;
29
30
  }): Promise<SlackChannelReadAccess>;