mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-12 08:02:44 +00:00
fix: keep the base path in the chat SDK example, list slack_agents token scopes, bound the bot name lookup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
41b166b90b
commit
44029ccba2
@@ -123,12 +123,24 @@ async fn list_agent_channels(
|
||||
Some(_) => bot_name(&db, &w_id).await,
|
||||
None => None,
|
||||
};
|
||||
Ok(Json(AgentSlack { slack_team_name, signing_secret_set, bot_name, channels }))
|
||||
Ok(Json(AgentSlack {
|
||||
slack_team_name,
|
||||
signing_secret_set,
|
||||
bot_name,
|
||||
channels,
|
||||
}))
|
||||
}
|
||||
|
||||
async fn bot_name(db: &DB, w_id: &str) -> Option<String> {
|
||||
let token = bot_token(db, w_id).await.ok()?;
|
||||
let res = slack_call(&token, "auth.test", &[]).await.ok()?;
|
||||
// On every agent page load: a slow Slack must not hold the page for the client's 20s timeout.
|
||||
let res = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(3),
|
||||
slack_call(&token, "auth.test", &[]),
|
||||
)
|
||||
.await
|
||||
.ok()?
|
||||
.ok()?;
|
||||
res["user"].as_str().map(str::to_string)
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,12 @@ fn build_standard_scope_domains() -> Vec<ScopeDomain> {
|
||||
"AI agent eval datasets and standalone runs",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"slack_agents",
|
||||
"Slack Agents",
|
||||
"AI agents answering in Slack channels",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"agent_workers",
|
||||
"Agent Workers",
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
workspace,
|
||||
isAdmin,
|
||||
chat,
|
||||
slackLoading,
|
||||
slackTeamName,
|
||||
botName,
|
||||
signingSecretSet,
|
||||
@@ -45,6 +46,8 @@
|
||||
isAdmin: boolean
|
||||
/** Whether the agent keeps the conversation. Slack is offered only then: a thread is one. */
|
||||
chat: boolean
|
||||
/** Whether the workspace's Slack connection is still being read. */
|
||||
slackLoading: boolean
|
||||
/** Unset when Slack is not connected to the workspace. */
|
||||
slackTeamName: string | undefined
|
||||
/** Unset when Slack can't be reached with the workspace's bot token. */
|
||||
@@ -173,7 +176,9 @@
|
||||
{#snippet content()}
|
||||
<div class="min-h-0 grow overflow-y-auto">
|
||||
<TabContent value="slack" class="flex flex-col gap-6 p-4">
|
||||
{#if !slackTeamName}
|
||||
{#if slackLoading}
|
||||
<span class="text-xs text-hint">Loading…</span>
|
||||
{:else if !slackTeamName}
|
||||
<span class="text-xs text-secondary">
|
||||
Connect Slack to the workspace to ask this agent from Slack, by its name or as a
|
||||
channel's default.
|
||||
|
||||
@@ -110,7 +110,7 @@ const TOKEN = '${t.token}'
|
||||
|
||||
export function AgentChat() {
|
||||
const chat = useWindmillChat({
|
||||
baseUrl: '${new URL(t.api).origin}',
|
||||
baseUrl: '${t.api.replace(/\/api\/w\/[^/]+$/, '')}',
|
||||
workspace: '${t.api.split('/').pop()}',
|
||||
token: TOKEN,
|
||||
// What the agent's conversations are filed under. With a token, history stays in this
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
workspace={ws}
|
||||
isAdmin={!!($userStore?.is_admin || $userStore?.is_super_admin)}
|
||||
chat={chatAvailable}
|
||||
slackLoading={slack.loading && !slack.current}
|
||||
slackTeamName={slack.current?.slack_team_name}
|
||||
botName={slack.current?.bot_name}
|
||||
signingSecretSet={slack.current?.signing_secret_set ?? true}
|
||||
|
||||
Reference in New Issue
Block a user