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.

feat(platform): expert profiles show required services, cost, and AI disclosure (#14037)

Abhimanyu Yadav118ac214c1a8
diff --git a/autogpt_platform/backend/backend/api/features/experts/experts_db.py b/autogpt_platform/backend/backend/api/features/experts/experts_db.py
index 653b10205a..f48c44f696 100644
--- a/autogpt_platform/backend/backend/api/features/experts/experts_db.py
+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db.py
@@ -1,6 +1,7 @@
import asyncio
import logging
from collections import defaultdict
+from collections.abc import Sequence
from datetime import date, datetime, time, timedelta
from typing import Literal, cast
from zoneinfo import ZoneInfo
@@ -49,7 +50,10 @@ from backend.api.features.experts.models import (
RaiseResult,
decode_voice_preferences,
)
-from backend.api.features.experts.workflow_chain import build_workflow_chain
+from backend.api.features.experts.workflow_chain import (
+ build_workflow_chain,
+ integration_providers,
+)
from backend.api.features.library import db as library_db
from backend.api.features.library import model as library_model
from backend.api.features.orgs.db import get_user_default_team
@@ -91,19 +95,40 @@ def _raised_identity(name: str) -> str:
return f"I'm {name}, raised by you. I learn how you work and grow with you."
+# Postgres promises no row order without this, so the profile's workflow grid
+# could reshuffle between loads; createdAt keeps the roster's authored order.
+_WORKFLOW_ORDER = [{"createdAt": "asc"}, {"id": "asc"}]
+
_WORKFLOW_ROW_INCLUDE: prisma.types.ExpertWorkflowInclude = {
# AgentGraph carries the name/description of a user-created library agent;
# LibraryAgent.name is only populated from a marketplace snapshot.
"LibraryAgent": {"include": {"AgentGraph": {"include": {"Nodes": True}}}},
"StoreListingVersion": True,
}
-_WORKFLOW_INCLUDE = {"Workflows": {"include": _WORKFLOW_ROW_INCLUDE}}
+_WORKFLOW_INCLUDE = {
+ "Workflows": {"include": _WORKFLOW_ROW_INCLUDE, "order_by": _WORKFLOW_ORDER}
+}
_ROSTER_WORKFLOW_INCLUDE: prisma.types.ExpertInclude = {
"Workflows": {
"include": {
"LibraryAgent": {"include": {"AgentGraph": True}},
"StoreListingVersion": True,
- }
+ },
+ "order_by": _WORKFLOW_ORDER,
+ }
+}
+# A template workflow has no LibraryAgent — that row is created at hire time —
+# so its chain has to come from the listing's own graph. Without it the
+# marketplace profile cannot say what a workflow connects to.
+_TEMPLATE_WORKFLOW_INCLUDE: prisma.types.ExpertInclude = {
+ "Workflows": {
+ "include": {
+ "LibraryAgent": {"include": {"AgentGraph": True}},
+ "StoreListingVersion": {
+ "include": {"AgentGraph": {"include": {"Nodes": True}}}
+ },
+ },
+ "order_by": _WORKFLOW_ORDER,
}
}
_MAX_EXPERT_RUNS = 20
@@ -125,6 +150,7 @@ def _to_workflow_ref(row: prisma.models.ExpertWorkflow) -> ExpertWorkflowRef:
name, description = _library_agent_labels(library_agent)
else:
name, description = None, None
+ nodes = _chain_nodes(row)
return ExpertWorkflowRef(
id=row.id,
store_listing_version_id=row.storeListingVersionId,
@@ -134,14 +160,27 @@ def _to_workflow_ref(row: prisma.models.ExpertWorkflow) -> ExpertWorkflowRef:
description=description,
schedule_cron=row.scheduleCron,
schedule_id=row.scheduleId,
- chain=build_workflow_chain(
- library_agent.AgentGraph.Nodes or []
- if library_agent and library_agent.AgentGraph
- else []
- ),
+ chain=build_workflow_chain(nodes),
+ integration_providers=integration_providers(nodes),
)
+def _chain_nodes(
+ row: prisma.models.ExpertWorkflow,
+) -> Sequence[prisma.models.AgentNode]:
+ """The graph whose blocks the chain summarises: the hire's own library
+ agent, or the marketplace listing behind a template that has none yet."""
+ library_graph = row.LibraryAgent.AgentGraph if row.LibraryAgent else None
+ if library_graph and library_graph.Nodes:
+ return library_graph.Nodes
+ listing_graph = (
+ row.StoreListingVersion.AgentGraph if row.StoreListingVersion else None
+ )
+ if listing_graph and listing_graph.Nodes:
+ return listing_graph.Nodes
+ return []
+
+
def _library_agent_labels(
row: prisma.models.LibraryAgent,
) -> tuple[str | None, str | None]:
@@ -223,7 +262,7 @@ async def _latest_runs(
async def list_templates() -> list[Expert]:
rows = await prisma.models.Expert.prisma().find_many(
where={"isTemplate": True, "isArchived": False},
- include=_WORKFLOW_INCLUDE,
+ include=_TEMPLATE_WORKFLOW_INCLUDE,
)
return [_to_model(row) for row in rows]
diff --git a/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py b/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
index bd3ba90117..fbbeccbebf 100644
--- a/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db_test.py
@@ -105,12 +105,18 @@ async def _create_seed_user():
)
-async def _seed_store_listing(server: SpinTestServer, approved: bool = True) -> str:
+async def _seed_store_listing(
+ server: SpinTestServer,
+ approved: bool = True,
+ extra_block_ids: list[str] | None = None,
+) -> str:
"""Create a graph plus a store listing on top of it.
Returns the StoreListingVersion ID, ready for
``add_store_agent_to_library``. With ``approved=False`` the version is
- left in its submitted PENDING state. Mirrors the seeding pattern from
+ left in its submitted PENDING state. Pass ``extra_block_ids`` to put more
+ blocks in the graph — a credentialed one gives the listing an integration
+ to summarise. Mirrors the seeding pattern from
``backend/data/graph_test.py::test_access_store_listing_graph``.
"""
owner = await _create_seed_user()
@@ -124,6 +130,7 @@ async def _seed_store_listing(server: SpinTestServer, approved: bool = True) ->
block_id=AgentInputBlock().id,
input_default={"name": "input_1"},
),
+ *(Node(block_id=block_id) for block_id in extra_block_ids or []),
],
links=[],
)
@@ -3132,6 +3139,90 @@ async def test_list_experts_includes_last_run(server: SpinTestServer, test_user)
assert fetched.last_run_status == "COMPLETED"
[email protected](loop_scope="session")
+async def test_hired_workflows_order_by_created_at_then_id(
+ server: SpinTestServer, test_user
+):
+ oldest_listing = await _seed_store_listing(server)
+ earlier_listing = await _seed_store_listing(server)
+ later_listing = await _seed_store_listing(server)
+ template = await _seed_template(name="Maria", preload_listings=[])
+ hired = await experts_db.hire_expert(test_user.id, template.id, None)
+ now = datetime.now(timezone.utc)
+
+ later_workflow = await prisma.models.ExpertWorkflow.prisma().create(
+ data={
+ "expertId": hired.expert.id,
+ "storeListingVersionId": later_listing,
+ "createdAt": now,
+ }
+ )
+ earlier_workflow = await prisma.models.ExpertWorkflow.prisma().create(
+ data={
+ "expertId": hired.expert.id,
+ "storeListingVersionId": earlier_listing,
+ "createdAt": now,
+ }
+ )
+ oldest_workflow = await prisma.models.ExpertWorkflow.prisma().create(
+ data={
+ "expertId": hired.expert.id,
+ "storeListingVersionId": oldest_listing,
+ "createdAt": now - timedelta(days=1),
+ }
+ )
+
+ expected_workflows = sorted(
+ [later_workflow, earlier_workflow, oldest_workflow],
+ key=lambda workflow: (workflow.createdAt, workflow.id),
+ )
+ rehired = await experts_db.hire_expert(test_user.id, template.id, None)
+ assert [workflow.id for workflow in rehired.expert.workflows] == [
+ workflow.id for workflow in expected_workflows
+ ]
+ assert [
+ workflow.store_listing_version_id for workflow in rehired.expert.workflows
+ ] == [workflow.storeListingVersionId for workflow in expected_workflows]
+
+ listed = next(
+ expert
+ for expert in await experts_db.list_experts(test_user.id)
+ if expert.id == rehired.expert.id
+ )
+ assert [workflow.id for workflow in listed.workflows] == [
+ workflow.id for workflow in expected_workflows
+ ]
+ assert [workflow.store_listing_version_id for workflow in listed.workflows] == [
+ workflow.storeListingVersionId for workflow in expected_workflows
+ ]
+
+
+# Airtable: a provider the platform holds no credentials for, so a user has to
+# connect it — which is what the profile's access list is for.
+_AIRTABLE_BLOCK_ID = "f59b88a8-54ce-4676-a508-fd614b4e8dce"
+
+
[email protected](loop_scope="session")
+async def test_template_workflow_chain_comes_from_the_listing_graph(
+ server: SpinTestServer,
+):
+ """A template row has no LibraryAgent, so without the listing fallback the
+ marketplace profile has neither a chain nor an access list to build."""
+ slv_id = await _seed_store_listing(server, extra_block_ids=[_AIRTABLE_BLOCK_ID])
+ template = await _seed_template(name="Maria", preload_listings=[slv_id])
+
+ listed = next(t for t in await experts_db.list_templates() if t.id == template.id)
+
+ workflow = listed.workflows[0]
+ assert workflow.library_agent_id is None
+ # The integration is the property the access list depends on: a fallback
+ # that yielded only the input step would satisfy a non-empty chain.
+ assert ("integration", "airtable") in [
+ (item.kind, item.provider) for item in workflow.chain
+ ]
+ assert workflow.integration_providers == ["airtable"]
+
+
@pytest.mark.asyncio(loop_scope="session")
async def test_sync_preloads_updates_template_cadence(server: SpinTestServer):
"""Re-seeding must propagate roster cadence changes onto existing
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.py
index b28078836b..1f48f9a054 100644
--- a/autogpt_platform/backend/backend/api/features/experts/models.py
+++ b/autogpt_platform/backend/backend/api/features/experts/models.py
@@ -117,6 +117,9 @@ class ExpertWorkflowRef(BaseModel):
schedule_id: str | None = None
# Up to three of the graph's most-used blocks, integrations first.
chain: list[ExpertWorkflowChainItem] = Field(default_factory=list)
+ # Every integration the graph needs credentials for — NOT the chain's
+ # providers, which the three-item display cut can drop one of.
+ integration_providers: list[str] = Field(default_factory=list)
class ExpertIdentity(BaseModel):
diff --git a/autogpt_platform/backend/backend/api/features/experts/workflow_chain.py b/autogpt_platform/backend/backend/api/features/experts/workflow_chain.py
index ec52e381fb..ddf43665f5 100644
--- a/autogpt_platform/backend/backend/api/features/experts/workflow_chain.py
+++ b/autogpt_platform/backend/backend/api/features/experts/workflow_chain.py
@@ -53,6 +53,23 @@ def build_workflow_chain(
]
+def integration_providers(
+ nodes: Sequence[prisma.models.AgentNode],
+) -> list[str]:
+ """Every integration the graph needs credentials for, sorted, untruncated.
+
+ The chain is a three-item display summary, so a caller that reads providers
+ off it loses whichever one the node counts rank fourth — fine for an icon
+ row, wrong for telling someone what they have to connect.
+ """
+ providers = set()
+ for node in nodes:
+ key = _classify_node(node)
+ if key is not None and key[0] == "integration" and key[1]:
+ providers.add(key[1])
+ return sorted(providers)
+
+
def _rank(item: tuple[ChainKey, int]) -> tuple[int, str, str]:
(kind, provider), count = item
score = count + (_PROVIDER_PRIORITY if provider else 0)
diff --git a/autogpt_platform/backend/backend/api/features/experts/workflow_chain_test.py b/autogpt_platform/backend/backend/api/features/experts/workflow_chain_test.py
index e9944192e0..deff87dfa5 100644
--- a/autogpt_platform/backend/backend/api/features/experts/workflow_chain_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/workflow_chain_test.py
@@ -2,12 +2,21 @@ import json
import prisma
-from backend.api.features.experts.workflow_chain import build_workflow_chain
+from backend.api.features.experts.workflow_chain import (
+ CHAIN_LENGTH,
+ build_workflow_chain,
+ integration_providers,
+)
AGENT_INPUT_BLOCK = "c0a8e994-ebf1-4a9c-a4d8-89d09c86741b"
AGENT_OUTPUT_BLOCK = "363ae599-353e-4804-937e-b2ee3cef3da4"
GMAIL_READ_BLOCK = "25310c70-b89b-43ba-b25c-4dfa7e2a481c"
AI_TEXT_GENERATOR_BLOCK = "1f292d4a-41a4-4977-9684-7c8d560b9f91"
+# Four blocks whose providers a user must connect themselves — the platform
+# holds credentials for neither of these, unlike Gmail's google above.
+AIRTABLE_BLOCK = "f59b88a8-54ce-4676-a508-fd614b4e8dce"
+AGENT_MAIL_BLOCK = "a283ffc4-8087-4c3d-9135-8f26b86742ec"
+BANNERBEAR_BLOCK = "c7d3a5c2-05fc-450e-8dce-3b0e04626009"
def _node(block_id: str, constant_input: dict | None = None) -> prisma.models.AgentNode:
@@ -54,3 +63,32 @@ def test_chain_skips_unknown_blocks_and_unresolved_llm_models():
)
assert [(item.kind, item.provider) for item in chain] == [("ai", None)]
+
+
+def test_integration_providers_keeps_what_the_display_cut_drops():
+ """The chain is capped at three items, so a graph with four integrations
+ loses one — the access list on the expert profile must not."""
+ nodes = [
+ _node(GMAIL_READ_BLOCK),
+ _node(AIRTABLE_BLOCK),
+ _node(AGENT_MAIL_BLOCK),
+ _node(BANNERBEAR_BLOCK),
+ ]
+
+ chain = build_workflow_chain(nodes)
+ providers = integration_providers(nodes)
+
+ assert len(chain) == CHAIN_LENGTH
+ assert len({item.provider for item in chain}) < len(providers)
+ assert providers == ["agent_mail", "airtable", "bannerbear", "google"]
+
+
+def test_integration_providers_ignores_non_credentialed_steps():
+ nodes = [
+ _node(AGENT_INPUT_BLOCK),
+ _node(AGENT_OUTPUT_BLOCK),
+ _node(AI_TEXT_GENERATOR_BLOCK, {"model": "mystery"}),
+ _node(AIRTABLE_BLOCK),
+ ]
+
+ assert integration_providers(nodes) == ["airtable"]
diff --git a/autogpt_platform/backend/migrations/20260815061000_add_expert_workflow_order_index/migration.sql b/autogpt_platform/backend/migrations/20260815061000_add_expert_workflow_order_index/migration.sql
new file mode 100644
index 0000000000..2ed8e5d07f
--- /dev/null
+++ b/autogpt_platform/backend/migrations/20260815061000_add_expert_workflow_order_index/migration.sql
@@ -0,0 +1,2 @@
+CREATE INDEX IF NOT EXISTS "ExpertWorkflow_expertId_createdAt_id_idx" ON "ExpertWorkflow"("expertId", "createdAt", "id");
+DROP INDEX IF EXISTS "ExpertWorkflow_expertId_idx";
diff --git a/autogpt_platform/backend/schema.prisma b/autogpt_platform/backend/schema.prisma
index 6f2a354346..79b476bd91 100644
--- a/autogpt_platform/backend/schema.prisma
+++ b/autogpt_platform/backend/schema.prisma
@@ -1134,7 +1134,7 @@ model ExpertWorkflow {
// Duplicate install on an expert returns the existing row.
@@unique([expertId, storeListingVersionId])
- @@index([expertId])
+ @@index([expertId, createdAt, id])
}
// Which of the owner's integration credentials an expert may use.
diff --git a/autogpt_platform/backend/snapshots/expert_raise_attachments b/autogpt_platform/backend/snapshots/expert_raise_attachments
index f4355cb7d2..b673376893 100644
--- a/autogpt_platform/backend/snapshots/expert_raise_attachments
+++ b/autogpt_platform/backend/snapshots/expert_raise_attachments
@@ -33,6 +33,7 @@
"description": "Writes SEO-optimized blog posts",
"graph_id": "graph-1",
"id": "workflow-ref-1",
+ "integration_providers": [],
"library_agent_id": "library-agent-1",
"name": "SEO Blog Writer",
"schedule_cron": null,
diff --git a/autogpt_platform/backend/snapshots/expert_templates_list b/autogpt_platform/backend/snapshots/expert_templates_list
index 4bd046fff0..dc90c2e878 100644
--- a/autogpt_platform/backend/snapshots/expert_templates_list
+++ b/autogpt_platform/backend/snapshots/expert_templates_list
@@ -33,6 +33,7 @@
"description": "Writes SEO-optimized blog posts",
"graph_id": null,
"id": "workflow-ref-1",
+ "integration_providers": [],
"library_agent_id": null,
"name": "SEO Blog Writer",
"schedule_cron": null,
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.test.ts
new file mode 100644
index 0000000000..133094d3a1
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.test.ts
@@ -0,0 +1,127 @@
+import { ExpertWorkflowRef } from "@/app/api/__generated__/models/expertWorkflowRef";
+import { describe, expect, test } from "vitest";
+import {
+ getExpertAccent,
+ getExpertAccessProviders,
+ getExpertFirstName,
+} from "./helpers";
+
+describe("getExpertAccent", () => {
+ test("themes known roles and falls back to zinc", () => {
+ expect(getExpertAccent("Marketing").pill).toContain("violet");
+ expect(getExpertAccent("Sales").pill).toContain("amber");
+ expect(getExpertAccent("Ops").pill).toContain("sky");
+ expect(getExpertAccent("Astrologer").pill).toContain("zinc");
+ });
+});
+
+function makeWorkflow(
+ overrides: Partial<ExpertWorkflowRef>,
+): ExpertWorkflowRef {
+ return {
+ id: "wf-x",
+ store_listing_version_id: null,
+ library_agent_id: null,
+ graph_id: null,
+ name: null,
+ description: null,
+ ...overrides,
+ };
+}
+
+describe("getExpertFirstName", () => {
+ test("returns the first token of the name", () => {
+ expect(getExpertFirstName("Maria Lopez")).toBe("Maria");
+ expect(getExpertFirstName("Max")).toBe("Max");
+ expect(getExpertFirstName(" Frankie ")).toBe("Frankie");
+ });
+
+ test("falls back for an empty name", () => {
+ expect(getExpertFirstName("")).toBe("Expert");
+ expect(getExpertFirstName(" ")).toBe("Expert");
+ });
+});
+
+describe("getExpertAccessProviders", () => {
+ // Every provider the platform pays for, as /api/integrations/providers/system
+ // returns them. The roster's real workflows are almost entirely these.
+ const systemProviders = ["anthropic", "openai", "jina", "webshare_proxy"];
+
+ test("keeps only what the viewer has to connect themselves", () => {
+ // Maria's real providers on dev: three the platform supplies, one not.
+ const blogWriter = makeWorkflow({
+ id: "wf-1",
+ integration_providers: ["openai", "dataforseo", "anthropic"],
+ });
+ const copyImprover = makeWorkflow({
+ id: "wf-2",
+ integration_providers: ["openai", "jina"],
+ });
+
+ expect(
+ getExpertAccessProviders([blogWriter, copyImprover], systemProviders),
+ ).toEqual(["dataforseo"]);
+ });
+
+ test("reads the untruncated list, not the three-item display chain", () => {
+ // The chain caps at three, so a fourth integration is missing from it.
+ // Reading the chain here would drop airtable and tell the user to connect
+ // three services when they have to connect four.
+ const workflow = makeWorkflow({
+ id: "wf-1",
+ chain: [
+ { kind: "integration", provider: "google" },
+ { kind: "integration", provider: "dataforseo" },
+ { kind: "integration", provider: "openai" },
+ ],
+ integration_providers: ["airtable", "dataforseo", "google", "openai"],
+ });
+
+ expect(getExpertAccessProviders([workflow], systemProviders)).toEqual([
+ "airtable",
+ "dataforseo",
+ "google",
+ ]);
+ });
+
+ test("dedupes a provider named by more than one workflow", () => {
+ const first = makeWorkflow({
+ id: "wf-1",
+ integration_providers: ["linkedin"],
+ });
+ const second = makeWorkflow({
+ id: "wf-2",
+ integration_providers: ["linkedin", "google"],
+ });
+
+ expect(getExpertAccessProviders([first, second], systemProviders)).toEqual([
+ "linkedin",
+ "google",
+ ]);
+ });
+
+ test("is empty when there is nothing to connect", () => {
+ expect(getExpertAccessProviders([], systemProviders)).toEqual([]);
+ // A template served before the listing-graph fallback landed carries no
+ // providers at all, and the section has to disappear rather than throw.
+ expect(
+ getExpertAccessProviders([makeWorkflow({ id: "wf-1" })], systemProviders),
+ ).toEqual([]);
+ expect(
+ getExpertAccessProviders(
+ [makeWorkflow({ id: "wf-2", integration_providers: ["anthropic"] })],
+ systemProviders,
+ ),
+ ).toEqual([]);
+ });
+
+ test("names nothing while the system-provider list is missing", () => {
+ // Better to say nothing than to tell someone they must connect Anthropic.
+ const workflow = makeWorkflow({
+ id: "wf-1",
+ integration_providers: ["anthropic", "dataforseo"],
+ });
+
+ expect(getExpertAccessProviders([workflow], undefined)).toEqual([]);
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.ts
index cff7bb3b2c..4c9ae0bde7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/ExpertsSection/helpers.ts
@@ -1,3 +1,4 @@
+import { ExpertWorkflowRef } from "@/app/api/__generated__/models/expertWorkflowRef";
import {
Briefcase01Icon,
ChartIncreaseIcon,
@@ -123,3 +124,28 @@ export function getRaisedExpertAccent(
icon: option.textClassName,
};
}
+
+export function getExpertFirstName(name: string): string {
+ return name.trim().split(/\s+/)[0] || "Expert";
+}
+
+/** The integrations an expert's workflows will ask this viewer to connect.
+ *
+ * Reads `integration_providers`, never `chain`: the chain is a three-item
+ * display summary, so a workflow with a fourth integration silently loses
+ * one, picked by node counts rather than by whether anyone connects it.
+ * Providers the platform already pays for are then subtracted — the roster
+ * leans on Anthropic, OpenAI, Jina and a Webshare proxy, none of which a user
+ * ever connects. Without the system list this returns nothing, because naming
+ * a provider the platform supplies is worse than naming none. */
+export function getExpertAccessProviders(
+ workflows: ExpertWorkflowRef[],
+ systemProviders: string[] | undefined,
+): string[] {
+ if (!systemProviders) return [];
+ const supplied = new Set(systemProviders);
+ const providers = workflows
+ .flatMap((workflow) => workflow.integration_providers ?? [])
+ .filter((provider) => !supplied.has(provider));
+ return [...new Set(providers)];
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertAccess.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertAccess.tsx
new file mode 100644
index 0000000000..5a31963054
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertAccess.tsx
@@ -0,0 +1,35 @@
+import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
+import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";
+import { ExpertSection } from "./ExpertSection";
+
+interface Props {
+ name: string;
+ providers: string[];
+}
+
+export function ExpertAccess({ name, providers }: Props) {
+ if (providers.length === 0) return null;
+
+ return (
+ <ExpertSection
+ title={`Services ${name} can work with`}
+ description={`${name} will ask you to connect these the first time they are needed — nothing is shared until you do.`}
+ >
+ <ul className="flex flex-wrap gap-2">
+ {providers.map((provider) => (
+ <li
+ key={provider}
+ className="flex min-w-0 items-center gap-2 rounded-lg bg-white px-2.5 py-1.5 text-sm text-zinc-700 ring-1 ring-inset ring-zinc-200/80"
+ >
+ {/* The label beside it already names the provider; without this a
+ screen reader announces the name twice. */}
+ <span aria-hidden="true" className="flex shrink-0">
+ <IntegrationLogo provider={provider} />
+ </span>
+ <span className="truncate">{formatProviderName(provider)}</span>
+ </li>
+ ))}
+ </ul>
+ </ExpertSection>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPage.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPage.tsx
index 71d3004f9a..924b5faa03 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPage.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPage.tsx
@@ -1,6 +1,10 @@
"use client";
-import { getExpertAccent } from "@/app/(platform)/marketplace/components/ExpertsSection/helpers";
+import {
+ getExpertAccent,
+ getExpertAccessProviders,
+ getExpertFirstName,
+} from "@/app/(platform)/marketplace/components/ExpertsSection/helpers";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";
import { Dialog } from "@/components/molecules/Dialog/Dialog";
@@ -11,9 +15,12 @@ import Link from "next/link";
import { notFound, useParams } from "next/navigation";
import { ReactNode } from "react";
import { ExpertAbout } from "./ExpertAbout";
+import { ExpertAccess } from "./ExpertAccess";
import { ExpertComingSoonLabel } from "./ExpertComingSoonLabel";
import { ExpertHireActions } from "./ExpertHireActions";
import { ExpertPageHeader } from "./ExpertPageHeader";
+import { ExpertPlanNote } from "./ExpertPlanNote";
+import { ExpertProtectedRules } from "./ExpertProtectedRules";
import { ExpertSkills } from "./ExpertSkills";
import { ExpertWorkflowList } from "./ExpertWorkflowList";
import { useExpertPage } from "../useExpertPage";
@@ -42,6 +49,7 @@ export function ExpertPage() {
isLoggedIn,
isHiringOpen,
isActionReady,
+ systemProviders,
isLoading,
isError,
refetch,
@@ -97,6 +105,7 @@ export function ExpertPage() {
}
const accent = getExpertAccent(expert.role);
+ const firstName = getExpertFirstName(expert.name);
let actions: ReactNode = <Skeleton className="h-9 w-28 rounded-full" />;
if (isActionReady) {
@@ -125,6 +134,18 @@ export function ExpertPage() {
workflows={expert.workflows}
accent={accent}
/>
+ <ExpertAccess
+ name={firstName}
+ providers={getExpertAccessProviders(
+ expert.workflows,
+ systemProviders,
+ )}
+ />
+ <ExpertPlanNote
+ name={firstName}
+ weeklyBudget={expert.weekly_budget ?? null}
+ />
+ <ExpertProtectedRules rules={expert.protected_soul_rules ?? []} />
</div>
{/* The voice pick follows a successful hire when the persona ships
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPlanNote.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPlanNote.tsx
new file mode 100644
index 0000000000..0978de1650
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertPlanNote.tsx
@@ -0,0 +1,20 @@
+import { creditsToUsdLabel } from "@/lib/credits";
+import { ExpertSection } from "./ExpertSection";
+
+interface Props {
+ name: string;
+ weeklyBudget: number | null;
+}
+
+export function ExpertPlanNote({ name, weeklyBudget }: Props) {
+ return (
+ <ExpertSection title="Included with your plan">
+ <p className="text-[15px] leading-6 text-zinc-600">
+ {`Hiring ${name} costs nothing extra. Their work draws on your existing balance`}
+ {weeklyBudget
+ ? `, capped at ${creditsToUsdLabel(weeklyBudget)} a week — a limit you can change once they are on your team.`
+ : "."}
+ </p>
+ </ExpertSection>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertProtectedRules.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertProtectedRules.tsx
new file mode 100644
index 0000000000..dd0636bdcf
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertProtectedRules.tsx
@@ -0,0 +1,38 @@
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { LockIcon } from "@hugeicons/core-free-icons";
+import { ExpertSection } from "./ExpertSection";
+
+interface Props {
+ rules: string[];
+}
+
+/** The rules baked into every expert's soul, quoted verbatim — the same
+ * strings the backend injects, so the promise on the profile and the
+ * instruction the model receives can never drift apart. */
+export function ExpertProtectedRules({ rules }: Props) {
+ if (rules.length === 0) return null;
+
+ return (
+ <ExpertSection
+ title="Rules this expert cannot break"
+ description="Part of every expert's soul, and not editable by anyone."
+ >
+ <ul className="flex flex-col gap-2">
+ {rules.map((rule) => (
+ <li
+ key={rule}
+ className="flex gap-2.5 text-[15px] leading-6 text-zinc-600"
+ >
+ <Icon
+ icon={LockIcon}
+ size={16}
+ aria-hidden="true"
+ className="mt-1 shrink-0 text-zinc-400"
+ />
+ <span>{rule}</span>
+ </li>
+ ))}
+ </ul>
+ </ExpertSection>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertSection.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertSection.tsx
index ecff844767..6b43ae4450 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertSection.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertSection.tsx
@@ -1,4 +1,4 @@
-import { ReactNode } from "react";
+import { ReactNode, useId } from "react";
interface Props {
title: string;
@@ -8,9 +8,14 @@ interface Props {
}
export function ExpertSection({ title, count, description, children }: Props) {
+ const headingId = useId();
+
return (
- <section>
- <h2 className="flex items-baseline gap-2 text-base font-medium text-zinc-900">
+ <section aria-labelledby={headingId}>
+ <h2
+ id={headingId}
+ className="flex items-baseline gap-2 text-base font-medium text-zinc-900"
+ >
{title}
{count !== undefined ? (
<span className="text-sm font-normal tabular-nums text-zinc-400">
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/useExpertPage.ts b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/useExpertPage.ts
index 6239aea004..0ef4ed70be 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/useExpertPage.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/useExpertPage.ts
@@ -2,6 +2,8 @@ import {
useListExperts,
useListExpertTemplates,
} from "@/app/api/__generated__/endpoints/experts/experts";
+import { useGetV1ListSystemProviders } from "@/app/api/__generated__/endpoints/integrations/integrations";
+import { okData } from "@/app/api/helpers";
import { Expert } from "@/app/api/__generated__/models/expert";
import { useAuth } from "@/lib/auth/hooks/useAuth";
import { Flag, useFlagStatus } from "@/services/feature-flags/use-get-flag";
@@ -26,6 +28,12 @@ export function useExpertPage({ expertId }: Args) {
const expertsQuery = useListExperts({
query: { select: (x) => x.data as Expert[], enabled: canHire },
});
+ // Which providers the platform already pays for. Public, so a signed-out
+ // visitor gets it too — without it the access list cannot tell an
+ // integration the viewer must connect from one they never will.
+ const systemProvidersQuery = useGetV1ListSystemProviders({
+ query: { select: (res) => okData(res) ?? [] },
+ });
const expert =
(templatesQuery.data ?? []).find((template) => template.id === expertId) ??
@@ -38,12 +46,17 @@ export function useExpertPage({ expertId }: Args) {
return {
expert,
hiredExpert,
+ // Undefined until the list is in: the access section renders nothing
+ // rather than risk naming a provider the platform supplies.
+ systemProviders: systemProvidersQuery.data,
isLoggedIn,
isHiringOpen,
// Which header action to show is only decided once LaunchDarkly has
- // answered: rendering "Coming soon" first would flash the wrong state at
- // the users who do have hiring.
- isActionReady: !isUserLoading && ready,
+ // answered and the roster is in: rendering "Coming soon" or a "Hire"
+ // button first would flash the wrong state at users who have hiring, or
+ // have already hired this expert. A disabled roster query never blocks —
+ // isLoading is false unless it is actually fetching.
+ isActionReady: !isUserLoading && ready && !expertsQuery.isLoading,
isLoading: templatesQuery.isLoading,
isError: templatesQuery.isError,
refetch: templatesQuery.refetch,
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/__tests__/expert-page.test.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/__tests__/expert-page.test.tsx
index a0b9fadfde..0911adcbe3 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/__tests__/expert-page.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/__tests__/expert-page.test.tsx
@@ -6,8 +6,14 @@ import {
} from "@/app/api/__generated__/endpoints/experts/experts.msw";
import { Expert } from "@/app/api/__generated__/models/expert";
import { Toaster } from "@/components/molecules/Toast/toaster";
+import { getGetV1ListSystemProvidersMockHandler } from "@/app/api/__generated__/endpoints/integrations/integrations.msw";
import { server } from "@/mocks/mock-server";
-import { render, screen, waitFor } from "@/tests/integrations/test-utils";
+import {
+ render,
+ screen,
+ waitFor,
+ within,
+} from "@/tests/integrations/test-utils";
import userEvent from "@testing-library/user-event";
import { HttpResponse, http } from "msw";
import { beforeEach, describe, expect, test, vi } from "vitest";
@@ -66,10 +72,14 @@ const mariaTemplate: Expert = {
identity: "You are Maria, a senior marketing strategist.",
voice_preferences: "Warm, concise, and direct.",
boundaries: "Never invent customer evidence.",
- protected_soul_rules: [],
+ protected_soul_rules: [
+ "The expert discloses that it is AI when acting externally.",
+ "The expert asks for approval before acting externally.",
+ ],
is_template: true,
source_template_id: null,
is_archived: false,
+ weekly_budget: 500,
workflows: [
{
id: "wf-1",
@@ -78,6 +88,16 @@ const mariaTemplate: Expert = {
store_listing_version_id: null,
library_agent_id: null,
graph_id: null,
+ integration_providers: ["anthropic", "jina"],
+ },
+ {
+ id: "wf-2",
+ name: "Automated Blog Writer",
+ description: "Turns a brief into a drafted post.",
+ store_listing_version_id: null,
+ library_agent_id: null,
+ graph_id: null,
+ integration_providers: ["dataforseo", "openai"],
},
],
};
@@ -115,6 +135,14 @@ describe("Marketplace expert page", () => {
mockParams.expertId = "template-maria";
flagStatusMock.mockReturnValue({ enabled: true, ready: true });
mockUseAuth.mockReturnValue({ user: { id: "user-1" }, isLoggedIn: true });
+ server.use(
+ getGetV1ListSystemProvidersMockHandler([
+ "anthropic",
+ "openai",
+ "jina",
+ "webshare_proxy",
+ ]),
+ );
});
test("shows the profile and hires from the page", async () => {
@@ -131,7 +159,11 @@ describe("Marketplace expert page", () => {
).toBeDefined();
expect(screen.getByText("Grows your brand while you sleep")).toBeDefined();
expect(screen.getByText("Content strategy")).toBeDefined();
- expect(screen.getByText("LinkedIn Post Generator")).toBeDefined();
+ expect(
+ within(screen.getByRole("region", { name: /^Workflows/ })).getByText(
+ "LinkedIn Post Generator",
+ ),
+ ).toBeDefined();
expect(
screen
.getByRole("link", { name: "Back to marketplace" })
@@ -146,6 +178,86 @@ describe("Marketplace expert page", () => {
);
});
+ test("renders the services, plan and disclosure sections", async () => {
+ server.use(
+ getListExpertTemplatesMockHandler([mariaTemplate]),
+ getListExpertsMockHandler([]),
+ );
+
+ renderPage();
+
+ // Only what the viewer connects: Anthropic, OpenAI and Jina are on the
+ // platform's own credentials and must not be asked for.
+ const access = await screen.findByRole("region", {
+ name: "Services Maria can work with",
+ });
+ expect(within(access).getByText("DataForSEO")).toBeDefined();
+ expect(within(access).queryByText("Anthropic")).toBeNull();
+ expect(within(access).queryByText("OpenAI")).toBeNull();
+
+ expect(
+ screen.getByRole("heading", { name: "Included with your plan" }),
+ ).toBeDefined();
+ expect(screen.getByText(/capped at \$5 a week/)).toBeDefined();
+
+ expect(
+ screen.getByText(
+ "The expert discloses that it is AI when acting externally.",
+ ),
+ ).toBeDefined();
+ });
+
+ test("drops the services section when there is nothing to connect", async () => {
+ server.use(
+ getListExpertTemplatesMockHandler([
+ { ...mariaTemplate, workflows: [], protected_soul_rules: [] },
+ ]),
+ getListExpertsMockHandler([]),
+ );
+
+ renderPage();
+
+ expect(
+ await screen.findByRole("heading", { level: 1, name: "Maria" }),
+ ).toBeDefined();
+ expect(
+ screen.queryByRole("region", { name: /Services Maria can work with/ }),
+ ).toBeNull();
+ expect(screen.queryByText(/cannot break/)).toBeNull();
+ // The plan line has no data to be missing, so it always stands.
+ expect(
+ screen.getByRole("heading", { name: "Included with your plan" }),
+ ).toBeDefined();
+ });
+
+ test("waits for the roster before offering to hire an expert already hired", async () => {
+ let releaseRoster = () => {};
+ const rosterHeld = new Promise<void>((resolve) => {
+ releaseRoster = resolve;
+ });
+ server.use(
+ getListExpertTemplatesMockHandler([mariaTemplate]),
+ http.get("*/api/experts", async () => {
+ await rosterHeld;
+ return HttpResponse.json([hiredMaria]);
+ }),
+ );
+
+ renderPage();
+
+ expect(
+ await screen.findByRole("heading", { level: 1, name: "Maria" }),
+ ).toBeDefined();
+ // The roster has not answered, so neither action may be shown yet.
+ expect(screen.queryByRole("button", { name: "Hire Maria" })).toBeNull();
+ expect(screen.queryByText("On your team")).toBeNull();
+
+ releaseRoster();
+
+ expect(await screen.findByText("On your team")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Hire Maria" })).toBeNull();
+ });
+
test("shows the on-your-team state with a way into the chat", async () => {
server.use(
getListExpertTemplatesMockHandler([mariaTemplate]),
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
index cb73e845ab..2cb5e4a30e 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
@@ -443,6 +443,28 @@ describe("TeamPage", () => {
expect(getStatValue(card, "Schedules")).toBe("1");
});
+ test("keeps the roster when only the schedules query fails", async () => {
+ server.use(
+ getListExpertsMockHandler([hiredMaria]),
+ http.get(
+ "*/api/schedules",
+ () => new HttpResponse(null, { status: 401 }),
+ ),
+ );
+
+ render(<TeamPage />);
+
+ expect(
+ await screen.findByRole("link", { name: "View Maria" }),
+ ).toBeDefined();
+ // The roster loaded, so the page must not claim it could not.
+ await waitFor(() =>
+ expect(
+ screen.queryByText("We could not load your hired experts."),
+ ).toBeNull(),
+ );
+ });
+
test("does not badge a card for a workflow without a schedule", async () => {
const needsSetupMaria: Expert = {
...hiredMaria,
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/useTeamPage.ts b/autogpt_platform/frontend/src/app/(platform)/team/useTeamPage.ts
index 174fa4a92f..99dbeecc96 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/useTeamPage.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/team/useTeamPage.ts
@@ -71,8 +71,10 @@ export function useTeamPage({ enabled }: Args) {
hiredExperts,
schedules,
schedulesForExpert,
- isLoading: enabled && (expertsQuery.isLoading || schedulesQuery.isLoading),
- isError: expertsQuery.isError || schedulesQuery.isError,
+ // Only the roster decides the page's loading and error states: a slow or
+ // failing schedules fetch must not hide experts that loaded fine.
+ isLoading: enabled && expertsQuery.isPending,
+ isError: expertsQuery.isError,
refetch,
installWorkflow,
pickerExpertId,
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 300d556e81..c0202f97ca 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -21076,6 +21076,11 @@
"items": { "$ref": "#/components/schemas/ExpertWorkflowChainItem" },
"type": "array",
"title": "Chain"
+ },
+ "integration_providers": {
+ "items": { "type": "string" },
+ "type": "array",
+ "title": "Integration Providers"
}
},
"type": "object",
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
index 44b0fc2d14..83fa89d03f 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
@@ -21,9 +21,9 @@ export interface ProviderGroupView {
}
const TYPE_LABELS: Record<CredentialType, string> = {
- api_key: "API Key",
+ api_key: "API Key", // pragma: allowlist secret
oauth2: "OAuth",
- user_password: "User/Password",
+ user_password: "User/Password", // pragma: allowlist secret
host_scoped: "Host-scoped",
device_code: "Device auth",
};
@@ -42,6 +42,7 @@ const PROVIDER_DISPLAY_NAME_OVERRIDES: Record<string, string> = {
openweathermap: "OpenWeatherMap",
e2b: "E2B",
d_id: "D-ID",
+ dataforseo: "DataForSEO",
ideogram: "Ideogram",
jina: "Jina",
linkedin: "LinkedIn",