Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): slack - preserve default HITL authorization (#2165)

Andrew Barba0bc9f92397c4
diff --git a/.changeset/brave-slack-input-gate.md b/.changeset/brave-slack-input-gate.md
index 126503a04..8c0c444e1 100644
--- a/.changeset/brave-slack-input-gate.md
+++ b/.changeset/brave-slack-input-gate.md
@@ -1,5 +1,5 @@
---
-"eve": minor
+"eve": patch
---
-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.
+Authorize Slack HITL answers with `onInputResponse` before they resume a parked session. Omitting the hook preserves the existing submitting-user authorization behavior regardless of other Slack handlers.
diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdx
index 59175d784..66e918c77 100644
--- a/docs/channels/slack.mdx
+++ b/docs/channels/slack.mdx
@@ -187,7 +187,7 @@ Keep authorization checks inside sensitive tools too. The inbound allowlist cont
`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.
+If you omit `onInputResponse`, Slack accepts HITL answers with the submitting user's auth, regardless of which message or event handlers you define. Define `onInputResponse` when those handlers enforce an invocation policy that must also apply to HITL answers. 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
diff --git a/packages/eve/src/public/channels/slack/slackChannel.test.ts b/packages/eve/src/public/channels/slack/slackChannel.test.ts
index c035518b4..e63d6ec94 100644
--- a/packages/eve/src/public/channels/slack/slackChannel.test.ts
+++ b/packages/eve/src/public/channels/slack/slackChannel.test.ts
@@ -2540,7 +2540,7 @@ describe("slackChannel() HITL interaction pipeline", () => {
}
});
- it("rejects HITL by default when an inbound hook is authored", async () => {
+ it("uses default HITL auth when onAppMention is authored", async () => {
const channel = slackChannel({
credentials: { botToken: "xoxb-test" },
onAppMention: () => ({ auth: null }),
@@ -2548,11 +2548,8 @@ describe("slackChannel() HITL interaction pipeline", () => {
const { send } = await firePost(channel, buildHitlButtonRequest());
- expect(send).not.toHaveBeenCalled();
- expect(fetchMock).not.toHaveBeenCalledWith(
- "https://slack.com/api/chat.update",
- expect.anything(),
- );
+ expect(send).toHaveBeenCalledTimes(1);
+ expect(send.mock.calls[0]?.[1].auth?.principalId).toBe("slack:T01:U_APPROVER");
});
it("does not mark a HITL card answered when response delivery fails", async () => {
diff --git a/packages/eve/src/public/channels/slack/slackChannel.ts b/packages/eve/src/public/channels/slack/slackChannel.ts
index d57b53146..46d588eb4 100644
--- a/packages/eve/src/public/channels/slack/slackChannel.ts
+++ b/packages/eve/src/public/channels/slack/slackChannel.ts
@@ -635,10 +635,9 @@ export interface SlackChannelConfig {
* 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.
+ * When this hook is omitted, Slack preserves its built-in behavior and
+ * accepts the response with the submitting user's auth, regardless of other
+ * authored handlers.
*/
onInputResponse?(
ctx: SlackInputResponseContext,
@@ -692,9 +691,7 @@ 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 onInputResponse = config.onInputResponse ?? defaultOnInputResponse;
const authorizationRequiredOverride = config.events?.["authorization.required"];
const candidateHandler =
config.events?.["approval.candidate"] ?? defaultEvents["approval.candidate"]!;
@@ -824,23 +821,10 @@ 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`.