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): raise experts with real marketplace skills (#14550)

Ubbec8407e550371
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 dcf5a2a449..3ef1e3d54d 100644
--- a/autogpt_platform/backend/backend/api/features/experts/experts_db.py
+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db.py
@@ -1046,8 +1046,8 @@ async def create_raised_expert(
A raised expert has no source template, so ``sourceTemplateId`` stays
NULL. Capacity checks and creation share a per-user advisory lock.
- Attachments are validated before creation. Workflow install failure
- remains non-fatal and is reported in the result.
+ Attachments are validated before creation. A workflow or marketplace-skill
+ install failure remains non-fatal and is reported in the result.
"""
resolved = await raise_attachments.resolve_attachments(user_id, attachments or [])
expert = await _create_raised_expert_row(
@@ -1063,24 +1063,38 @@ async def create_raised_expert(
weekly_budget=weekly_budget,
skills=resolved.skill_names,
)
- failed_skills = await _copy_library_skills(user_id, expert.id, resolved.skill_names)
- if failed_skills:
+ failed_skill_installs = await raise_attachments.install_marketplace_skills(
+ user_id, expert.id, resolved.skills
+ )
+ # Keyed on the whole attachment, not the bare id: the same slug can be
+ # attached from both the Hub and the user's own library, and a failed Hub
+ # install must not drop the library copy that succeeded.
+ uninstalled = {(f.kind, f.source, f.id) for f in failed_skill_installs}
+ dropped_skills = set(
+ await _copy_library_skills(user_id, expert.id, resolved.library_skill_names)
+ ) | {
+ s.name
+ for s in resolved.skills
+ if (s.attachment.kind, s.attachment.source, s.attachment.id) in uninstalled
+ }
+ if dropped_skills:
expert = (
await prisma.models.Expert.prisma().update(
where={"id": expert.id},
data={
"skills": [
- s for s in (expert.skills or []) if s not in failed_skills
+ s for s in (expert.skills or []) if s not in dropped_skills
]
},
include=_WORKFLOW_INCLUDE,
)
or expert
)
- failed_attachments = await raise_attachments.install_workflows(
+ failed_workflows = await raise_attachments.install_workflows(
user_id, expert.id, resolved.workflows
)
- if resolved.workflows and len(failed_attachments) < len(resolved.workflows):
+ failed_attachments = failed_skill_installs + failed_workflows
+ if resolved.workflows and len(failed_workflows) < len(resolved.workflows):
hydrated = await get_expert(user_id, expert.id)
if hydrated is None:
raise ExpertNotFoundError(expert.id)
@@ -1092,8 +1106,9 @@ async def create_raised_expert(
async def _copy_library_skills(
user_id: str, expert_id: str, names: list[str]
) -> list[str]:
- """Give a freshly raised expert its own copies of the Otto skills it
- was raised with. Defaults and marketplace names have nothing to copy.
+ """Give a freshly raised expert its own copies of the library skills it
+ was raised with. Defaults have nothing to copy; marketplace skills are
+ installed from their listing instead and never reach here.
Returns the names whose copy failed so the caller can drop them from the
expert's row rather than list a skill the expert cannot read."""
candidates = [
@@ -1106,8 +1121,8 @@ async def _copy_library_skills(
for name in candidates:
folder = folders.get(name.strip().lower())
if folder is None:
- # A marketplace attachment: no library folder to copy, and the
- # name is legitimate, so it stays on the row.
+ # A default listed under a name that differs from its slug: no
+ # folder to copy, and the name is legitimate, so it stays.
continue
try:
if await copy_skill_to_expert(user_id, expert_id, folder) is None:
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 eedefedd10..76285a4b3a 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
@@ -16,7 +16,7 @@ import pydantic
import pytest
import backend.api.features.store.model as store_model
-from backend.api.features.experts import experts_db, scheduling, seed
+from backend.api.features.experts import experts_db, raise_attachments, scheduling, seed
from backend.api.features.experts.models import (
ExpertBundledSkill,
ExpertDayOneItem,
@@ -160,8 +160,8 @@ def _library_skill(slug: str) -> list[RaiseAttachment]:
return [RaiseAttachment(kind="skill", source="library", id=slug)]
-def _marketplace_skill(listing_id: str) -> list[RaiseAttachment]:
- return [RaiseAttachment(kind="skill", source="marketplace", id=listing_id)]
+def _marketplace_skill(slug: str) -> list[RaiseAttachment]:
+ return [RaiseAttachment(kind="skill", source="marketplace", id=slug)]
async def _create_seed_user():
@@ -1071,23 +1071,108 @@ async def test_raise_expert_rejects_missing_library_skill(server: SpinTestServer
@pytest.mark.asyncio(loop_scope="session")
-async def test_raise_expert_attaches_marketplace_skill_name(server: SpinTestServer):
+async def test_raise_expert_installs_a_marketplace_skill(
+ server: SpinTestServer, hub_listing
+):
owner = await _create_seed_user()
- slv_id = await _seed_store_listing(server)
- listing = await prisma.models.StoreListingVersion.prisma().find_unique(
- where={"id": slv_id}
+
+ with _patch_skills_path(_FakeWorkspaceManager()):
+ raised = await experts_db.create_raised_expert(
+ owner.id,
+ name="Nova",
+ role=None,
+ voice_preferences=None,
+ attachments=_marketplace_skill(hub_listing.slug),
+ )
+ installed = await read_user_skill_with_body(
+ owner.id, hub_listing.slug, expert_id=raised.expert.id
+ )
+
+ assert raised.expert.skills == [hub_listing.slug]
+ assert raised.expert.workflows == []
+ assert raised.failed_attachments == []
+ assert installed is not None
+ assert installed.description == f"{hub_listing.slug} description"
+
+
[email protected](loop_scope="session")
+async def test_raise_expert_rejects_a_marketplace_skill_that_is_not_listed(
+ server: SpinTestServer,
+):
+ owner = await _create_seed_user()
+
+ with pytest.raises(experts_db.FirstJobUnavailableError):
+ await experts_db.create_raised_expert(
+ owner.id,
+ name="Nova",
+ role=None,
+ voice_preferences=None,
+ attachments=_marketplace_skill("no-such-skill"),
+ )
+ assert await experts_db.list_experts(owner.id) == []
+
+
[email protected](loop_scope="session")
+async def test_a_failed_marketplace_skill_install_leaves_no_name_on_the_row(
+ server: SpinTestServer, hub_listing, monkeypatch
+):
+ owner = await _create_seed_user()
+ install = AsyncMock(side_effect=RuntimeError("storage down"))
+ monkeypatch.setattr(
+ raise_attachments.skill_db, "install_marketplace_skill", install
)
- assert listing is not None
raised = await experts_db.create_raised_expert(
owner.id,
name="Nova",
role=None,
voice_preferences=None,
- attachments=_marketplace_skill(slv_id),
+ attachments=_marketplace_skill(hub_listing.slug),
)
- assert raised.expert.skills == [listing.name]
- assert raised.expert.workflows == []
+
+ install.assert_awaited_once()
+ assert raised.expert.skills == []
+ assert [f.reason for f in raised.failed_attachments] == ["installation_failed"]
+
+
[email protected](loop_scope="session")
+async def test_a_failed_hub_install_keeps_the_library_skill_of_the_same_slug(
+ server: SpinTestServer, hub_listing, monkeypatch
+):
+ """The picker can attach one slug from both halves; the two differ only by
+ source, so the failed Hub install must not take the library copy with it."""
+ owner = await _create_seed_user()
+ monkeypatch.setattr(
+ raise_attachments.skill_db,
+ "install_marketplace_skill",
+ AsyncMock(side_effect=RuntimeError("storage down")),
+ )
+ with (
+ patch.object(
+ experts_db.raise_attachments,
+ "get_default_skill_with_body",
+ return_value=None,
+ ),
+ patch.object(
+ experts_db.raise_attachments,
+ "read_user_skill_with_body",
+ new_callable=AsyncMock,
+ return_value=SimpleNamespace(name="My Own Playbook"),
+ ),
+ ):
+ raised = await experts_db.create_raised_expert(
+ owner.id,
+ name="Nova",
+ role=None,
+ voice_preferences=None,
+ attachments=_marketplace_skill(hub_listing.slug)
+ + _library_skill(hub_listing.slug),
+ )
+
+ assert raised.expert.skills == ["My Own Playbook"]
+ assert [(f.source, f.reason) for f in raised.failed_attachments] == [
+ ("marketplace", "installation_failed")
+ ]
@pytest.mark.asyncio(loop_scope="session")
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.py
index 9de2bdd540..30ced4882b 100644
--- a/autogpt_platform/backend/backend/api/features/experts/models.py
+++ b/autogpt_platform/backend/backend/api/features/experts/models.py
@@ -330,10 +330,10 @@ WEEKLY_BUDGET_MAX_CREDITS = 1_000_000
class RaiseAttachment(BaseModel):
"""One workflow or skill to attach while raising an expert.
- ``id`` is a store listing version UUID (marketplace), a library agent
- UUID (library workflow), or a copilot skill slug (library skill).
- Marketplace skills use a store listing version UUID; the listing's
- public name is stored on ``Expert.skills``.
+ ``id`` is a store listing version UUID (marketplace workflow), a library
+ agent UUID (library workflow), or a skill slug — the caller's own skill
+ for ``library``, a Hub :class:`SkillListing` slug for ``marketplace``.
+ Either skill slug ends up on ``Expert.skills``.
"""
kind: RaiseAttachmentKind
diff --git a/autogpt_platform/backend/backend/api/features/experts/raise_attachments.py b/autogpt_platform/backend/backend/api/features/experts/raise_attachments.py
index 5f8e160b01..454e35f4c4 100644
--- a/autogpt_platform/backend/backend/api/features/experts/raise_attachments.py
+++ b/autogpt_platform/backend/backend/api/features/experts/raise_attachments.py
@@ -15,6 +15,7 @@ from backend.api.features.experts.models import (
RaiseAttachmentSource,
)
from backend.api.features.library import db as library_db
+from backend.api.features.store import skill_db
from backend.copilot.tools.skills import (
get_default_skill_with_body,
read_user_skill_with_body,
@@ -49,9 +50,30 @@ class ResolvedWorkflow(BaseModel):
library_agent_id: str | None
+class ResolvedSkill(BaseModel):
+ """One skill to give the expert.
+
+ ``name`` is what goes on ``Expert.skills``. ``marketplace_slug`` is set for
+ a Hub listing, whose SKILL.md is installed into the expert's folder; a
+ library skill is copied from the user's own folder instead.
+ """
+
+ attachment: RaiseAttachment
+ name: str
+ marketplace_slug: str | None = None
+
+
class ResolvedRaiseAttachments(BaseModel):
workflows: list[ResolvedWorkflow]
- skill_names: list[str]
+ skills: list[ResolvedSkill]
+
+ @property
+ def skill_names(self) -> list[str]:
+ return [skill.name for skill in self.skills]
+
+ @property
+ def library_skill_names(self) -> list[str]:
+ return [s.name for s in self.skills if s.marketplace_slug is None]
async def resolve_attachments(
@@ -59,7 +81,7 @@ async def resolve_attachments(
) -> ResolvedRaiseAttachments:
"""Pre-check every attachment. Raises if any item is not attachable."""
workflows: list[ResolvedWorkflow] = []
- skill_names: list[str] = []
+ skills: list[ResolvedSkill] = []
seen: set[tuple[str, str, str]] = set()
for attachment in attachments:
key = _dedupe_key(attachment)
@@ -69,8 +91,42 @@ async def resolve_attachments(
if attachment.kind == "workflow":
workflows.append(await _resolve_workflow(user_id, attachment))
continue
- skill_names.append(await _resolve_skill_name(user_id, attachment))
- return ResolvedRaiseAttachments(workflows=workflows, skill_names=skill_names)
+ skills.append(await _resolve_skill(user_id, attachment))
+ return ResolvedRaiseAttachments(workflows=workflows, skills=skills)
+
+
+async def install_marketplace_skills(
+ user_id: str,
+ expert_id: str,
+ skills: list[ResolvedSkill],
+) -> list[RaiseAttachmentFailure]:
+ """Copy each Hub listing's SKILL.md into the expert's own skill folder.
+
+ Library skills are the caller's job — they are copied from the user's own
+ folder. Failures are reported, not fatal, as workflow installs are.
+ """
+ failed: list[RaiseAttachmentFailure] = []
+ for resolved in skills:
+ if resolved.marketplace_slug is None:
+ continue
+ try:
+ await skill_db.install_marketplace_skill(
+ user_id, resolved.marketplace_slug, expert_id=expert_id
+ )
+ except NotFoundError:
+ failed.append(_failure(resolved.attachment, "unavailable"))
+ logger.warning(
+ f"Marketplace skill {resolved.marketplace_slug!r} became "
+ f"unavailable while raising expert #{expert_id} for user #{user_id}"
+ )
+ except Exception:
+ failed.append(_failure(resolved.attachment, "installation_failed"))
+ logger.exception(
+ f"Failed to install marketplace skill "
+ f"{resolved.marketplace_slug!r} on raised expert #{expert_id} "
+ f"for user #{user_id}"
+ )
+ return failed
async def install_workflows(
@@ -165,7 +221,7 @@ async def _resolve_workflow(
user_id: str, attachment: RaiseAttachment
) -> ResolvedWorkflow:
if attachment.source == "marketplace":
- await _validate_marketplace_listing(attachment.id, "workflow")
+ await _validate_marketplace_listing(attachment.id)
return ResolvedWorkflow(
attachment=attachment,
store_listing_version_id=attachment.id,
@@ -179,34 +235,32 @@ async def _resolve_workflow(
)
-async def _resolve_skill_name(user_id: str, attachment: RaiseAttachment) -> str:
- if attachment.source == "marketplace":
- await _validate_marketplace_listing(attachment.id, "skill")
- listing = await prisma.models.StoreListingVersion.prisma().find_unique(
- where={"id": attachment.id}
- )
- if listing is None:
- raise RaiseAttachmentUnavailableError("skill", "marketplace", attachment.id)
- return listing.name
+async def _resolve_skill(user_id: str, attachment: RaiseAttachment) -> ResolvedSkill:
slug = attachment.id.strip().lower()
+ if attachment.source == "marketplace":
+ try:
+ await skill_db.get_marketplace_skill(slug)
+ except NotFoundError:
+ raise RaiseAttachmentUnavailableError("skill", "marketplace", slug)
+ # The install names the copy after the listing slug, so that is the
+ # name the expert's row has to carry for the two to line up.
+ return ResolvedSkill(attachment=attachment, name=slug, marketplace_slug=slug)
default = get_default_skill_with_body(slug)
if default is not None:
- return default.name
+ return ResolvedSkill(attachment=attachment, name=default.name)
stored = await read_user_skill_with_body(user_id, slug)
if stored is None:
raise RaiseAttachmentUnavailableError("skill", "library", slug)
- return stored.name
+ return ResolvedSkill(attachment=attachment, name=stored.name)
-async def _validate_marketplace_listing(
- store_listing_version_id: str, kind: RaiseAttachmentKind
-) -> None:
+async def _validate_marketplace_listing(store_listing_version_id: str) -> None:
is_installable = await library_db.is_store_listing_version_available_for_install(
store_listing_version_id
)
if not is_installable:
raise RaiseAttachmentUnavailableError(
- kind, "marketplace", store_listing_version_id
+ "workflow", "marketplace", store_listing_version_id
)
@@ -279,7 +333,8 @@ async def _existing_listing_workflow(
def _dedupe_key(attachment: RaiseAttachment) -> tuple[str, str, str]:
attachment_id = attachment.id
- if attachment.kind == "skill" and attachment.source == "library":
+ # Both skill sources are slugs, which are case-insensitive.
+ if attachment.kind == "skill":
attachment_id = attachment.id.strip().lower()
return (attachment.kind, attachment.source, attachment_id)
diff --git a/autogpt_platform/backend/backend/api/features/experts/raise_attachments_test.py b/autogpt_platform/backend/backend/api/features/experts/raise_attachments_test.py
index 690a10cbe4..3e49df77d9 100644
--- a/autogpt_platform/backend/backend/api/features/experts/raise_attachments_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/raise_attachments_test.py
@@ -7,6 +7,8 @@ import prisma.models
import pytest
from backend.api.features.experts import raise_attachments
+from backend.api.features.experts.models import RaiseAttachment
+from backend.util.exceptions import NotFoundError
def _transaction_losing_the_insert():
@@ -72,3 +74,93 @@ async def test_install_marketplace_workflow_reraises_race_without_winner():
)
workflow_client.find_first.assert_awaited_once()
+
+
+def _hub_skill(slug: str) -> raise_attachments.ResolvedSkill:
+ return raise_attachments.ResolvedSkill(
+ attachment=RaiseAttachment(kind="skill", source="marketplace", id=slug),
+ name=slug,
+ marketplace_slug=slug,
+ )
+
+
+async def test_install_marketplace_skills_reports_a_withdrawn_listing():
+ """The real race: the listing passed resolve_attachments and was pulled
+ before the install, which is `unavailable` rather than a failed install."""
+ with patch.object(
+ raise_attachments.skill_db,
+ "install_marketplace_skill",
+ new_callable=AsyncMock,
+ side_effect=NotFoundError("gone"),
+ ):
+ failures = await raise_attachments.install_marketplace_skills(
+ "user-1", "expert-1", [_hub_skill("seo-playbook")]
+ )
+
+ assert [(f.kind, f.source, f.id, f.reason) for f in failures] == [
+ ("skill", "marketplace", "seo-playbook", "unavailable")
+ ]
+
+
+async def test_install_marketplace_skills_reports_a_broken_install():
+ with patch.object(
+ raise_attachments.skill_db,
+ "install_marketplace_skill",
+ new_callable=AsyncMock,
+ side_effect=RuntimeError("disk full"),
+ ):
+ failures = await raise_attachments.install_marketplace_skills(
+ "user-1", "expert-1", [_hub_skill("seo-playbook")]
+ )
+
+ assert [f.reason for f in failures] == ["installation_failed"]
+
+
+async def test_install_marketplace_skills_installs_each_slug_and_skips_library():
+ library = raise_attachments.ResolvedSkill(
+ attachment=RaiseAttachment(kind="skill", source="library", id="my-skill"),
+ name="my-skill",
+ )
+ with patch.object(
+ raise_attachments.skill_db,
+ "install_marketplace_skill",
+ new_callable=AsyncMock,
+ ) as install:
+ failures = await raise_attachments.install_marketplace_skills(
+ "user-1", "expert-1", [_hub_skill("seo-playbook"), library]
+ )
+
+ assert failures == []
+ install.assert_awaited_once_with("user-1", "seo-playbook", expert_id="expert-1")
+
+
+async def test_resolve_skill_addresses_a_hub_listing_by_slug():
+ """The name on the row has to be the slug the install names the copy
+ after, or the folder and Expert.skills disagree."""
+ attachment = RaiseAttachment(
+ kind="skill", source="marketplace", id=" SEO-Playbook "
+ )
+ with patch.object(
+ raise_attachments.skill_db,
+ "get_marketplace_skill",
+ new_callable=AsyncMock,
+ ) as get_skill:
+ resolved = await raise_attachments.resolve_attachments("user-1", [attachment])
+
+ get_skill.assert_awaited_once_with("seo-playbook")
+ assert [(s.name, s.marketplace_slug) for s in resolved.skills] == [
+ ("seo-playbook", "seo-playbook")
+ ]
+ assert resolved.library_skill_names == []
+
+
+async def test_resolve_skill_rejects_a_listing_that_is_not_there():
+ attachment = RaiseAttachment(kind="skill", source="marketplace", id="ghost")
+ with patch.object(
+ raise_attachments.skill_db,
+ "get_marketplace_skill",
+ new_callable=AsyncMock,
+ side_effect=NotFoundError("no listing"),
+ ):
+ with pytest.raises(raise_attachments.RaiseAttachmentUnavailableError):
+ await raise_attachments.resolve_attachments("user-1", [attachment])
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/__tests__/skills-section.test.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/__tests__/skills-section.test.tsx
index 97f4e99775..663b3fd688 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/__tests__/skills-section.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/__tests__/skills-section.test.tsx
@@ -191,6 +191,29 @@ describe("Marketplace SkillsSection", () => {
expect(brand.textContent).toContain("View");
});
+ test("offers Build your own above the shelf's text action", async () => {
+ server.use(listing([brandVoice, outreach], 2));
+
+ render(<MainMarkeplacePage />);
+
+ const build = await screen.findByRole(
+ "link",
+ { name: "Build your own" },
+ { timeout: 10000 },
+ );
+ expect(build.getAttribute("href")).toBe("/library/skills");
+ });
+
+ test("hides Build your own from signed-out visitors", async () => {
+ mockUseAuth.mockReturnValue({ user: null, isLoggedIn: false });
+ server.use(listing([brandVoice, outreach], 2));
+
+ render(<MainMarkeplacePage />);
+
+ await screen.findAllByTestId("skill-card", undefined, { timeout: 10000 });
+ expect(screen.queryByRole("link", { name: "Build your own" })).toBeNull();
+ });
+
test("offers no Browse all while the catalogue fits the shelf", async () => {
server.use(listing([brandVoice, outreach], 2));
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SectionHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SectionHeader.tsx
index 74a46adeb7..a431464ec7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SectionHeader.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SectionHeader.tsx
@@ -26,8 +26,10 @@ export function SectionHeader({
action,
secondaryAction,
}: Props) {
+ // A phone stacks the actions under the text rather than hiding them: for
+ // the skills shelf this block is the only route to authoring your own.
return (
- <div className="mb-7 flex items-end justify-between gap-4">
+ <div className="mb-7 flex flex-col items-start justify-between gap-4 sm:flex-row sm:items-end">
<div>
{eyebrow ? (
<div className="mb-2.5 flex items-center gap-2 text-xs font-medium uppercase tracking-[0.14em] text-violet-600">
@@ -47,7 +49,7 @@ export function SectionHeader({
) : null}
</div>
{action || secondaryAction ? (
- <div className="hidden shrink-0 flex-col items-end gap-2 sm:flex">
+ <div className="flex shrink-0 flex-row items-center gap-4 sm:flex-col sm:items-end sm:gap-2">
{secondaryAction ? (
<Button
as="NextLink"
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SkillsSection/SkillsSection.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SkillsSection/SkillsSection.tsx
index 0b8c40d355..b96c3664ac 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SkillsSection/SkillsSection.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/SkillsSection/SkillsSection.tsx
@@ -45,18 +45,12 @@ export function SkillsSection({ category }: Props) {
titleId={HEADING_ID}
subtitle="Playbooks your experts follow — from brand voice to cold outreach. Teach them your way of working."
action={sectionAction({ isLoggedIn, total })}
+ secondaryAction={
+ isLoggedIn
+ ? { label: "Build your own", href: "/library/skills" }
+ : undefined
+ }
/>
- {isLoggedIn ? (
- <div className="-mt-3 mb-6">
- <Link
- href="/library/skills"
- className="text-sm font-medium text-accent transition-colors hover:text-accent/80"
- >
- …or teach them a skill of your own
- </Link>
- </div>
- ) : null}
-
{isLoading ? (
<div
role="status"
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/raise/__tests__/main.test.tsx
index 6eb76c2fac..865f666a49 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/__tests__/main.test.tsx
@@ -1,6 +1,8 @@
import { getCreateRaisedExpertMockHandler } from "@/app/api/__generated__/endpoints/experts/experts.msw";
import { getListCopilotSkillsMockHandler } from "@/app/api/__generated__/endpoints/skills/skills.msw";
+import { getGetV2ListMarketplaceSkillsMockHandler200 } from "@/app/api/__generated__/endpoints/store/store.msw";
import type { Expert } from "@/app/api/__generated__/models/expert";
+import type { MarketplaceSkill } from "@/app/api/__generated__/models/marketplaceSkill";
import type { RaiseResult } from "@/app/api/__generated__/models/raiseResult";
import { Toaster } from "@/components/molecules/Toast/toaster";
import { server } from "@/mocks/mock-server";
@@ -22,10 +24,14 @@ vi.mock("@/services/feature-flags/use-get-flag", async (importActual) => {
>();
return {
...actual,
- useFlagStatus: (flag: string) =>
- flag === "hire-experts"
- ? setFlagStatusMock()
- : actual.useFlagStatus(flag as never),
+ useFlagStatus: (flag: string) => {
+ if (flag === "hire-experts") return setFlagStatusMock();
+ // The Hub is on here so the flow runs in the configuration production
+ // will be in: leaving it to the real hook disabled the listing query
+ // and left "Hub on and empty" — the case that drops the beat — untested.
+ if (flag === "skills-hub") return { enabled: true, ready: true };
+ return actual.useFlagStatus(flag as never);
+ },
};
});
@@ -67,6 +73,20 @@ const raisedExpert = {
workflows: [],
} as Expert;
+const LIBRARY_SKILL = { name: "seo-audit", description: "Audit landing pages" };
+
+function hubSkills(skills: MarketplaceSkill[]) {
+ return getGetV2ListMarketplaceSkillsMockHandler200({
+ skills,
+ pagination: {
+ total_items: skills.length,
+ total_pages: 1,
+ current_page: 1,
+ page_size: 3,
+ },
+ });
+}
+
function raiseResult(overrides: Partial<RaiseResult> = {}): RaiseResult {
return { expert: raisedExpert, failed_attachments: [], ...overrides };
}
@@ -138,7 +158,9 @@ beforeEach(() => {
setFlagStatusMock.mockReturnValue({ enabled: true, ready: true });
pushMock.mockClear();
notFoundMock.mockClear();
- server.use(getListCopilotSkillsMockHandler([]));
+ // One library skill is enough to keep the skills beat in the flow; with
+ // none and an empty Hub, the marketplace beat becomes the last one.
+ server.use(getListCopilotSkillsMockHandler([LIBRARY_SKILL]), hubSkills([]));
});
afterEach(() => {
@@ -342,6 +364,106 @@ test("picking a weekly budget advances to marketplace workflows", async () => {
expect(screen.getByRole("button", { name: "That's it" })).toBeDefined();
});
+test("drops the skills beat and raises from the marketplace step when there is nothing to add", async () => {
+ let captured: unknown = null;
+ // The Hub is on for this file, so this is an empty catalogue plus an empty
+ // library — not a disabled flag.
+ server.use(
+ getListCopilotSkillsMockHandler([]),
+ getCreateRaisedExpertMockHandler(async (info) => {
+ captured = await info.request.json();
+ return raiseResult();
+ }),
+ );
+
+ seedAtBudget();
+ renderRaise();
+ await userEvent.click(
+ await screen.findByRole("button", { name: "$5 / week" }),
+ );
+
+ const finish = await screen.findByRole(
+ "button",
+ { name: /Bring Otto to life/ },
+ { timeout: 5000 },
+ );
+ expect(screen.queryByRole("textbox", { name: "Search skills" })).toBeNull();
+ await userEvent.click(finish);
+
+ await waitFor(() => expect(captured).not.toBeNull());
+ expect(captured).toMatchObject({ weekly_budget: 500, attachments: [] });
+ await waitFor(() =>
+ expect(pushMock).toHaveBeenCalledWith(
+ "/copilot?expertId=raised-1&kickoff=1",
+ ),
+ );
+});
+
+test("keeps the skills beat when only the Hub has something to offer", async () => {
+ server.use(
+ getListCopilotSkillsMockHandler([]),
+ hubSkills([
+ {
+ slug: "cold-outreach",
+ name: "Cold Outreach",
+ description: "Write cold emails",
+ categories: ["sales"],
+ required_providers: [],
+ install_count: 2,
+ },
+ ]),
+ );
+
+ seedAtBudget();
+ renderRaise();
+ await userEvent.click(
+ await screen.findByRole("button", { name: "$5 / week" }),
+ );
+
+ expect(
+ await screen.findByRole("button", { name: "That's it" }, { timeout: 5000 }),
+ ).toBeDefined();
+ expect(
+ screen.queryByRole("button", { name: /Bring Otto to life/ }),
+ ).toBeNull();
+});
+
+test("keeps the skills beat when availability settles empty after marketplace submit", async () => {
+ let captured: unknown = null;
+ let settleLibrary!: (skills: (typeof LIBRARY_SKILL)[]) => void;
+ const pendingLibrary = new Promise<(typeof LIBRARY_SKILL)[]>((resolve) => {
+ settleLibrary = resolve;
+ });
+ server.use(
+ getListCopilotSkillsMockHandler(() => pendingLibrary),
+ getCreateRaisedExpertMockHandler(async (info) => {
+ captured = await info.request.json();
+ return raiseResult();
+ }),
+ );
+
+ seedAtBudget();
+ renderRaise();
+ await userEvent.click(
+ await screen.findByRole("button", { name: "$5 / week" }),
+ );
+ await userEvent.click(
+ await screen.findByRole("button", { name: "That's it" }),
+ );
+ settleLibrary([]);
+
+ await userEvent.click(
+ await screen.findByRole(
+ "button",
+ { name: /Bring Otto to life/ },
+ { timeout: 5000 },
+ ),
+ );
+
+ await waitFor(() => expect(captured).not.toBeNull());
+ expect(captured).toMatchObject({ weekly_budget: 500, attachments: [] });
+});
+
test("back returns to the previous step and the draft survives", async () => {
seedAtBudget();
renderRaise();
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.test.ts
index 63031c0c0e..448a71e153 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, test } from "vitest";
import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import type { MarketplaceSkill } from "@/app/api/__generated__/models/marketplaceSkill";
import type { StoreAgent } from "@/app/api/__generated__/models/storeAgent";
import {
combineSearchHits,
@@ -24,6 +25,17 @@ const storeAgent = {
agent_graph_id: "graph-1",
} as StoreAgent;
+const marketplaceSkill: MarketplaceSkill = {
+ slug: "seo-playbook",
+ // Deliberately unlike the slug: a listing's version name is its SKILL.md
+ // frontmatter name, and only the slug addresses the listing.
+ name: "SEO Playbook",
+ description: "An SEO playbook",
+ categories: ["content"],
+ required_providers: [],
+ install_count: 3,
+};
+
describe("kit helpers", () => {
test("parses dollar amounts into credits and rejects junk", () => {
expect(parseBudget("5")).toBe(500);
@@ -50,6 +62,7 @@ describe("kit helpers", () => {
storeAgents: [storeAgent],
libraryAgents: [{ id: "lib-1", name: "Local SEO" } as LibraryAgent],
skills: [{ name: "seo-audit", description: "Audit pages" }],
+ marketplaceSkills: [],
scope: "marketplace",
});
@@ -59,7 +72,7 @@ describe("kit helpers", () => {
]);
});
- test("combines marketplace-as-skill and library skills", () => {
+ test("combines marketplace and library skills, ignoring store agents", () => {
const hits = combineSearchHits({
query: "seo",
storeAgents: [storeAgent],
@@ -68,18 +81,57 @@ describe("kit helpers", () => {
{ name: "seo-audit", description: "Audit pages" },
{ name: "unrelated", description: "Something else" },
],
+ marketplaceSkills: [marketplaceSkill],
scope: "skills",
});
expect(hits.map((hit) => hit.subtitle)).toEqual([
- "Marketplace skill",
"Library skill",
+ "Marketplace skill",
]);
+ expect(hits.map((hit) => hit.name)).not.toContain("SEO Blog Writer");
expect(
hits.find((hit) => hit.kind === "skill" && hit.source === "library")?.id,
).toBe("seo-audit");
});
+ test("addresses a marketplace skill by its slug, not a listing id", () => {
+ const [hit] = combineSearchHits({
+ query: "",
+ storeAgents: [],
+ libraryAgents: [],
+ skills: [],
+ marketplaceSkills: [marketplaceSkill],
+ scope: "skills",
+ });
+
+ expect(hit.id).toBe("seo-playbook");
+ expect(hit.name).toBe("SEO Playbook");
+ expect(hit.kind).toBe("skill");
+ expect(hit.source).toBe("marketplace");
+ });
+
+ test("keeps the user's own skills reachable when nothing is typed", () => {
+ const hits = combineSearchHits({
+ query: "",
+ storeAgents: [],
+ libraryAgents: [],
+ skills: [{ name: "my-skill", description: "Mine" }],
+ marketplaceSkills: [
+ marketplaceSkill,
+ { ...marketplaceSkill, slug: "cold-outreach", name: "Cold Outreach" },
+ { ...marketplaceSkill, slug: "brand-voice", name: "Brand Voice" },
+ ],
+ scope: "skills",
+ });
+
+ expect(hits.map((hit) => hit.id)).toEqual([
+ "my-skill",
+ "seo-playbook",
+ "cold-outreach",
+ ]);
+ });
+
test("limits default marketplace results to three items", () => {
const hits = combineSearchHits({
query: "",
@@ -94,6 +146,7 @@ describe("kit helpers", () => {
{ id: "lib-2", name: "Library 2" } as LibraryAgent,
],
skills: [],
+ marketplaceSkills: [],
scope: "marketplace",
});
@@ -116,6 +169,7 @@ describe("kit helpers", () => {
{ name: "skill-c", description: "C" },
{ name: "skill-d", description: "D" },
],
+ marketplaceSkills: [],
scope: "skills",
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.ts
index bcb844af15..c46201dad3 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/helpers.ts
@@ -1,8 +1,10 @@
import type { CopilotSkillInfo } from "@/app/api/__generated__/models/copilotSkillInfo";
import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import type { MarketplaceSkill } from "@/app/api/__generated__/models/marketplaceSkill";
import type { RaiseAttachment } from "@/app/api/__generated__/models/raiseAttachment";
import type { StoreAgent } from "@/app/api/__generated__/models/storeAgent";
import { parseUsdToCredits } from "@/lib/credits";
+import { formatSkillTitle } from "../../../marketplace/components/SkillsSection/helpers";
import type { RaiseAttachmentDraft } from "../../helpers";
export const MAX_ATTACHMENTS = 20;
@@ -67,20 +69,21 @@ export function combineSearchHits({
storeAgents,
libraryAgents,
skills,
+ marketplaceSkills,
scope,
}: {
query: string;
storeAgents: StoreAgent[];
libraryAgents: LibraryAgent[];
skills: CopilotSkillInfo[];
+ marketplaceSkills: MarketplaceSkill[];
scope: KitSearchScope;
}): SearchHit[] {
const hits: SearchHit[] = [];
- const kind = scope === "marketplace" ? "workflow" : "skill";
- for (const agent of storeAgents) {
- hits.push(marketplaceHit(agent, kind));
- }
if (scope === "marketplace") {
+ for (const agent of storeAgents) {
+ hits.push(marketplaceWorkflowHit(agent));
+ }
for (const agent of libraryAgents) {
hits.push({
key: `library:workflow:${agent.id}`,
@@ -94,19 +97,36 @@ export function combineSearchHits({
return limitSearchHits(hits, query);
}
const needle = query.trim().toLowerCase();
- for (const skill of skills) {
- if (!skillMatches(skill, needle)) continue;
- hits.push({
- key: `library:skill:${skill.name.toLowerCase()}`,
- name: skill.name,
- subtitle: "Library skill",
- kind: "skill",
- source: "library",
- id: skill.name,
- description: skill.description,
- });
+ const libraryHits = skills
+ .filter((skill) => skillMatches(skill, needle))
+ .map(
+ (skill): SearchHit => ({
+ key: `library:skill:${skill.name.toLowerCase()}`,
+ name: skill.name,
+ subtitle: "Library skill",
+ kind: "skill",
+ source: "library",
+ id: skill.name,
+ description: skill.description,
+ }),
+ );
+ // Browsing with nothing typed, the Hub asks for exactly as many listings as
+ // there are slots, so pushing it first would bury the user's own skills —
+ // the half they are likeliest to be after. Interleaving keeps both visible.
+ // A typed query is ranked instead, so order in equals order out there.
+ return limitSearchHits(
+ interleave(libraryHits, marketplaceSkills.map(marketplaceSkillHit)),
+ query,
+ );
+}
+
+function interleave(left: SearchHit[], right: SearchHit[]): SearchHit[] {
+ const merged: SearchHit[] = [];
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
+ if (i < left.length) merged.push(left[i]);
+ if (i < right.length) merged.push(right[i]);
}
- return limitSearchHits(hits, query);
+ return merged;
}
export function skillMatches(skill: CopilotSkillInfo, needle: string) {
@@ -174,19 +194,29 @@ export function failedAttachmentMessage(
.join(". ");
}
-function marketplaceHit(
- agent: StoreAgent,
- kind: "workflow" | "skill",
-): SearchHit {
+function marketplaceWorkflowHit(agent: StoreAgent): SearchHit {
return {
- key: `marketplace:${kind}:${agent.creator.toLowerCase()}/${agent.slug}`,
+ key: `marketplace:workflow:${agent.creator.toLowerCase()}/${agent.slug}`,
name: agent.agent_name,
- subtitle:
- kind === "workflow" ? "Marketplace workflow" : "Marketplace skill",
- kind,
+ subtitle: "Marketplace workflow",
+ kind: "workflow",
source: "marketplace",
+ // Resolved to a store listing version id when the row is added.
id: "",
creator: agent.creator,
slug: agent.slug,
};
}
+
+// A Hub skill listing is addressed by its slug, so nothing needs resolving.
+function marketplaceSkillHit(skill: MarketplaceSkill): SearchHit {
+ return {
+ key: `marketplace:skill:${skill.slug}`,
+ name: formatSkillTitle(skill.name),
+ subtitle: "Marketplace skill",
+ kind: "skill",
+ source: "marketplace",
+ id: skill.slug,
+ description: skill.description,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useAttachmentPicker.ts b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useAttachmentPicker.ts
index 554dc34456..b413d6e9ec 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useAttachmentPicker.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useAttachmentPicker.ts
@@ -35,8 +35,10 @@ export function useAttachmentPicker({
);
}
+ // Only a marketplace workflow needs resolving: a listing card carries a
+ // creator/slug pair, while every other hit already knows its own id.
async function addHit(hit: SearchHit) {
- if (hit.source === "marketplace") {
+ if (hit.source === "marketplace" && hit.kind === "workflow") {
await addMarketplaceHit(hit);
return;
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useKitSearch.ts b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useKitSearch.ts
index 4c60584de2..bd96420d76 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useKitSearch.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/KitStep/useKitSearch.ts
@@ -1,8 +1,12 @@
import { useGetV2ListLibraryAgents } from "@/app/api/__generated__/endpoints/library/library";
import { useListCopilotSkills } from "@/app/api/__generated__/endpoints/skills/skills";
-import { useGetV2ListStoreAgents } from "@/app/api/__generated__/endpoints/store/store";
+import {
+ useGetV2ListMarketplaceSkills,
+ useGetV2ListStoreAgents,
+} from "@/app/api/__generated__/endpoints/store/store";
import { okData } from "@/app/api/helpers";
import { useDebouncedValue } from "@/hooks/useDebouncedValue";
+import { Flag, useFlagStatus } from "@/services/feature-flags/use-get-flag";
import { useState } from "react";
import {
combineSearchHits,
@@ -16,14 +20,15 @@ export function useKitSearch(scope: KitSearchScope) {
const debouncedQuery = useDebouncedValue(searchQuery, SEARCH_DEBOUNCE_MS);
const trimmed = debouncedQuery.trim();
const hasQuery = trimmed.length > 0;
- const searchStore = scope === "marketplace" || hasQuery;
- const searchLibrary = scope === "marketplace";
+ const isWorkflowScope = scope === "marketplace";
+ const hub = useFlagStatus(Flag.SKILLS_HUB);
+ const searchHubSkills = !isWorkflowScope && hub.ready && hub.enabled;
const storeQuery = useGetV2ListStoreAgents(
{ search_query: trimmed, page_size: MAX_SEARCH_RESULTS },
{
query: {
- enabled: searchStore,
+ enabled: isWorkflowScope,
select: (response) => okData(response)?.agents ?? [],
},
},
@@ -32,14 +37,23 @@ export function useKitSearch(scope: KitSearchScope) {
{ search_term: trimmed, page_size: MAX_SEARCH_RESULTS, is_hidden: false },
{
query: {
- enabled: searchLibrary,
+ enabled: isWorkflowScope,
select: (response) => okData(response)?.agents ?? [],
},
},
);
+ const hubQuery = useGetV2ListMarketplaceSkills(
+ { search_query: trimmed, page_size: MAX_SEARCH_RESULTS },
+ {
+ query: {
+ enabled: searchHubSkills,
+ select: (response) => okData(response)?.skills ?? [],
+ },
+ },
+ );
const skillsQuery = useListCopilotSkills(undefined, {
query: {
- enabled: scope === "skills",
+ enabled: !isWorkflowScope,
select: (response) => okData(response) ?? [],
},
});
@@ -53,11 +67,13 @@ export function useKitSearch(scope: KitSearchScope) {
storeAgents: storeQuery.data ?? [],
libraryAgents: libraryQuery.data ?? [],
skills: skillsQuery.data ?? [],
+ marketplaceSkills: hubQuery.data ?? [],
scope,
}),
isSearching:
- (scope === "skills" && skillsQuery.isLoading) ||
- (searchStore && storeQuery.isFetching) ||
- (searchLibrary && libraryQuery.isFetching),
+ (!isWorkflowScope && skillsQuery.isLoading) ||
+ (searchHubSkills && hubQuery.isFetching) ||
+ (isWorkflowScope && storeQuery.isFetching) ||
+ (isWorkflowScope && libraryQuery.isFetching),
};
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.test.tsx b/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.test.tsx
index 8c35c68cd9..6d721d1d6b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.test.tsx
@@ -34,8 +34,11 @@ function renderMarketplace(
render(
<>
<MarketplaceStep
+ name="Otto"
color="rose-300"
submitted={null}
+ isFinal={false}
+ isSubmitting={false}
onSubmit={onSubmit}
onSkip={onSkip}
{...overrides}
@@ -66,6 +69,14 @@ describe("MarketplaceStep", () => {
expect(onSkip).toHaveBeenCalled();
});
+ test("raises the expert itself when it is the flow's last beat", async () => {
+ const { onSubmit } = renderMarketplace({ isFinal: true });
+ await userEvent.click(
+ screen.getByRole("button", { name: "Bring Otto to life" }),
+ );
+ expect(onSubmit).toHaveBeenCalledWith([]);
+ });
+
test("shows only three default marketplace workflows", async () => {
server.use(
getGetV2ListStoreAgentsMockHandler({
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.tsx b/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.tsx
index a939387763..bfdf55922b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/MarketplaceStep/MarketplaceStep.tsx
@@ -4,23 +4,35 @@ import type { RaiseAttachmentDraft } from "../../helpers";
import { AttachmentStep } from "../KitStep/AttachmentStep";
interface Props {
+ name: string;
color: string | null;
submitted: RaiseAttachmentDraft[] | null;
+ isFinal: boolean;
+ isSubmitting: boolean;
onSubmit: (attachments: RaiseAttachmentDraft[]) => void;
onSkip: () => void;
}
-export function MarketplaceStep({ color, submitted, onSubmit, onSkip }: Props) {
+export function MarketplaceStep({
+ name,
+ color,
+ submitted,
+ isFinal,
+ isSubmitting,
+ onSubmit,
+ onSkip,
+}: Props) {
return (
<AttachmentStep
color={color}
submitted={submitted}
+ isSubmitting={isSubmitting}
scope="marketplace"
searchLabel="Search marketplace and library workflows"
searchPlaceholder="Search marketplace and library workflows…"
emptyQueryHint="Search to add marketplace or library workflows."
emptyResultsHint="No matching workflows."
- primaryLabel="That's it"
+ primaryLabel={isFinal ? `Bring ${name || "them"} to life` : "That's it"}
onSubmit={onSubmit}
onSkip={onSkip}
/>
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/RaiseFlow/components/BeatControl.tsx b/autogpt_platform/frontend/src/app/(platform)/raise/components/RaiseFlow/components/BeatControl.tsx
index f2c88aad34..1dd4e37c71 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/RaiseFlow/components/BeatControl.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/RaiseFlow/components/BeatControl.tsx
@@ -93,8 +93,11 @@ export function BeatControl({ beat, flow }: Props) {
case "marketplace":
return (
<MarketplaceStep
+ name={flow.name}
color={flow.color}
submitted={flow.marketplace}
+ isFinal={flow.isMarketplaceFinal}
+ isSubmitting={flow.isSubmitting}
onSubmit={flow.submitMarketplace}
onSkip={flow.skipMarketplace}
/>
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/components/SkillsStep/SkillsStep.test.tsx b/autogpt_platform/frontend/src/app/(platform)/raise/components/SkillsStep/SkillsStep.test.tsx
index d83a406a24..033aed2e30 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/components/SkillsStep/SkillsStep.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/components/SkillsStep/SkillsStep.test.tsx
@@ -1,17 +1,34 @@
import { getListCopilotSkillsMockHandler } from "@/app/api/__generated__/endpoints/skills/skills.msw";
import {
- getGetV2GetSpecificAgentMockHandler,
+ getGetV2ListMarketplaceSkillsMockHandler200,
getGetV2ListStoreAgentsMockHandler,
} from "@/app/api/__generated__/endpoints/store/store.msw";
+import type { MarketplaceSkill } from "@/app/api/__generated__/models/marketplaceSkill";
import type { StoreAgent } from "@/app/api/__generated__/models/storeAgent";
-import type { StoreAgentDetails } from "@/app/api/__generated__/models/storeAgentDetails";
import { Toaster } from "@/components/molecules/Toast/toaster";
import { server } from "@/mocks/mock-server";
import { render, screen, waitFor } from "@/tests/integrations/test-utils";
import userEvent from "@testing-library/user-event";
-import { describe, expect, test, vi } from "vitest";
+import { beforeEach, describe, expect, test, vi } from "vitest";
import { SkillsStep } from "./SkillsStep";
+const flags = vi.hoisted(() => ({ skillsHub: true }));
+
+vi.mock("@/services/feature-flags/use-get-flag", async (importOriginal) => {
+ const actual =
+ await importOriginal<
+ typeof import("@/services/feature-flags/use-get-flag")
+ >();
+ return {
+ ...actual,
+ useFlagStatus: (flag: string) => {
+ if (flag === "skills-hub")
+ return { enabled: flags.skillsHub, ready: true };
+ return actual.useFlagStatus(flag as never);
+ },
+ };
+});
+
const storeAgent = {
slug: "seo-writer",
agent_name: "SEO Blog Writer",
@@ -25,6 +42,27 @@ const storeAgent = {
agent_graph_id: "graph-1",
} as StoreAgent;
+const outreach: MarketplaceSkill = {
+ slug: "outreach-playbook",
+ name: "outreach-playbook",
+ description: "Cold outreach that lands",
+ categories: ["sales"],
+ required_providers: [],
+ install_count: 4,
+};
+
+function marketplaceSkills(skills: MarketplaceSkill[]) {
+ return getGetV2ListMarketplaceSkillsMockHandler200({
+ skills,
+ pagination: {
+ total_items: skills.length,
+ total_pages: 1,
+ current_page: 1,
+ page_size: 3,
+ },
+ });
+}
+
function renderSkills(
overrides: Partial<Parameters<typeof SkillsStep>[0]> = {},
) {
@@ -49,6 +87,11 @@ function renderSkills(
}
describe("SkillsStep", () => {
+ beforeEach(() => {
+ flags.skillsHub = true;
+ server.use(marketplaceSkills([]));
+ });
+
test("shows only three default library skills", async () => {
server.use(
getListCopilotSkillsMockHandler([
@@ -91,37 +134,18 @@ describe("SkillsStep", () => {
]);
});
- test("searches marketplace agents as skills", async () => {
+ test("adds a marketplace skill by its slug", async () => {
server.use(
getListCopilotSkillsMockHandler([]),
- getGetV2ListStoreAgentsMockHandler({
- agents: [storeAgent],
- pagination: {
- total_items: 1,
- total_pages: 1,
- current_page: 1,
- page_size: 3,
- },
- }),
- getGetV2GetSpecificAgentMockHandler({
- store_listing_version_id: "listing-version-42",
- slug: "seo-writer",
- agent_name: "SEO Blog Writer",
- creator: "acme",
- } as StoreAgentDetails),
+ marketplaceSkills([outreach]),
);
const { onSubmit } = renderSkills();
- await userEvent.type(
- screen.getByRole("textbox", { name: "Search skills" }),
- "seo",
- );
-
expect(await screen.findByText("Marketplace skill")).toBeDefined();
await userEvent.click(screen.getByRole("button", { name: "Add" }));
await waitFor(() =>
expect(
- screen.getByRole("button", { name: /Remove SEO Blog Writer/ }),
+ screen.getByRole("button", { name: /Remove Outreach playbook/ }),
).toBeDefined(),
);
await userEvent.click(
@@ -132,12 +156,46 @@ describe("SkillsStep", () => {
expect.objectContaining({
kind: "skill",
source: "marketplace",
- id: "listing-version-42",
- name: "SEO Blog Writer",
+ id: "outreach-playbook",
+ name: "Outreach playbook",
}),
]);
});
+ test("never offers a marketplace agent as a skill", async () => {
+ server.use(
+ getListCopilotSkillsMockHandler([]),
+ getGetV2ListStoreAgentsMockHandler({
+ agents: [storeAgent],
+ pagination: {
+ total_items: 1,
+ total_pages: 1,
+ current_page: 1,
+ page_size: 3,
+ },
+ }),
+ marketplaceSkills([outreach]),
+ );
+ renderSkills();
+
+ expect(await screen.findByText("Outreach playbook")).toBeDefined();
+ expect(screen.queryByText("SEO Blog Writer")).toBeNull();
+ });
+
+ test("offers no marketplace skills while the hub is off", async () => {
+ flags.skillsHub = false;
+ server.use(
+ getListCopilotSkillsMockHandler([
+ { name: "seo-audit", description: "Audit landing pages" },
+ ]),
+ marketplaceSkills([outreach]),
+ );
+ renderSkills();
+
+ expect(await screen.findByText("seo-audit")).toBeDefined();
+ expect(screen.queryByText("Outreach playbook")).toBeNull();
+ });
+
test("skip raises without extra skills", async () => {
server.use(getListCopilotSkillsMockHandler([]));
const { onSkip } = renderSkills();
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/flowItems.ts b/autogpt_platform/frontend/src/app/(platform)/raise/flowItems.ts
index c059d9b88f..61d41ab2ed 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/flowItems.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/flowItems.ts
@@ -79,8 +79,13 @@ export function stepId(beat: BeatKey) {
return `${beat}-step`;
}
-// Each beat's question is asked once the beat before it has an answer.
-export function beatTriggers(draft: RaiseDraft): Record<BeatKey, boolean> {
+// Each beat's question is asked once the beat before it has an answer. The
+// skills beat is also conditional: with nothing to offer it never opens, and
+// the marketplace beat before it becomes the flow's last.
+export function beatTriggers(
+ draft: RaiseDraft,
+ hasSkillsBeat: boolean,
+): Record<BeatKey, boolean> {
return {
role: draft.hasStarted,
name: draft.role !== null,
@@ -90,7 +95,7 @@ export function beatTriggers(draft: RaiseDraft): Record<BeatKey, boolean> {
voice: draft.about !== null,
budget: draft.voiceLabel !== null,
marketplace: draft.budget !== null,
- skills: draft.marketplace !== null,
+ skills: hasSkillsBeat && draft.marketplace !== null,
};
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/raise/helpers.ts
index 90d343b3d2..8893ab8778 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/helpers.ts
@@ -75,7 +75,7 @@ export const RAISE_PROMPTS = {
marketplaceQuestion: (name: string) =>
`Want ${name || "your expert"} to run workflows? Search the marketplace and your library, then add any you like — or skip.`,
skillsQuestion: (name: string) =>
- `Should ${name || "your expert"} have extra skills? Add from your library, or a marketplace agent as a skill — or skip.`,
+ `Should ${name || "your expert"} have extra skills? Add one from the marketplace or your own library — or skip.`,
};
// Beat before each question lands, so the control that triggered it settles
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/useRaisePage.ts b/autogpt_platform/frontend/src/app/(platform)/raise/useRaisePage.ts
index ad505b7fde..cc96a799d2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/raise/useRaisePage.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/useRaisePage.ts
@@ -25,6 +25,7 @@ import {
} from "./helpers";
import { useFlowProgress } from "./useFlowProgress";
import { useRaiseSubmission } from "./useRaiseSubmission";
+import { useSkillsAvailability } from "./useSkillsAvailability";
export function useRaisePage() {
const searchParams = useSearchParams();
@@ -33,7 +34,9 @@ export function useRaisePage() {
const [draft, setDraft] = useState<RaiseDraft>(() =>
draftWithPrefilledRole(loadDraft(), searchParams.get("role")),
);
- const progress = useFlowProgress(beatTriggers(draft));
+ const { hasSkillsToOffer } = useSkillsAvailability();
+ const hasSkillsBeat = draft.marketplace !== null || hasSkillsToOffer;
+ const progress = useFlowProgress(beatTriggers(draft, hasSkillsBeat));
const { finish: submitRaise, isSubmitting } = useRaiseSubmission();
function finish(kit: RaiseKit) {
@@ -115,11 +118,23 @@ export function useRaisePage() {
update({ budget: { credits: null }, step: "marketplace" });
}
+ // With no skills to offer the marketplace beat is the last one, so it
+ // raises the expert itself rather than handing off to a beat that never
+ // opens. As with skills, the answer is not recorded until the POST wins,
+ // which keeps the retry control on screen when it fails.
function submitMarketplace(attachments: RaiseAttachmentDraft[]) {
+ if (!hasSkillsToOffer) {
+ finish({ weeklyBudget: draft.budget?.credits ?? null, attachments });
+ return;
+ }
update({ marketplace: attachments, step: "skills" });
}
function skipMarketplace() {
+ if (!hasSkillsToOffer) {
+ finish({ weeklyBudget: draft.budget?.credits ?? null, attachments: [] });
+ return;
+ }
update({ marketplace: [], step: "skills" });
}
@@ -161,6 +176,7 @@ export function useRaisePage() {
marketplace: draft.marketplace,
skills: draft.skills,
kit: assembledKit(draft),
+ isMarketplaceFinal: !hasSkillsBeat,
isSubmitting,
canGoBack: lastAnsweredBeat(draft) !== null,
startRaising,
diff --git a/autogpt_platform/frontend/src/app/(platform)/raise/useSkillsAvailability.ts b/autogpt_platform/frontend/src/app/(platform)/raise/useSkillsAvailability.ts
new file mode 100644
index 0000000000..45dc047c1b
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/raise/useSkillsAvailability.ts
@@ -0,0 +1,41 @@
+import { useListCopilotSkills } from "@/app/api/__generated__/endpoints/skills/skills";
+import { useGetV2ListMarketplaceSkills } from "@/app/api/__generated__/endpoints/store/store";
+import { okData } from "@/app/api/helpers";
+import { Flag, useFlagStatus } from "@/services/feature-flags/use-get-flag";
+import { MAX_SEARCH_RESULTS } from "./components/KitStep/helpers";
+
+// The skills beat is only worth asking when there is something to add: a live
+// Hub listing, or a skill the user has already written. Both queries share
+// their keys with the picker's own search, so asking costs no extra request.
+export function useSkillsAvailability() {
+ const hub = useFlagStatus(Flag.SKILLS_HUB);
+ const isHubOn = hub.ready && hub.enabled;
+
+ const marketplace = useGetV2ListMarketplaceSkills(
+ { search_query: "", page_size: MAX_SEARCH_RESULTS },
+ {
+ query: {
+ enabled: isHubOn,
+ select: (response) => okData(response)?.skills.length ?? 0,
+ },
+ },
+ );
+ const library = useListCopilotSkills(undefined, {
+ query: { select: (response) => okData(response)?.length ?? 0 },
+ });
+
+ const isSettled =
+ hub.ready &&
+ !library.isLoading &&
+ !library.isError &&
+ (!isHubOn || (!marketplace.isLoading && !marketplace.isError));
+
+ return {
+ isReady: isSettled,
+ // An unanswered or failed query keeps the beat: a request that did not
+ // come back is not an empty catalogue. It is the flow's last step, so
+ // dropping it moves the submit button — better late than flickering.
+ hasSkillsToOffer:
+ !isSettled || (marketplace.data ?? 0) > 0 || (library.data ?? 0) > 0,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 38bdf94af2..96c79d757d 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -26981,7 +26981,7 @@
"type": "object",
"required": ["kind", "source", "id"],
"title": "RaiseAttachment",
- "description": "One workflow or skill to attach while raising an expert.\n\n``id`` is a store listing version UUID (marketplace), a library agent\nUUID (library workflow), or a copilot skill slug (library skill).\nMarketplace skills use a store listing version UUID; the listing's\npublic name is stored on ``Expert.skills``."
+ "description": "One workflow or skill to attach while raising an expert.\n\n``id`` is a store listing version UUID (marketplace workflow), a library\nagent UUID (library workflow), or a skill slug — the caller's own skill\nfor ``library``, a Hub :class:`SkillListing` slug for ``marketplace``.\nEither skill slug ends up on ``Expert.skills``."
},
"RaiseAttachmentFailure": {
"properties": {