Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): expert find_capability reports needs_expert_grant, not connected, for ungranted credentials (#15111)

Abhimanyu Yadav1b5c2fc675ff
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/ranking.py b/autogpt_platform/backend/backend/copilot/capabilities/ranking.py
index 05f2903167..187a189beb 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/ranking.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/ranking.py
@@ -17,13 +17,20 @@ WEIGHT_PRIMITIVE = 0.75
class ConnectionState(BaseModel):
- """The user's credentials, keyed the three ways capabilities need them."""
+ """The credentials this session can run on, keyed the three ways
+ capabilities need them.
+
+ For an expert session the top-level sets hold only what the expert was
+ granted; ``ungranted`` holds what the account owns but the expert may not
+ use, so search can say "ask for a grant" instead of "sign in".
+ """
model_config = ConfigDict(frozen=True)
providers: frozenset[str] = Field(default_factory=frozenset)
server_urls: frozenset[str] = Field(default_factory=frozenset)
hosts: frozenset[str] = Field(default_factory=frozenset)
+ ungranted: "ConnectionState | None" = None
def resolve_connected(
@@ -47,6 +54,18 @@ def resolve_connected(
return None
+def resolve_needs_expert_grant(
+ entry: CapabilityEntry, state: ConnectionState | None
+) -> bool:
+ """Whether *entry* would run on an account credential this expert session
+ has not been granted — owned, but not usable until the user grants it."""
+ if state is None or state.ungranted is None:
+ return False
+ if resolve_connected(entry, state) is not False:
+ return False
+ return resolve_connected(entry, state.ungranted) is True
+
+
def tier(entry: CapabilityEntry, connected: bool | None) -> int:
"""0 = connected service ... 3 = bare primitive; used for tie-breaks."""
if entry.kind == "skill":
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/resolve.py b/autogpt_platform/backend/backend/copilot/capabilities/resolve.py
index be95a11304..efb9c9ffea 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/resolve.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/resolve.py
@@ -55,18 +55,40 @@ def resolve_entry(index: CapabilityIndex, capability_id: str) -> CapabilityEntry
)
-async def load_connection_state(user_id: str) -> ConnectionState:
- """Providers, MCP server URLs and hosts the user holds credentials for.
+async def load_connection_state(
+ user_id: str, expert_id: str | None = None
+) -> ConnectionState:
+ """Providers, MCP server URLs and hosts this session holds credentials for.
One store read per call; the credentials manager already caches, so a
``find_capability`` turn costs no extra round-trips.
+
+ With an *expert_id* the state is narrowed to the expert's grants — the
+ same filter a run applies — so ``connected`` means "this session can run
+ it", and the account credentials the expert lacks are kept aside as
+ ``ungranted``. A grant lookup that fails leaves the expert with nothing
+ usable, matching the run-time gate rather than overstating what it can do.
"""
try:
credentials = await IntegrationCredentialsManager().store.get_all_creds(user_id)
except Exception:
logger.warning("Could not load credentials for ranking", exc_info=True)
return ConnectionState()
- return connection_state_from(credentials)
+ if expert_id is None:
+ return connection_state_from(credentials)
+
+ from backend.copilot.tools.utils import scope_credentials_to_expert
+
+ try:
+ granted = await scope_credentials_to_expert(user_id, expert_id, credentials)
+ except Exception:
+ logger.warning("Could not load expert credential grants", exc_info=True)
+ return ConnectionState(ungranted=connection_state_from(credentials))
+ granted_ids = {c.id for c in granted}
+ ungranted = [c for c in credentials if c.id not in granted_ids]
+ return connection_state_from(granted).model_copy(
+ update={"ungranted": connection_state_from(ungranted)}
+ )
def connection_state_from(credentials: list[Credentials]) -> ConnectionState:
diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.py
index 619b623d2c..d42dc82b76 100644
--- a/autogpt_platform/backend/backend/copilot/prompting.py
+++ b/autogpt_platform/backend/backend/copilot/prompting.py
@@ -159,6 +159,11 @@ your **first action** in that turn is `find_capability(query="<service>
3. `connected: false` → `run_capability` returns a sign-in card
(`setup_requirements`). Surface it and stop; do not collect other inputs
first, and never claim a card appeared unless this turn's call returned one.
+ `connected: "needs_expert_grant"` (expert sessions) → the account already
+ has the integration but this expert has not been granted it. Do NOT ask
+ the user to sign in: `run_capability` returns the same card with a Grant
+ button for the existing credential. Surface it, ask the user to grant
+ access, and stop.
4. `review_required` → tell the user; after they approve, call
`resume_capability(review_id)`.
diff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.py
index 4f3c115941..e2f2571647 100644
--- a/autogpt_platform/backend/backend/copilot/prompting_test.py
+++ b/autogpt_platform/backend/backend/copilot/prompting_test.py
@@ -98,6 +98,17 @@ class TestCredentialsSurfacingGuardrails:
assert "NEVER claim a card has appeared" in result
assert "call the tool first" in result
+ def test_prompt_distinguishes_an_expert_grant_from_a_sign_in(self):
+ """An expert session's ``find_capability`` reports an account-owned
+ credential the expert lacks as ``needs_expert_grant``; the model must
+ ask for a grant, not send the user back through sign-in."""
+ result = prompting.get_sdk_supplement(use_e2b=False)
+ step = result[result.index('`connected: "needs_expert_grant"`') :]
+ step = " ".join(step[: step.index("4. `review_required`")].split())
+ assert "Do NOT ask the user to sign in" in step
+ assert "Grant button" in step
+ assert "ask the user to grant access" in step
+
def test_prompt_contains_rejection_rule(self):
"""This section collects rules from several PRs at once, so a merge
that takes one side drops a rule silently."""
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_scope.py b/autogpt_platform/backend/backend/copilot/tools/expert_scope.py
index 32f52e0d2d..d97f0e3444 100644
--- a/autogpt_platform/backend/backend/copilot/tools/expert_scope.py
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_scope.py
@@ -332,7 +332,9 @@ async def ungranted_credential_hint(
)
return (
"\n\nThe account already has matching credentials that this expert has "
- f"not been granted:\n{lines}\nAsk the user to grant one on the expert's "
- "Integrations page, or from personal AutoPilot with "
- "tool:grant_expert_credential."
+ f"not been granted:\n{lines}\nDo not ask the user to sign in again. Ask "
+ "them to grant one with the Grant button on the setup card, on the "
+ "expert's Integrations page, or from personal AutoPilot with "
+ "tool:grant_expert_credential; tool:request_credential_grant parks the "
+ "ask on Home under 'Needs you'."
)
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_scope_test.py b/autogpt_platform/backend/backend/copilot/tools/expert_scope_test.py
index 38a6d2ec36..3893a5db39 100644
--- a/autogpt_platform/backend/backend/copilot/tools/expert_scope_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_scope_test.py
@@ -180,6 +180,9 @@ async def test_hint_lists_owned_but_ungranted_credentials(experts):
assert "spare-cred" in hint and "GH spare" in hint
assert "granted-cred" not in hint and "other-cred" not in hint
assert "grant_expert_credential" in hint
+ assert "request_credential_grant" in hint
+ assert "Grant button" in hint
+ assert "Do not ask the user to sign in" in hint
assert none == "" and personal == ""
diff --git a/autogpt_platform/backend/backend/copilot/tools/find_capability.py b/autogpt_platform/backend/backend/copilot/tools/find_capability.py
index fdd2291969..33c8cbeb75 100644
--- a/autogpt_platform/backend/backend/copilot/tools/find_capability.py
+++ b/autogpt_platform/backend/backend/copilot/tools/find_capability.py
@@ -7,6 +7,10 @@ from typing import Any
from backend.copilot.capabilities.index import SearchHit
from backend.copilot.capabilities.models import CapabilityKindName
+from backend.copilot.capabilities.ranking import (
+ ConnectionState,
+ resolve_needs_expert_grant,
+)
from backend.copilot.capabilities.resolve import load_connection_state
from backend.copilot.context import get_current_permissions
from backend.copilot.model import ChatSession
@@ -32,6 +36,9 @@ _KIND_ARG: dict[str, CapabilityKindName] = {
}
+NEEDS_EXPERT_GRANT = "needs_expert_grant"
+
+
class FindCapabilityTool(BaseTool):
"""Ranked capability search with connection state."""
@@ -113,7 +120,8 @@ class FindCapabilityTool(BaseTool):
)
connections, index = await asyncio.gather(
- load_connection_state(user_id), session_registry(user_id, session)
+ load_connection_state(user_id, session.expert_id),
+ session_registry(user_id, session),
)
result = index.search(
query,
@@ -132,31 +140,46 @@ class FindCapabilityTool(BaseTool):
],
session_id=session_id,
)
+ capabilities = [_listing(hit, connections) for hit in result.hits]
+ fallback = [_listing(hit, connections) for hit in result.fallback]
return CapabilityListResponse(
message=_message(
result.service,
len(result.hits),
len(result.fallback),
skills=any(hit.entry.kind == "skill" for hit in result.hits),
+ needs_grant=any(
+ c.get("connected") == NEEDS_EXPERT_GRANT
+ for c in capabilities + fallback
+ ),
),
query=query,
- capabilities=[_listing(hit) for hit in result.hits],
+ capabilities=capabilities,
count=len(result.hits),
- fallback=[_listing(hit) for hit in result.fallback],
+ fallback=fallback,
service=result.service,
session_id=session_id,
)
-def _listing(hit: SearchHit) -> dict[str, Any]:
+def _listing(hit: SearchHit, connections: ConnectionState) -> dict[str, Any]:
listing = hit.entry.listing()
if hit.entry.connection.required:
- listing["connected"] = hit.connected
+ listing["connected"] = (
+ NEEDS_EXPERT_GRANT
+ if resolve_needs_expert_grant(hit.entry, connections)
+ else hit.connected
+ )
return listing
def _message(
- service: str | None, hits: int, fallback: int, *, skills: bool = False
+ service: str | None,
+ hits: int,
+ fallback: int,
+ *,
+ skills: bool = False,
+ needs_grant: bool = False,
) -> str:
parts = [f"Found {hits} capabilit{'y' if hits == 1 else 'ies'}"]
if service:
@@ -169,6 +192,14 @@ def _message(
"run_capability(id, input). connected=false means the user must sign in "
"first: run_capability returns the sign-in card."
)
+ if needs_grant:
+ text += (
+ f" connected='{NEEDS_EXPERT_GRANT}' means the account already has "
+ "this integration but this expert has not been granted it: do not "
+ "ask the user to sign in. run_capability returns the setup card "
+ "with a Grant button for the existing credential; surface it and "
+ "ask the user to grant access."
+ )
if skills:
text += (
" A kind=skill result is a saved procedure: "
diff --git a/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py b/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py
new file mode 100644
index 0000000000..7c12494145
--- /dev/null
+++ b/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py
@@ -0,0 +1,169 @@
+"""``find_capability`` in an expert session reports what the session can run,
+not what the account owns, so search and ``run_capability`` agree."""
+
+from unittest.mock import AsyncMock, MagicMock, patch
+
+import pytest
+from pydantic import SecretStr
+
+from backend.copilot.capabilities.ranking import ConnectionState
+from backend.copilot.capabilities.resolve import load_connection_state
+from backend.copilot.context import set_execution_context
+from backend.data.model import APIKeyCredentials
+
+from ._test_data import make_session
+from .find_capability import NEEDS_EXPERT_GRANT, FindCapabilityTool
+from .models import CapabilityListResponse
+
+USER = "user-find-cap"
+GITHUB_STATE = ConnectionState(providers=frozenset({"github"}))
+GITHUB_UNGRANTED = ConnectionState(ungranted=GITHUB_STATE)
+
+
[email protected](autouse=True)
+def _clean_context():
+ set_execution_context(USER, make_session(USER))
+ yield
+ set_execution_context(None, None)
+
+
[email protected](autouse=True)
+def _no_skills():
+ """Skills are read through Redis and the workspace; keep them out."""
+ with (
+ patch(
+ "backend.copilot.tools.session_registry.is_skills_feature_enabled",
+ AsyncMock(return_value=True),
+ ),
+ patch(
+ "backend.copilot.tools.session_registry.list_all_skills",
+ AsyncMock(return_value=[]),
+ ),
+ ):
+ yield
+
+
+def _api_key(id: str, provider: str) -> APIKeyCredentials:
+ return APIKeyCredentials(id=id, provider=provider, title=id, api_key=SecretStr("k"))
+
+
+def _github_hits(result: CapabilityListResponse) -> list[dict]:
+ return [c for c in result.capabilities if c["name"].startswith("Github")]
+
+
+async def test_expert_search_reports_needs_grant_for_an_owned_but_ungranted_credential():
+ """The account holds a GitHub credential the expert was never granted:
+ the listing must say so, never ``connected: true`` — that is what sent
+ the model to a sign-in card the run then refused."""
+ session = make_session(USER, expert_id="expert-1")
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=GITHUB_UNGRANTED),
+ ) as loader:
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github pull request"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ loader.assert_awaited_once_with(USER, "expert-1")
+ hits = _github_hits(result)
+ assert hits
+ assert all(c["connected"] == NEEDS_EXPERT_GRANT for c in hits)
+ assert not any(c.get("connected") is True for c in result.capabilities)
+ assert NEEDS_EXPERT_GRANT in result.message
+ assert "grant" in result.message.lower()
+ assert "do not ask the user to sign in" in result.message.lower()
+
+
+async def test_expert_search_reports_connected_for_a_granted_credential():
+ session = make_session(USER, expert_id="expert-1")
+ granted = ConnectionState(
+ providers=frozenset({"github"}), ungranted=ConnectionState()
+ )
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=granted),
+ ):
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github pull request"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ assert all(c["connected"] is True for c in _github_hits(result))
+ assert NEEDS_EXPERT_GRANT not in result.message
+
+
+async def test_expert_search_reports_false_for_a_provider_the_account_lacks():
+ session = make_session(USER, expert_id="expert-1")
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=ConnectionState(ungranted=ConnectionState())),
+ ):
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github pull request"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ assert all(c["connected"] is False for c in _github_hits(result))
+ assert NEEDS_EXPERT_GRANT not in result.message
+
+
+async def test_personal_session_is_not_narrowed():
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=GITHUB_STATE),
+ ) as loader:
+ result = await FindCapabilityTool()._execute(
+ USER, make_session(USER), query="github pull request"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ loader.assert_awaited_once_with(USER, None)
+ assert all(c["connected"] is True for c in _github_hits(result))
+
+
+async def test_loader_narrows_an_expert_to_its_grants():
+ """Account: a GitHub credential the expert has, a second GitHub one it
+ lacks, and a Slack one it lacks. Only the granted provider is connected;
+ the rest is reported as ungranted."""
+ store = MagicMock()
+ store.get_all_creds = AsyncMock(
+ return_value=[
+ _api_key("gh-granted", "github"),
+ _api_key("gh-spare", "github"),
+ _api_key("slack-1", "slack"),
+ ]
+ )
+ experts = MagicMock()
+ experts.expert_allowed_credential_ids = AsyncMock(return_value=["gh-granted"])
+ with (
+ patch(
+ "backend.copilot.capabilities.resolve.IntegrationCredentialsManager",
+ return_value=MagicMock(store=store),
+ ),
+ patch("backend.data.db_accessors.experts_db", return_value=experts),
+ ):
+ state = await load_connection_state(USER, "expert-1")
+ personal = await load_connection_state(USER)
+ experts.expert_allowed_credential_ids.assert_awaited_once_with(USER, "expert-1")
+ assert state.providers == frozenset({"github"})
+ assert state.ungranted is not None
+ assert state.ungranted.providers == frozenset({"github", "slack"})
+ assert personal.providers == frozenset({"github", "slack"})
+ assert personal.ungranted is None
+
+
+async def test_loader_fails_closed_when_the_grant_lookup_fails():
+ """A broken allow-list read must not report the account's credentials as
+ usable: the run-time gate would refuse them anyway."""
+ store = MagicMock()
+ store.get_all_creds = AsyncMock(return_value=[_api_key("gh-1", "github")])
+ experts = MagicMock()
+ experts.expert_allowed_credential_ids = AsyncMock(side_effect=RuntimeError("db"))
+ with (
+ patch(
+ "backend.copilot.capabilities.resolve.IntegrationCredentialsManager",
+ return_value=MagicMock(store=store),
+ ),
+ patch("backend.data.db_accessors.experts_db", return_value=experts),
+ ):
+ state = await load_connection_state(USER, "expert-1")
+ assert state.providers == frozenset()
+ assert state.ungranted is not None
+ assert state.ungranted.providers == frozenset({"github"})
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/FindCapabilities.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/FindCapabilities.tsx
index 9a90ccdbb1..02f4ba4bf4 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/FindCapabilities.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/FindCapabilities.tsx
@@ -12,6 +12,7 @@ import { AccordionIcon, ToolIcon } from "../FindBlocks/helpers";
import {
type CapabilityListing,
type FindCapabilityToolPart,
+ connectionBadge,
getAnimationText,
kindLabel,
parseOutput,
@@ -23,21 +24,18 @@ interface Props {
}
function CapabilityCard({ item }: { item: CapabilityListing }) {
- const connected = item.connected;
+ const badge = connectionBadge(item);
return (
<ContentCard className="w-52 shrink-0">
<div className="flex items-start justify-between gap-2">
<ContentCardTitle className="truncate">{item.name}</ContentCardTitle>
- {connected !== undefined && connected !== null && (
+ {badge && (
<span
className={
- "shrink-0 rounded-full px-2 py-0.5 text-[11px] " +
- (connected
- ? "bg-green-100 text-green-800"
- : "bg-zinc-100 text-zinc-500")
+ "shrink-0 rounded-full px-2 py-0.5 text-[11px] " + badge.className
}
>
- {connected ? "connected" : "sign in"}
+ {badge.label}
</span>
)}
</div>
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/FindCapabilities.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/FindCapabilities.test.tsx
index 7638a75228..2aaf633fca 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/FindCapabilities.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/FindCapabilities.test.tsx
@@ -70,6 +70,26 @@ describe("FindCapabilitiesTool", () => {
expect(screen.queryAllByText(/^(connected|sign in)$/)).toHaveLength(2);
});
+ it("shows an expert's ungranted integration as needing a grant, not connected", () => {
+ const ungranted = {
+ ...OUTPUT,
+ count: 1,
+ capabilities: [
+ {
+ ...OUTPUT.capabilities[0],
+ connected: "needs_expert_grant" as const,
+ },
+ ],
+ fallback: [],
+ };
+ render(<FindCapabilitiesTool part={part({ output: ungranted })} />);
+ fireEvent.click(screen.getByText("Results"));
+
+ expect(screen.getByText("grant needed")).toBeDefined();
+ expect(screen.queryByText("connected")).toBeNull();
+ expect(screen.queryByText("sign in")).toBeNull();
+ });
+
it("labels a skill as one, not as an action", () => {
const withSkill = {
...OUTPUT,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/helpers.test.ts
index 35eee6119b..9bd5bd6e4c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/__tests__/helpers.test.ts
@@ -1,5 +1,10 @@
import { describe, expect, it } from "vitest";
-import { getAnimationText, kindLabel, parseOutput } from "../helpers";
+import {
+ connectionBadge,
+ getAnimationText,
+ kindLabel,
+ parseOutput,
+} from "../helpers";
const OUTPUT = {
type: "capability_list",
@@ -41,6 +46,21 @@ describe("find_capability helpers", () => {
expect(parseOutput("")).toBeNull();
});
+ it("badges connection state, with a grant state for expert sessions", () => {
+ const base = OUTPUT.capabilities[0];
+ expect(connectionBadge({ ...base, connected: true })?.label).toBe(
+ "connected",
+ );
+ expect(connectionBadge({ ...base, connected: false })?.label).toBe(
+ "sign in",
+ );
+ expect(
+ connectionBadge({ ...base, connected: "needs_expert_grant" })?.label,
+ ).toBe("grant needed");
+ expect(connectionBadge({ ...base, connected: null })).toBeNull();
+ expect(connectionBadge({ ...base, connected: undefined })).toBeNull();
+ });
+
it("labels kinds for the card footer", () => {
expect(kindLabel(OUTPUT.capabilities[0])).toBe("action");
expect(kindLabel(OUTPUT.capabilities[1])).toBe("integration");
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/helpers.ts
index b3d00d153a..e1a3036a48 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindCapabilities/helpers.ts
@@ -1,13 +1,20 @@
+export type ConnectionState = boolean | "needs_expert_grant" | null;
+
export interface CapabilityListing {
id: string;
name: string;
purpose: string;
kind: string;
class?: string;
- connected?: boolean | null;
+ connected?: ConnectionState;
eager?: boolean;
}
+export interface ConnectionBadge {
+ label: string;
+ className: string;
+}
+
export interface CapabilityListOutput {
type: "capability_list";
query: string;
@@ -83,6 +90,19 @@ export function getAnimationText(part: FindCapabilityToolPart): string {
}
}
+export function connectionBadge(
+ item: CapabilityListing,
+): ConnectionBadge | null {
+ if (item.connected === undefined || item.connected === null) return null;
+ if (item.connected === "needs_expert_grant") {
+ return { label: "grant needed", className: "bg-amber-100 text-amber-800" };
+ }
+ if (item.connected) {
+ return { label: "connected", className: "bg-green-100 text-green-800" };
+ }
+ return { label: "sign in", className: "bg-zinc-100 text-zinc-500" };
+}
+
export function kindLabel(item: CapabilityListing): string {
if (item.kind === "mcp_server") return "integration";
if (item.kind === "skill") return "skill";