The Open Framework for Building Agents
feat(eve): slack - authorize HITL responses (#2157)
Andrew Barba8b2a914dae1d
diff --git a/.changeset/brave-slack-input-gate.md b/.changeset/brave-slack-input-gate.mdnew file mode 100644index 000000000..126503a04--- /dev/null+++ b/.changeset/brave-slack-input-gate.md@@ -0,0 +1,5 @@+---+"eve": minor+---++Authorize Slack HITL answers with `onInputResponse` before they resume a parked session. Slack channels with authored inbound hooks now reject built-in HITL responses unless they define a matching input-response policy.diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdxindex 9a668bfc4..59175d784 100644--- a/docs/channels/slack.mdx+++ b/docs/channels/slack.mdx@@ -140,7 +140,7 @@ Message hooks return `{ auth }` to dispatch, `null` to drop, or `{ auth, contextOnly the first available handler runs. A message hook returning `null` drops the message; it does not continue down the table.-`onInteraction(action, ctx)` separately handles `block_actions` callbacks not consumed by HITL. eve attaches the triggering Slack user id to the same model message as its text, preserving speaker attribution without profile lookups.+`onInteraction(action, ctx)` separately handles user-owned `block_actions` callbacks. eve-owned HITL buttons and modal submissions go through `onInputResponse(ctx, submission)` instead. eve attaches the triggering Slack user id to the same model message as its text, preserving speaker attribution without profile lookups.#### Restrict who can invoke the agent@@ -150,7 +150,7 @@ A valid Slack signature proves that Slack sent the event. It does not decide whiimport { connectSlackCredentials } from "@vercel/connect/eve";import { defaultSlackAuth, slackChannel, type SlackMessage } from "eve/channels/slack";-const allowedChannels = new Set(["C01234567"]);+const allowedConversations = new Set(["C01234567", "D01234567"]);const allowedUsers = new Set(["U01234567"]);function isAllowedUser(message: SlackMessage) {@@ -161,23 +161,33 @@ function isAllowedUser(message: SlackMessage) {export default slackChannel({credentials: connectSlackCredentials("slack/my-agent"),onAppMention(ctx, message) {- if (!isAllowedUser(message) || !allowedChannels.has(message.channelId)) {+ if (!isAllowedUser(message) || !allowedConversations.has(message.channelId)) {return null;}return { auth: defaultSlackAuth(message, ctx) };},onDirectMessage(ctx, message) {- if (!isAllowedUser(message)) return null;+ if (!isAllowedUser(message) || !allowedConversations.has(message.channelId)) {+ return null;+ }return { auth: defaultSlackAuth(message, ctx) };},+ onInputResponse(ctx, submission) {+ if (!allowedUsers.has(submission.user.id) || !allowedConversations.has(ctx.slack.channelId)) {+ return null;+ }+ return { auth: ctx.defaultAuth };+ },});```-Override every enabled inbound handler; leaving `onDirectMessage` out would retain eve's default DM behavior. Slack Connect can deliver events from external users, so authorize the explicit user and current channel IDs your policy expects. If access depends on organization membership, resolve it from Slack's shared-channel and user data instead of inferring it from the request signature.+Override every enabled inbound handler; leaving `onDirectMessage` out would retain eve's default DM behavior. Apply the same policy in `onInputResponse` so someone who cannot start a turn cannot resume one through an eve-owned HITL control. Slack Connect can deliver events from external users, so authorize the explicit user and current conversation IDs your policy expects. If access depends on organization membership, resolve it from Slack's shared-channel and user data instead of inferring it from the request signature.Keep authorization checks inside sensitive tools too. The inbound allowlist controls who can start a turn; tool-level checks control what that authenticated Slack principal may read or change.-The allowlist above gates message-started turns. Built-in HITL buttons are handled before `onInteraction`, and the person who clicks supplies the Slack auth for the resumed session. Anyone who can interact with the Slack message can answer it. Put sensitive prompts in channels limited to the intended approvers, and re-check `ctx.session.auth.current` inside a sensitive tool before performing its side effect.+`onInputResponse` runs after eve decodes a built-in HITL answer but before the parked session resumes. Return `{ auth }` to accept the answer. Returning `null` or throwing rejects it, leaves the request pending, and keeps the Slack controls active. `ctx.defaultAuth` identifies the Slack user who submitted the signed interaction; it does not authorize that user by itself.++Without authored inbound hooks, Slack accepts HITL answers with the submitting user's auth. If you author `onAppMention`, `onDirectMessage`, `onMessage`, or `onEvent` but omit `onInputResponse`, eve rejects built-in HITL answers instead of bypassing the authored ingress policy. Put sensitive prompts in conversations limited to the intended approvers, and re-check `ctx.session.auth.current` inside a sensitive tool before performing its side effect.#### Continue conversations without repeated mentions@@ -337,7 +347,7 @@ const session = await ctx.resolveSession({ target });### Slack API calls outside a handler-Inside webhook-side handlers (`onAppMention`, `onEvent`, `onInteraction`, `events`),+Inside webhook-side handlers (`onAppMention`, `onEvent`, `onInteraction`, `onInputResponse`, `events`),`ctx.slack.request(operation, body)` is the raw-API escape hatch. Outsidethose contexts there is no handle — a schedule resolving reactions on oldmessages, for example, has no inbound Slack request. For that, call the@@ -391,7 +401,7 @@ export default slackChannel({### Human-in-the-loop (HITL)-HITL renders as Slack buttons and selects. When the user responds, the parked session (paused awaiting input) resumes.+HITL renders as Slack buttons and selects. Fixed-choice actions and freeform modal submissions pass through `onInputResponse` before the parked session resumes. The initial **Type your answer** action only opens eve's modal; the hook runs when the user submits an answer.Authorization prompts split public status from private credentials. A sign-in challenge (OAuth URL, device code) is a credential. Anyone who completes it binds their identity to the session's connection. The default `authorization.required` handler posts a public, link-free status in the thread, delivers the actual challenge ephemerally to the triggering user, device code included, and then updates that public status when `authorization.completed` fires. The handler receives a private-delivery context with `postEphemeral`, `postDirectMessage` (needs the `im:write` scope), and `state`. There is, intentionally, no public `post` and no raw API access.diff --git a/packages/eve/src/public/channels/slack/index.ts b/packages/eve/src/public/channels/slack/index.tsindex 027def271..1d6d06d55 100644--- a/packages/eve/src/public/channels/slack/index.ts+++ b/packages/eve/src/public/channels/slack/index.ts@@ -29,6 +29,9 @@ export {type SlackInboundResult,type SlackInboundResultOrPromise,type SlackInitialMessage,+ type SlackInputResponseContext,+ type SlackInputResponseResult,+ type SlackInputResponseSubmission,type SlackInstrumentationMetadata,type SlackInteractionAction,type SlackInteractionContext,diff --git a/packages/eve/src/public/channels/slack/input-response.ts b/packages/eve/src/public/channels/slack/input-response.tsnew file mode 100644index 000000000..72924adca--- /dev/null+++ b/packages/eve/src/public/channels/slack/input-response.ts@@ -0,0 +1,44 @@+import { createLogger } from "#internal/logging.js";+import { buildSlackBinding } from "#public/channels/slack/api.js";+import { buildSlackAuthContext } from "#public/channels/slack/auth.js";+import type {+ SlackChannelConfig,+ SlackInputResponseContext,+ SlackInputResponseResult,+ SlackInputResponseSubmission,+} from "#public/channels/slack/slackChannel.js";++const log = createLogger("slack.interactions");++export async function authorizeInputResponse(input: {+ readonly channelId: string;+ readonly deps: {+ readonly config: SlackChannelConfig;+ readonly onInputResponse: NonNullable<SlackChannelConfig["onInputResponse"]>;+ };+ readonly submission: SlackInputResponseSubmission;+ readonly teamId: string | null | undefined;+ readonly threadTs: string;+}): Promise<SlackInputResponseResult> {+ const defaultAuth = buildSlackAuthContext({+ channelId: input.channelId,+ teamId: input.teamId,+ threadTs: input.threadTs,+ userId: input.submission.user.id,+ userName: input.submission.user.username ?? input.submission.user.name,+ });+ const { thread, slack } = buildSlackBinding({+ botToken: input.deps.config.credentials?.botToken,+ channelId: input.channelId,+ threadTs: input.threadTs,+ teamId: input.teamId ?? undefined,+ });+ const ctx: SlackInputResponseContext = { defaultAuth, slack, thread };++ try {+ return await input.deps.onInputResponse(ctx, input.submission);+ } catch (error) {+ log.error("HITL input response authorization failed", { error });+ return null;+ }+}diff --git a/packages/eve/src/public/channels/slack/interactions.ts b/packages/eve/src/public/channels/slack/interactions.tsindex 54d68fd9c..81ef21f37 100644--- a/packages/eve/src/public/channels/slack/interactions.ts+++ b/packages/eve/src/public/channels/slack/interactions.ts@@ -9,12 +9,13 @@* 2. Open the freeform-answer modal inline when the click was a "Type* your answer" button (Slack's `trigger_id` is only valid for ~3s,* so this can't run under `waitUntil`).- * 3. Resolve `view_submission` payloads (freeform modal submissions)- * back into parked HITL requests via `send`.+ * 3. Authorize decoded fixed-choice and freeform submissions through+ * `onInputResponse`, then resolve accepted answers against parked HITL+ * requests.*- * Anything we don't consume flows through to the user-supplied- * `onInteraction` callback. Always returns `Response("ok")` — followup- * work runs under `waitUntil` so the webhook ACK is immediate.+ * User-owned block actions flow through to the supplied `onInteraction`+ * callback. Always returns `Response("ok")` — followup work runs under+ * `waitUntil` so the webhook ACK is immediate.*/import {@@ -46,9 +47,11 @@ import {SLACK_CARD_SUBTEXT_MAX_LENGTH,truncateCardSubtext,} from "#public/channels/slack/limits.js";+import { authorizeInputResponse } from "#public/channels/slack/input-response.js";import type {SlackChannelConfig,SlackChannelState,+ SlackInputResponseSubmission,SlackInteractionAction,SlackInteractionContext,SlackInteractionUser,@@ -319,23 +322,18 @@ function hasCardContent(block: Record<string, unknown>): boolean {return block.body !== undefined || block.title !== undefined || block.hero_image !== undefined;}-/**- * Channel-supplied dependencies for {@link handleInteractionPost}.- *- * Carries the bits the handler needs that come from channel- * construction: credentials for outbound API calls and the user's- * `onInteraction` callback for non-HITL clicks.- */+/** Channel-supplied dependencies for {@link handleInteractionPost}. */export interface InteractionHandlerDeps {readonly config: SlackChannelConfig;+ readonly onInputResponse: NonNullable<SlackChannelConfig["onInputResponse"]>;}/*** Entry point for Slack's form-encoded interactivity endpoint. Routes* `view_submission` payloads to the freeform-answer flow, intercepts* "Type your answer" button clicks to open a modal, resolves- * framework HITL clicks against the parked session, and forwards- * anything else to `config.onInteraction`.+ * framework HITL clicks through `onInputResponse` to the parked session,+ * and forwards anything else to `config.onInteraction`.*/export async function handleInteractionPost(rawBody: string,@@ -374,34 +372,25 @@ export async function handleInteractionPost(}const continuationToken = slackContinuationToken(interaction.channelId, interaction.threadTs);- const inputResponses = interaction.actions- .map(deriveHitlResponse)- .filter((r): r is { requestId: string; optionId: string } => r !== null);-- if (inputResponses.length > 0) {- const user = interaction.actions[0]?.user;- if (!user) return ack;-- ctx.waitUntil(- ctx- .from(continuationToken)- .respond(inputResponses, {- auth: buildSlackAuthContext({- channelId: interaction.channelId,- teamId: interaction.teamId,- threadTs: interaction.threadTs,- userId: user.id,- userName: user.username ?? user.name,- }),- })- .catch((error: unknown) => {- log.error("HITL interaction delivery failed", { error });- }),- );+ const hitlActions = interaction.actions.flatMap((action) => {+ const response = deriveHitlResponse(action);+ return response === null ? [] : [{ action, response }];+ });+ if (hitlActions.length > 0) {+ const user = hitlActions[0]!.action.user;ctx.waitUntil(- updateAnsweredHitlCard(interaction, deps).catch((error: unknown) => {- log.error("HITL answered-card update failed", { error });+ dispatchBlockInputResponses({+ ctx,+ deps,+ interaction,+ submission: {+ type: "block_actions",+ actions: hitlActions.map(({ action }) => action),+ inputResponses: hitlActions.map(({ response }) => response),+ messageTs: hitlActions[0]!.action.messageTs,+ user,+ },}),);}@@ -452,6 +441,39 @@ export async function handleInteractionPost(return ack;}+async function dispatchBlockInputResponses(input: {+ readonly ctx: {+ from: ChannelFrom<SlackChannelState>;+ };+ readonly deps: InteractionHandlerDeps;+ readonly interaction: ParsedBlockActionsPayload;+ readonly submission: Extract<SlackInputResponseSubmission, { type: "block_actions" }>;+}): Promise<void> {+ const result = await authorizeInputResponse({+ channelId: input.interaction.channelId,+ deps: input.deps,+ submission: input.submission,+ teamId: input.interaction.teamId,+ threadTs: input.interaction.threadTs,+ });+ if (result === null) return;++ try {+ await input.ctx+ .from(slackContinuationToken(input.interaction.channelId, input.interaction.threadTs))+ .respond(input.submission.inputResponses, { auth: result.auth });+ } catch (error) {+ log.error("HITL interaction delivery failed", { error });+ return;+ }++ try {+ await updateAnsweredHitlCard(input.interaction, input.deps);+ } catch (error) {+ log.error("HITL answered-card update failed", { error });+ }+}+async function openFreeformModal(input: {readonly payload: Record<string, unknown>;readonly interaction: ParsedBlockActionsPayload;@@ -511,7 +533,7 @@ async function handleViewSubmission(from: ChannelFrom<SlackChannelState>;waitUntil: (task: Promise<unknown>) => void;},- _deps: InteractionHandlerDeps,+ deps: InteractionHandlerDeps,): Promise<Response> {// Slack view submissions require an empty 200 body to close the modal.const ack = new Response(null, { status: 200 });@@ -547,36 +569,63 @@ async function handleViewSubmission(const user = payload.user;const triggeringUserId = payload.userId;const teamId = user?.teamId ?? payload.teamId ?? null;+ const submission: SlackInputResponseSubmission = {+ type: "view_submission",+ inputResponses: [{ requestId: metadata.requestId, text }],+ messageTs: metadata.messageTs,+ user: {+ id: triggeringUserId,+ username: user?.username,+ name: user?.name,+ },+ };- ctx.waitUntil(- ctx- .from(metadata.continuationToken)- .respond([{ requestId: metadata.requestId, text }], {- auth: buildSlackAuthContext({- channelId: metadata.channelId,- teamId,- threadTs: metadata.threadTs,- userId: triggeringUserId,- userName: user?.username ?? user?.name,- }),- })- .then(() =>- updateAnsweredFreeformCard({- channelId: metadata.channelId,- messageTs: metadata.messageTs,- answerLabel: text,- userId: triggeringUserId ?? undefined,- deps: _deps,- }),- )- .catch((error: unknown) => {- log.error("freeform answer delivery or answered-card update failed", { error });- }),- );+ ctx.waitUntil(dispatchViewInputResponse({ ctx, deps, metadata, submission, teamId, text }));return ack;}+async function dispatchViewInputResponse(input: {+ readonly ctx: { from: ChannelFrom<SlackChannelState> };+ readonly deps: InteractionHandlerDeps;+ readonly metadata: HitlFreeformModalMetadata;+ readonly submission: Extract<SlackInputResponseSubmission, { type: "view_submission" }>;+ readonly teamId: string | null;+ readonly text: string;+}): Promise<void> {+ const result = await authorizeInputResponse({+ channelId: input.metadata.channelId,+ deps: input.deps,+ submission: input.submission,+ teamId: input.teamId,+ threadTs: input.metadata.threadTs,+ });+ if (result === null) return;++ try {+ await input.ctx+ .from(input.metadata.continuationToken)+ .respond(input.submission.inputResponses, {+ auth: result.auth,+ });+ } catch (error) {+ log.error("freeform answer delivery failed", { error });+ return;+ }++ try {+ await updateAnsweredFreeformCard({+ channelId: input.metadata.channelId,+ messageTs: input.metadata.messageTs,+ answerLabel: input.text,+ userId: input.submission.user.id,+ deps: input.deps,+ });+ } catch (error) {+ log.error("freeform answered-card update failed", { error });+ }+}+async function updateAnsweredHitlCard(interaction: ParsedBlockActionsPayload,deps: InteractionHandlerDeps,diff --git a/packages/eve/src/public/channels/slack/slackChannel.test.ts b/packages/eve/src/public/channels/slack/slackChannel.test.tsindex eac38252a..c035518b4 100644--- a/packages/eve/src/public/channels/slack/slackChannel.test.ts+++ b/packages/eve/src/public/channels/slack/slackChannel.test.ts@@ -33,6 +33,8 @@ import {constrainAuthorizationRequired,slackChannel,type SlackAuthorizationEventContext,+ type SlackInputResponseContext,+ type SlackInputResponseSubmission,type SlackChannelState,type SlackEventContext,} from "#public/channels/slack/slackChannel.js";@@ -2326,6 +2328,27 @@ describe("slackChannel() HITL interaction pipeline", () => {vi.stubGlobal("fetch", fetchMock);});+ function buildHitlButtonRequest(userId = "U_APPROVER"): Request {+ return buildSignedInteractionRequest({+ type: "block_actions",+ team: { id: "T01" },+ user: { id: userId, username: "ada", name: "ada", team_id: "T01" },+ channel: { id: "C01" },+ message: {+ ts: "1700000000.000010",+ thread_ts: "1700000000.000001",+ blocks: [{ type: "section", text: { type: "mrkdwn", text: "Approve?" } }],+ },+ actions: [+ {+ action_id: `${HITL_ACTION_PREFIX}approval_abc123:button:0`,+ text: { type: "plain_text", text: "Approve" },+ value: "approve",+ },+ ],+ });+ }+afterAll(() => {if (ORIGINAL_SIGNING_SECRET === undefined) {delete process.env.SLACK_SIGNING_SECRET;@@ -2460,6 +2483,91 @@ describe("slackChannel() HITL interaction pipeline", () => {});});+ it("authorizes HITL button answers before resuming with the returned auth", async () => {+ const customAuth = {+ attributes: { role: "deployer" },+ authenticator: "secure-slack",+ principalId: "employee:ada",+ principalType: "user" as const,+ };+ const onInputResponse = vi.fn(+ (ctx: SlackInputResponseContext, submission: SlackInputResponseSubmission) => {+ expect(ctx.defaultAuth.principalId).toBe("slack:T01:U_APPROVER");+ expect(submission).toMatchObject({+ type: "block_actions",+ inputResponses: [{ optionId: "approve", requestId: "approval_abc123" }],+ messageTs: "1700000000.000010",+ user: { id: "U_APPROVER", username: "ada" },+ });+ return { auth: customAuth };+ },+ );+ const channel = slackChannel({+ credentials: { botToken: "xoxb-test" },+ onInputResponse,+ });++ const { send } = await firePost(channel, buildHitlButtonRequest());++ expect(onInputResponse).toHaveBeenCalledTimes(1);+ expect(send).toHaveBeenCalledTimes(1);+ expect(send.mock.calls[0]?.[1]).toMatchObject({ auth: customAuth });+ });++ it("keeps HITL pending when the input-response hook rejects or throws", async () => {+ const handlers = [+ vi.fn(() => null),+ vi.fn(() => {+ throw new Error("policy unavailable");+ }),+ ];++ for (const onInputResponse of handlers) {+ fetchMock.mockClear();+ const channel = slackChannel({+ credentials: { botToken: "xoxb-test" },+ onInputResponse,+ });++ const { send } = await firePost(channel, buildHitlButtonRequest());++ expect(onInputResponse).toHaveBeenCalledTimes(1);+ expect(send).not.toHaveBeenCalled();+ expect(fetchMock).not.toHaveBeenCalledWith(+ "https://slack.com/api/chat.update",+ expect.anything(),+ );+ }+ });++ it("rejects HITL by default when an inbound hook is authored", async () => {+ const channel = slackChannel({+ credentials: { botToken: "xoxb-test" },+ onAppMention: () => ({ auth: null }),+ });++ const { send } = await firePost(channel, buildHitlButtonRequest());++ expect(send).not.toHaveBeenCalled();+ expect(fetchMock).not.toHaveBeenCalledWith(+ "https://slack.com/api/chat.update",+ expect.anything(),+ );+ });++ it("does not mark a HITL card answered when response delivery fails", async () => {+ const send = vi.fn().mockRejectedValue(new Error("target session not found"));+ const channel = slackChannel({ credentials: { botToken: "xoxb-test" } });++ await firePost(channel, buildHitlButtonRequest(), { send });++ expect(send).toHaveBeenCalledTimes(1);+ expect(fetchMock).not.toHaveBeenCalledWith(+ "https://slack.com/api/chat.update",+ expect.anything(),+ );+ });+it("updates one answered HITL card without removing sibling batched buttons", async () => {const channel = slackChannel({ credentials: { botToken: "xoxb-test" } });@@ -2803,6 +2911,56 @@ describe("slackChannel() HITL interaction pipeline", () => {inputResponses: [{ requestId: "call_abc123", text: "approved with context" }],});});++ it("authorizes freeform modal answers before resuming", async () => {+ const onInputResponse = vi.fn(() => null);+ const channel = slackChannel({+ credentials: { botToken: "xoxb-test" },+ onInputResponse,+ });++ const { send } = await firePost(+ channel,+ buildSignedInteractionRequest({+ type: "view_submission",+ team: { id: "T01" },+ user: { id: "U_SUBMITTER", username: "grace", team_id: "T01" },+ view: {+ callback_id: HITL_FREEFORM_MODAL_CALLBACK_ID,+ private_metadata: JSON.stringify({+ channelId: "C01",+ continuationToken: "C01:1700000000.000001",+ messageTs: "1700000000.000010",+ requestId: "call_abc123",+ threadTs: "1700000000.000001",+ }),+ state: {+ values: {+ [HITL_FREEFORM_MODAL_BLOCK_ID]: {+ [HITL_FREEFORM_MODAL_ACTION_ID]: { value: "approved with context" },+ },+ },+ },+ },+ }),+ );++ expect(onInputResponse).toHaveBeenCalledWith(+ expect.objectContaining({+ defaultAuth: expect.objectContaining({ principalId: "slack:T01:U_SUBMITTER" }),+ }),+ expect.objectContaining({+ type: "view_submission",+ inputResponses: [{ requestId: "call_abc123", text: "approved with context" }],+ user: expect.objectContaining({ id: "U_SUBMITTER" }),+ }),+ );+ expect(send).not.toHaveBeenCalled();+ expect(fetchMock).not.toHaveBeenCalledWith(+ "https://slack.com/api/chat.update",+ expect.anything(),+ );+ });});describe("slackChannel() webhookVerifier credentials path", () => {diff --git a/packages/eve/src/public/channels/slack/slackChannel.ts b/packages/eve/src/public/channels/slack/slackChannel.tsindex b3ff16668..d57b53146 100644--- a/packages/eve/src/public/channels/slack/slackChannel.ts+++ b/packages/eve/src/public/channels/slack/slackChannel.ts@@ -15,6 +15,7 @@ import type { ChannelContinuationOps } from "#public/definitions/channel.js";import { createLogger, logError } from "#internal/logging.js";import type { UnstampedMessageStreamEvent } from "#protocol/message.js";+import type { InputResponse } from "#runtime/input/types.js";import {buildSlackBinding,buildSlackWorkspaceHandle,@@ -376,6 +377,12 @@ export interface SlackInboundMessageContext extends SlackContext, SlackSessionOp/** Interaction-scoped context handed to `slackChannel({ onInteraction })`. */export interface SlackInteractionContext extends SlackContext, SlackSessionOperations {}+/** Context handed to `slackChannel({ onInputResponse })` before eve resumes HITL. */+export interface SlackInputResponseContext extends SlackContext {+ /** Auth derived from the Slack user who submitted the signed interaction. */+ readonly defaultAuth: SessionAuthContext;+}+export interface SlackInteractionAction {readonly actionId: string;readonly value?: string;@@ -416,6 +423,25 @@ export interface SlackInteractionUser {readonly name?: string;}+/** Decoded eve-owned HITL response submitted through Slack interactivity. */+export type SlackInputResponseSubmission =+ | {+ readonly type: "block_actions";+ readonly inputResponses: readonly InputResponse[];+ readonly actions: readonly SlackInteractionAction[];+ readonly messageTs?: string;+ readonly user: SlackInteractionUser;+ }+ | {+ readonly type: "view_submission";+ readonly inputResponses: readonly InputResponse[];+ readonly messageTs: string;+ readonly user: SlackInteractionUser;+ };++/** Result of a Slack HITL response admission hook. Return `null` to reject. */+export type SlackInputResponseResult = { readonly auth: SessionAuthContext | null } | null;+/*** Result of an `onAppMention` or `onDirectMessage` callback. Return an* object (auth may be `null`) to dispatch a turn, or `null` to drop the@@ -604,6 +630,21 @@ export interface SlackChannelConfig {ctx: SlackInteractionContext,): void | Promise<void>;+ /**+ * Authorizes an eve-owned HITL answer before the pending input resolves.+ * Return `{ auth }` to accept the response, or `null` to reject it and keep+ * the request pending. Thrown errors are logged and treated as rejection.+ *+ * When this hook is omitted, Slack keeps its built-in submitting-user auth+ * only if no inbound message or Events API hook is authored. Authoring+ * `onAppMention`, `onDirectMessage`, `onMessage`, or `onEvent` without a+ * matching `onInputResponse` rejects HITL responses by default.+ */+ onInputResponse?(+ ctx: SlackInputResponseContext,+ submission: SlackInputResponseSubmission,+ ): SlackInputResponseResult | Promise<SlackInputResponseResult>;+readonly events?: SlackChannelEvents;}@@ -651,6 +692,9 @@ export interface SlackChannel extends Channel<export function slackChannel(config: SlackChannelConfig = {}): SlackChannel {const uploadPolicy = mergeUploadPolicy(config.uploadPolicy);const slackFetchFile = createSlackFetchFile({ botToken: config.credentials?.botToken });+ const onInputResponse =+ config.onInputResponse ??+ (hasAuthoredInboundHook(config) ? rejectInputResponse : defaultOnInputResponse);const authorizationRequiredOverride = config.events?.["authorization.required"];const candidateHandler =config.events?.["approval.candidate"] ?? defaultEvents["approval.candidate"]!;@@ -753,7 +797,11 @@ export function slackChannel(config: SlackChannelConfig = {}): SlackChannel {const contentType = req.headers.get("content-type") ?? "";if (contentType.includes("application/x-www-form-urlencoded")) {- return handleInteractionPost(body, { from, resolveSession, waitUntil }, { config });+ return handleInteractionPost(+ body,+ { from, resolveSession, waitUntil },+ { config, onInputResponse },+ );}return handleEventPost({body,@@ -776,6 +824,23 @@ export function slackChannel(config: SlackChannelConfig = {}): SlackChannel {});}+function hasAuthoredInboundHook(config: SlackChannelConfig): boolean {+ return (+ config.onAppMention !== undefined ||+ config.onDirectMessage !== undefined ||+ config.onMessage !== undefined ||+ config.onEvent !== undefined+ );+}++function defaultOnInputResponse(ctx: SlackInputResponseContext): SlackInputResponseResult {+ return { auth: ctx.defaultAuth };+}++function rejectInputResponse(): null {+ return null;+}+/*** Shared proactive Slack receive path used by both the channel's public* `receive` hook and the pre-bound `send` function exposed to `onEvent`.