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): show a bundled workflow's cadence before hire, and skip install-time schedules a hire cannot run (#14506)

Reinier van der Leer3c3f102d7009
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 5ef0f1d4c4..e9c72deced 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
@@ -35,6 +35,7 @@ from backend.data.db import prisma as db_client
from backend.data.graph import Graph, GraphSettings, Node
from backend.data.model import User
from backend.data.user import get_or_create_user
+from backend.executor import utils as execution_utils
from backend.util.exceptions import ExpertRunPausedError, NotFoundError
from backend.util.json import SafeJson
from backend.util.test import SpinTestServer
@@ -110,6 +111,7 @@ async def _seed_store_listing(
server: SpinTestServer,
approved: bool = True,
extra_block_ids: list[str] | None = None,
+ input_value: str | None = "seeded",
) -> str:
"""Create a graph plus a store listing on top of it.
@@ -119,6 +121,9 @@ async def _seed_store_listing(
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``.
+
+ ``input_value=None`` leaves the graph's one input without a default,
+ which is what makes it a required user-supplied field.
"""
owner = await _create_seed_user()
admin = await _create_seed_user()
@@ -129,7 +134,8 @@ async def _seed_store_listing(
nodes=[
Node(
block_id=AgentInputBlock().id,
- input_default={"name": "input_1"},
+ input_default={"name": "input_1"}
+ | ({} if input_value is None else {"value": input_value}),
),
*(Node(block_id=block_id) for block_id in extra_block_ids or []),
],
@@ -2375,6 +2381,89 @@ async def test_hire_creates_schedule_from_template_cadence(
assert call_kwargs["expert_id"] == result.expert.id
[email protected](loop_scope="session")
+async def test_hire_creates_the_schedule_on_the_hiring_users_clock(
+ server: SpinTestServer, test_user
+):
+ """A 07:40 cadence means 07:40 where the user is, not UTC."""
+ slv_id = await _seed_store_listing(server)
+ template = await _seed_template(
+ name="Frankie",
+ preload_listings=[slv_id],
+ preload_crons={slv_id: "40 7 * * *"},
+ )
+ mock_scheduler = AsyncMock()
+ mock_scheduler.add_execution_schedule = AsyncMock(
+ return_value=SimpleNamespace(id="sched-tz")
+ )
+ with (
+ patch.object(scheduling, "get_scheduler_client", return_value=mock_scheduler),
+ patch.object(
+ experts_db,
+ "get_user_by_id",
+ new=AsyncMock(return_value=SimpleNamespace(timezone="Pacific/Auckland")),
+ ),
+ ):
+ await experts_db.hire_expert(test_user.id, template.id, None)
+
+ kwargs = mock_scheduler.add_execution_schedule.call_args.kwargs
+ assert kwargs["user_timezone"] == "Pacific/Auckland"
+
+
[email protected](loop_scope="session")
+async def test_hire_skips_the_schedule_when_the_graph_needs_user_input(
+ server: SpinTestServer, test_user
+):
+ """A cadence on a workflow whose inputs only the user can supply gets no
+ schedule: the cadence stays on the row so the Team page can ask for them."""
+ slv_id = await _seed_store_listing(server, input_value=None)
+ template = await _seed_template(
+ name="Frankie",
+ preload_listings=[slv_id],
+ preload_crons={slv_id: "40 7 * * *"},
+ )
+ mock_scheduler = AsyncMock()
+ mock_scheduler.add_execution_schedule = AsyncMock(
+ return_value=SimpleNamespace(id="sched-1")
+ )
+ with patch.object(scheduling, "get_scheduler_client", return_value=mock_scheduler):
+ result = await experts_db.hire_expert(test_user.id, template.id, None)
+
+ wf = result.expert.workflows[0]
+ assert wf.schedule_cron == "40 7 * * *"
+ assert wf.schedule_id is None
+ assert result.failed_preloads == []
+ mock_scheduler.add_execution_schedule.assert_not_awaited()
+
+
[email protected](loop_scope="session")
+async def test_the_scheduler_accepts_a_schedule_missing_a_required_input(
+ server: SpinTestServer, test_user
+):
+ """Why the skip above is load-bearing: nothing downstream refuses it.
+
+ ``add_graph_execution_schedule`` validates through this call, and an
+ ``AgentInputBlock`` with no value validates clean — so an unguarded
+ install creates a schedule that fires daily on an input yielding nothing.
+ """
+ slv_id = await _seed_store_listing(server, input_value=None)
+ template = await _seed_template(name="Frankie", preload_listings=[slv_id])
+ result = await experts_db.hire_expert(test_user.id, template.id, None)
+ library_agent_id = result.expert.workflows[0].library_agent_id
+ assert library_agent_id is not None
+ library_agent = await prisma.models.LibraryAgent.prisma().find_unique(
+ where={"id": library_agent_id}
+ )
+ assert library_agent is not None
+
+ await execution_utils.validate_and_construct_node_execution_input(
+ graph_id=library_agent.agentGraphId,
+ user_id=test_user.id,
+ graph_inputs={},
+ graph_version=library_agent.agentGraphVersion,
+ )
+
+
@pytest.mark.asyncio(loop_scope="session")
async def test_hire_schedule_failure_marks_needs_setup(
server: SpinTestServer, test_user
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.py
index 48a959c08a..b029c5cc1e 100644
--- a/autogpt_platform/backend/backend/api/features/experts/models.py
+++ b/autogpt_platform/backend/backend/api/features/experts/models.py
@@ -136,8 +136,10 @@ class ExpertSetupItem(BaseModel):
Rendered on the Team page as a row with a single fix. ``connect``: the
user has no credential for any of ``providers``. ``allow``: they have one
- (``credential_id``) that this expert may not use yet. ``workflow``: no
- credential is missing, so the schedule needs creating from the workflow.
+ (``credential_id``) that this expert may not use yet. ``inputs``: the
+ workflow needs the values in ``missing_inputs`` before it can run
+ unattended. ``workflow``: nothing is missing, so the schedule needs
+ creating from the workflow.
"""
expert_id: str
@@ -147,8 +149,11 @@ class ExpertSetupItem(BaseModel):
workflow_name: str | None
library_agent_id: str | None
providers: list[str]
- resolution: Literal["connect", "allow", "workflow"]
+ resolution: Literal["connect", "allow", "inputs", "workflow"]
credential_id: str | None = None
+ # Titles of the graph inputs a scheduled run cannot supply; only set on
+ # an ``inputs`` item.
+ missing_inputs: list[str] = Field(default_factory=list)
class ExpertCredentialRef(BaseModel):
diff --git a/autogpt_platform/backend/backend/api/features/experts/scheduling.py b/autogpt_platform/backend/backend/api/features/experts/scheduling.py
index 204f1da977..a8f2a45aa4 100644
--- a/autogpt_platform/backend/backend/api/features/experts/scheduling.py
+++ b/autogpt_platform/backend/backend/api/features/experts/scheduling.py
@@ -10,6 +10,7 @@ Split out of ``experts_db`` to keep both files within the size guideline.
import logging
import uuid
from datetime import datetime, timezone
+from typing import TYPE_CHECKING
import prisma.models
from prisma.enums import ResourceVisibility
@@ -25,6 +26,9 @@ from backend.util.exceptions import ExpertRunPausedError, NotFoundError
from backend.util.settings import Settings
from backend.util.timezone_utils import get_user_timezone_or_utc
+if TYPE_CHECKING:
+ from backend.data.graph import GraphModel
+
logger = logging.getLogger(__name__)
settings = Settings()
@@ -63,11 +67,24 @@ async def create_workflow_schedule(
user hasn't connected yet: the cadence stays on the row with a null
``scheduleId``, surfacing the workflow as "needs setup" instead of
silently dropping the roster's intent.
+
+ A graph that still needs user-supplied input gets no schedule at all,
+ for the same reason: a surprise run whose input node yields nothing is
+ worse than no run, and the missing fields are named on the setup card.
"""
try:
- input_credentials = await _resolve_workflow_credentials(
- user_id, expert_id, graph_id, graph_version
- )
+ graph = await _load_workflow_graph(user_id, graph_id, graph_version)
+ input_credentials: dict[str, CredentialsMetaInput] = {}
+ if graph is not None:
+ if missing := unsatisfied_required_inputs(graph):
+ logger.info(
+ f"Schedule for expert #{expert_id} workflow #{workflow_row_id} "
+ f"not created (needs input): {', '.join(missing)}"
+ )
+ return False
+ input_credentials = await _resolve_workflow_credentials(
+ user_id, expert_id, graph
+ )
schedule = await get_scheduler_client().add_execution_schedule(
user_id=user_id,
graph_id=graph_id,
@@ -110,8 +127,32 @@ async def create_workflow_schedule(
return True
+def unsatisfied_required_inputs(graph: "GraphModel") -> list[str]:
+ """Graph inputs a schedule would have to supply and cannot.
+
+ ``input_schema.required`` is exactly the set of graph inputs carrying no
+ default value, and an install-time schedule passes no input data.
+ """
+ schema = graph.input_schema
+ properties: dict = schema.get("properties", {})
+ return [
+ properties.get(name, {}).get("title") or name
+ for name in schema.get("required", [])
+ ]
+
+
+async def _load_workflow_graph(
+ user_id: str, graph_id: str, graph_version: int
+) -> "GraphModel | None":
+ # Imported here: graph loading pulls in the executor, which imports this
+ # package at module load.
+ from backend.data.graph import get_graph
+
+ return await get_graph(graph_id, graph_version, user_id, include_subgraphs=True)
+
+
async def _resolve_workflow_credentials(
- user_id: str, expert_id: str, graph_id: str, graph_version: int
+ user_id: str, expert_id: str, graph: "GraphModel"
) -> dict[str, CredentialsMetaInput]:
"""The graph's credential inputs, filled from the expert's allow-list.
@@ -122,11 +163,7 @@ async def _resolve_workflow_credentials(
# Imported here: the matcher lives beside the executor, which imports this
# package at module load.
from backend.copilot.tools.utils import match_user_credentials_to_graph
- from backend.data.graph import get_graph
- graph = await get_graph(graph_id, graph_version, user_id, include_subgraphs=True)
- if graph is None:
- return {}
matched, _missing = await match_user_credentials_to_graph(user_id, graph, expert_id)
return matched
diff --git a/autogpt_platform/backend/backend/api/features/experts/scheduling_test.py b/autogpt_platform/backend/backend/api/features/experts/scheduling_test.py
index d8f24dbae2..062ddd9da9 100644
--- a/autogpt_platform/backend/backend/api/features/experts/scheduling_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/scheduling_test.py
@@ -1,3 +1,4 @@
+from types import SimpleNamespace
from unittest.mock import AsyncMock
import prisma.models
@@ -141,13 +142,14 @@ async def test_create_workflow_schedule_fills_credentials_from_the_allow_list(
) -> None:
"""The scheduler validates credential inputs, so an empty map fails every
graph that needs one; the expert's reachable credentials must be passed."""
- from types import SimpleNamespace
-
from backend.data.model import CredentialsMetaInput
meta = CredentialsMetaInput(
id="cred-notion", provider="notion", type="api_key", title="Notion"
)
+ mocker.patch.object(
+ scheduling, "_load_workflow_graph", new=AsyncMock(return_value=_graph([]))
+ )
mocker.patch.object(
scheduling,
"_resolve_workflow_credentials",
@@ -187,8 +189,6 @@ async def test_create_workflow_schedule_fills_credentials_from_the_allow_list(
@pytest.mark.asyncio
async def test_pending_schedules_are_retried_per_workflow(mocker) -> None:
- from types import SimpleNamespace
-
workflow_client = mocker.MagicMock()
workflow_client.find_many = AsyncMock(
return_value=[
@@ -243,3 +243,108 @@ async def test_pending_schedules_are_retried_per_workflow(mocker) -> None:
name="SEO Audit",
user_timezone="Europe/Madrid",
)
+
+
+def _graph(required: list[str], titles: dict[str, str] | None = None):
+ return SimpleNamespace(
+ input_schema={
+ "properties": {
+ name: {"title": (titles or {}).get(name)} for name in required
+ },
+ "required": required,
+ }
+ )
+
+
+def test_unsatisfied_required_inputs_prefers_the_field_title() -> None:
+ graph = _graph(["recipient"], {"recipient": "Email Address"})
+ assert scheduling.unsatisfied_required_inputs(graph) == ["Email Address"]
+
+
+def test_unsatisfied_required_inputs_falls_back_to_the_field_name() -> None:
+ assert scheduling.unsatisfied_required_inputs(_graph(["recipient"])) == [
+ "recipient"
+ ]
+
+
+def test_a_graph_whose_inputs_all_have_defaults_has_nothing_unsatisfied() -> None:
+ assert scheduling.unsatisfied_required_inputs(_graph([])) == []
+
+
+async def test_no_schedule_is_created_while_an_input_is_unsatisfied(mocker) -> None:
+ scheduler_client = mocker.MagicMock()
+ scheduler_client.add_execution_schedule = AsyncMock()
+ mocker.patch.object(
+ scheduling, "get_scheduler_client", return_value=scheduler_client
+ )
+ workflow_client = mocker.MagicMock()
+ workflow_client.update_many = AsyncMock()
+ mocker.patch.object(
+ scheduling.prisma.models.ExpertWorkflow, "prisma", return_value=workflow_client
+ )
+ mocker.patch.object(
+ scheduling,
+ "_load_workflow_graph",
+ new=AsyncMock(return_value=_graph(["recipient"], {"recipient": "Email"})),
+ )
+ # Mocked so the guard is the only thing that can stop the schedule:
+ # the real resolver raises on a stub graph, which would pass this test
+ # with the guard removed.
+ mocker.patch.object(
+ scheduling, "_resolve_workflow_credentials", new=AsyncMock(return_value={})
+ )
+
+ created = await scheduling.create_workflow_schedule(
+ workflow_row_id="wf-1",
+ expert_id="expert-1",
+ user_id="owner",
+ cron="40 7 * * *",
+ graph_id="g1",
+ graph_version=1,
+ name="Personal Newsletter",
+ user_timezone="UTC",
+ )
+
+ assert created is False
+ scheduler_client.add_execution_schedule.assert_not_awaited()
+ workflow_client.update_many.assert_not_awaited()
+
+
+async def test_a_fully_defaulted_graph_still_gets_its_schedule(mocker) -> None:
+ scheduler_client = mocker.MagicMock()
+ scheduler_client.add_execution_schedule = AsyncMock(
+ return_value=SimpleNamespace(id="sched-1")
+ )
+ mocker.patch.object(
+ scheduling, "get_scheduler_client", return_value=scheduler_client
+ )
+ workflow_client = mocker.MagicMock()
+ workflow_client.update_many = AsyncMock(return_value=1)
+ mocker.patch.object(
+ scheduling.prisma.models.ExpertWorkflow, "prisma", return_value=workflow_client
+ )
+ mocker.patch.object(
+ scheduling, "_load_workflow_graph", new=AsyncMock(return_value=_graph([]))
+ )
+ mocker.patch.object(
+ scheduling, "_resolve_workflow_credentials", new=AsyncMock(return_value={})
+ )
+
+ created = await scheduling.create_workflow_schedule(
+ workflow_row_id="wf-1",
+ expert_id="expert-1",
+ user_id="owner",
+ cron="40 7 * * *",
+ graph_id="g1",
+ graph_version=1,
+ name="Lead Finder",
+ user_timezone="UTC",
+ )
+
+ assert created is True
+ scheduler_client.add_execution_schedule.assert_awaited_once()
+ workflow_client.update_many.assert_awaited_once_with(
+ where={"id": "wf-1", "scheduleId": None}, data={"scheduleId": "sched-1"}
+ )
diff --git a/autogpt_platform/backend/backend/api/features/experts/seed.py b/autogpt_platform/backend/backend/api/features/experts/seed.py
index e7f0dbceae..017065fcdf 100644
--- a/autogpt_platform/backend/backend/api/features/experts/seed.py
+++ b/autogpt_platform/backend/backend/api/features/experts/seed.py
@@ -43,6 +43,10 @@ class PreloadSeed(TypedDict):
# means the workflow installs without a schedule. Applied to template
# rows on every seed run, but only copied to hires made afterwards —
# existing hires keep the schedule they were created with.
+ #
+ # A cadence fires unattended from the day of hire, so it may only go on a
+ # workflow that acts on nothing outside the platform — typically research.
+ # The marketplace reviewer is that gate; nothing here enforces it.
cron: str | None
diff --git a/autogpt_platform/backend/backend/api/features/experts/setup.py b/autogpt_platform/backend/backend/api/features/experts/setup.py
index 9343ce9542..2f93fe0a16 100644
--- a/autogpt_platform/backend/backend/api/features/experts/setup.py
+++ b/autogpt_platform/backend/backend/api/features/experts/setup.py
@@ -1,10 +1,10 @@
"""What stands between a hired expert and its scheduled work.
A workflow "needs setup" when its roster cadence could not become a schedule
-at install time, almost always because the graph needs a credential the
-expert cannot reach. This names that gap per workflow so the Team page can
-offer the one fix that clears it: connect a service, or allow the expert to
-use one the user already has.
+at install time — the graph needs a credential the expert cannot reach, or an
+input value only the user can give. This names that gap per workflow so the
+Team page can offer the one fix that clears it: connect a service, allow the
+expert to use one the user already has, or fill the workflow's inputs in.
"""
import logging
@@ -19,6 +19,7 @@ from backend.api.features.experts.credentials import (
filter_credentials_for_expert,
)
from backend.api.features.experts.models import ExpertSetupItem
+from backend.api.features.experts.scheduling import unsatisfied_required_inputs
from backend.data.model import Credentials
logger = logging.getLogger(__name__)
@@ -124,8 +125,12 @@ async def _workflow_items(
credential_id=candidate.id if candidate else None,
)
)
- # Everything is reachable yet the schedule is still missing: whatever
- # failed was not a credential, so hand the user the workflow itself.
+ if missing_inputs := unsatisfied_required_inputs(graph):
+ items.append(
+ item(providers=[], resolution="inputs", missing_inputs=missing_inputs)
+ )
+ # Nothing is missing yet the schedule is not there: whatever failed was
+ # neither a credential nor an input, so hand the user the workflow itself.
return items or [item(providers=[], resolution="workflow")]
diff --git a/autogpt_platform/backend/backend/api/features/experts/setup_test.py b/autogpt_platform/backend/backend/api/features/experts/setup_test.py
index e45cecad0a..e1d8ae6e3e 100644
--- a/autogpt_platform/backend/backend/api/features/experts/setup_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/setup_test.py
@@ -59,6 +59,7 @@ def _arrange(
credentials: list[APIKeyCredentials],
allowed: list[str],
fields: dict,
+ required_inputs: list[str] | None = None,
) -> None:
expert_client = mocker.MagicMock()
expert_client.find_many = AsyncMock(return_value=experts)
@@ -73,7 +74,15 @@ def _arrange(
)
mocker.patch(
"backend.data.graph.get_graph",
- new=AsyncMock(return_value=SimpleNamespace(regular_credentials_inputs=fields)),
+ new=AsyncMock(
+ return_value=SimpleNamespace(
+ regular_credentials_inputs=fields,
+ input_schema={
+ "properties": {},
+ "required": required_inputs or [],
+ },
+ )
+ ),
)
@@ -187,3 +196,42 @@ async def test_a_graph_that_fails_to_load_still_reports_the_workflow(
[item] = await setup.list_setup_items("user-1")
assert item.resolution == "workflow"
+
+
+async def test_an_input_only_the_user_can_supply_gets_its_own_row(
+ mocker: pytest_mock.MockFixture,
+):
+ """The newsletter's recipient: named, so the row says what to fill in."""
+ _arrange(
+ mocker,
+ experts=[_expert(_workflow())],
+ credentials=[],
+ allowed=[],
+ fields={},
+ required_inputs=["Email Address"],
+ )
+
+ [item] = await setup.list_setup_items("user-1")
+
+ assert item.resolution == "inputs"
+ assert item.missing_inputs == ["Email Address"]
+ assert item.library_agent_id == "lib-1"
+
+
+async def test_a_missing_credential_and_a_missing_input_are_separate_rows(
+ mocker: pytest_mock.MockFixture,
+):
+ _arrange(
+ mocker,
+ experts=[_expert(_workflow())],
+ credentials=[],
+ allowed=[],
+ fields={"notion": _field("notion")},
+ required_inputs=["Email Address"],
+ )
+
+ items = await setup.list_setup_items("user-1")
+
+ assert [item.resolution for item in items] == ["connect", "inputs"]
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/ExpertWorkflowCard.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/ExpertWorkflowCard.tsx
index 4d6170c8f4..7b119cb8d1 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/ExpertWorkflowCard.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/ExpertWorkflowCard.tsx
@@ -4,8 +4,9 @@ import type { ExpertAccent } from "@/app/(platform)/marketplace/components/Exper
import { ExpertWorkflowRef } from "@/app/api/__generated__/models/expertWorkflowRef";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";
-import { FlashIcon } from "@hugeicons/core-free-icons";
+import { Calendar03Icon, FlashIcon } from "@hugeicons/core-free-icons";
import Image from "next/image";
+import { getCadenceLabel } from "./helpers";
import { useExpertWorkflowCard } from "./useExpertWorkflowCard";
interface Props {
@@ -47,6 +48,17 @@ export function ExpertWorkflowCard({ workflow, accent }: Props) {
{workflow.description}
</p>
) : null}
+ {workflow.schedule_cron ? (
+ <p className="mt-2 flex items-center gap-1.5 text-[13px] leading-5 text-zinc-600">
+ <Icon
+ icon={Calendar03Icon}
+ size={14}
+ className="shrink-0"
+ aria-hidden="true"
+ />
+ {getCadenceLabel(workflow.schedule_cron)}
+ </p>
+ ) : null}
</div>
</li>
);
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.test.ts
new file mode 100644
index 0000000000..58ee5be8f1
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.test.ts
@@ -0,0 +1,14 @@
+import { describe, expect, test } from "vitest";
+import { getCadenceLabel } from "./helpers";
+
+describe("getCadenceLabel", () => {
+ test.each([
+ ["40 7 * * *", "Runs every day at 07:40"],
+ ["0 9 * * 1,3", "Runs every Monday, Wednesday at 09:00"],
+ ["0 9 1,15 * *", "Runs on day 1, 15 of every month at 09:00"],
+ ["0 9 1 * 1", "Runs on a schedule"],
+ ["not a cron", "Runs on a schedule"],
+ ])("%s -> %s", (cron, label) => {
+ expect(getCadenceLabel(cron)).toBe(label);
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.ts
new file mode 100644
index 0000000000..4b4aba732f
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/experts/[expertId]/components/ExpertWorkflowCard/helpers.ts
@@ -0,0 +1,9 @@
+import { safeHumanizeCronExpression } from "@/lib/cron-expression-utils";
+
+// The humanizer falls back to "Scheduled" or "Cron Expression: …", neither of
+// which reads after "Runs".
+export function getCadenceLabel(cron: string) {
+ const phrase = safeHumanizeCronExpression(cron);
+ if (!/^(Every|On day)\b/.test(phrase)) return "Runs on a schedule";
+ return `Runs ${phrase.charAt(0).toLowerCase()}${phrase.slice(1)}`;
+}
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 f549b7c378..c6a64449f2 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
@@ -200,6 +200,36 @@ describe("Marketplace expert page", () => {
);
});
+ test("says when a bundled workflow runs on a schedule, before hiring", async () => {
+ server.use(
+ getListExpertTemplatesMockHandler([
+ {
+ ...mariaTemplate,
+ workflows: [
+ { ...mariaTemplate.workflows[0], schedule_cron: "40 7 * * *" },
+ ],
+ },
+ ]),
+ getListExpertsMockHandler([]),
+ );
+
+ renderPage();
+
+ expect(await screen.findByText("Runs every day at 07:40")).toBeDefined();
+ });
+
+ test("says nothing about a cadence for a workflow that has none", async () => {
+ server.use(
+ getListExpertTemplatesMockHandler([mariaTemplate]),
+ getListExpertsMockHandler([]),
+ );
+
+ renderPage();
+
+ await screen.findByText("LinkedIn Post Generator");
+ expect(screen.queryByText(/^Runs /)).toBeNull();
+ });
+
test("renders the services, plan and disclosure sections", 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 2cb5e4a30e..424143d4e8 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
@@ -1171,6 +1171,36 @@ describe("TeamPage - setup needed card", () => {
).toBe("/library/agents/lib-1");
});
+ test("an input only the user can give is named, with the workflow to fill it in", async () => {
+ server.use(
+ getListExpertSetupItemsMockHandler([
+ makeSetupItem({
+ workflow_name: "Personal Newsletter",
+ providers: [],
+ resolution: "inputs",
+ missing_inputs: ["Email Address"],
+ }),
+ ]),
+ );
+
+ render(<TeamPage />);
+
+ const card = await screen.findByTestId("setup-needed");
+ expect(
+ within(card).getByText("Schedule Personal Newsletter for Maria"),
+ ).toBeDefined();
+ expect(
+ within(card).getByText(
+ "Needs Email Address before it can run on schedule.",
+ ),
+ ).toBeDefined();
+ expect(
+ within(card)
+ .getByRole("link", { name: "Open workflow" })
+ .getAttribute("href"),
+ ).toBe("/library/agents/lib-1");
+ });
+
test("a provider the user cannot connect is explained instead of offered", async () => {
server.use(
getListExpertSetupItemsMockHandler([
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/components/SetupNeededRow.tsx b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/components/SetupNeededRow.tsx
index 365837ff71..788e228d10 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/components/SetupNeededRow.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/components/SetupNeededRow.tsx
@@ -2,9 +2,9 @@ import type { ExpertSetupItem } from "@/app/api/__generated__/models/expertSetup
import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Text } from "@/components/atoms/Text/Text";
-import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";
import { Calendar03Icon } from "@hugeicons/core-free-icons";
+import { getSetupRowCopy, isCredentialItem } from "../helpers";
interface Props {
item: ExpertSetupItem;
@@ -22,9 +22,8 @@ export function SetupNeededRow({
onAllow,
}: Props) {
const provider = item.providers[0];
- const providerName = provider ? formatProviderName(provider) : "A service";
- const workflowName = item.workflow_name ?? "a workflow";
- const isCredential = item.resolution !== "workflow";
+ const isCredential = isCredentialItem(item);
+ const { title, detail } = getSetupRowCopy(item);
return (
<article className="flex items-center gap-2.5 rounded-2xl bg-white px-3.5 py-2.5 smooth-shadow-ring-sm">
@@ -44,14 +43,10 @@ export function SetupNeededRow({
as="span"
className="truncate !text-zinc-800"
>
- {isCredential
- ? `${providerName} for ${item.expert_name}`
- : `Schedule ${workflowName} for ${item.expert_name}`}
+ {title}
</Text>
<Text variant="small" as="span" className="truncate !text-zinc-400">
- {isCredential
- ? `${workflowName} needs it to run on schedule.`
- : "Every connection is in place; the schedule still has to be created."}
+ {detail}
</Text>
</div>
<div className="flex shrink-0 items-center">
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.test.ts
new file mode 100644
index 0000000000..c0d0ebba47
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.test.ts
@@ -0,0 +1,34 @@
+import type { ExpertSetupItem } from "@/app/api/__generated__/models/expertSetupItem";
+import { describe, expect, test } from "vitest";
+import { getSetupRowCopy } from "./helpers";
+
+function inputsItem(missing_inputs: string[]): ExpertSetupItem {
+ return {
+ expert_id: "expert-frankie",
+ expert_name: "Frankie",
+ expert_avatar_url: null,
+ workflow_id: "wf-1",
+ workflow_name: "Personal Newsletter",
+ library_agent_id: "lib-1",
+ providers: [],
+ resolution: "inputs",
+ missing_inputs,
+ };
+}
+
+describe("getSetupRowCopy for missing inputs", () => {
+ test.each([
+ [[], "Needs a few details from you before it can run on schedule."],
+ [["Email Address"], "Needs Email Address before it can run on schedule."],
+ [
+ ["Email Address", "Topic"],
+ "Needs Email Address and Topic before it can run on schedule.",
+ ],
+ [
+ ["Email Address", "Topic", "Send Time"],
+ "Needs Email Address, Topic and Send Time before it can run on schedule.",
+ ],
+ ])("%j", (missing, detail) => {
+ expect(getSetupRowCopy(inputsItem(missing)).detail).toBe(detail);
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.ts
new file mode 100644
index 0000000000..84904d5380
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/helpers.ts
@@ -0,0 +1,30 @@
+import type { ExpertSetupItem } from "@/app/api/__generated__/models/expertSetupItem";
+import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
+
+export function isCredentialItem(item: ExpertSetupItem) {
+ return item.resolution === "connect" || item.resolution === "allow";
+}
+
+export function getSetupRowCopy(item: ExpertSetupItem) {
+ const workflowName = item.workflow_name ?? "a workflow";
+ if (isCredentialItem(item)) {
+ const provider = item.providers[0];
+ return {
+ title: `${provider ? formatProviderName(provider) : "A service"} for ${item.expert_name}`,
+ detail: `${workflowName} needs it to run on schedule.`,
+ };
+ }
+ return {
+ title: `Schedule ${workflowName} for ${item.expert_name}`,
+ detail:
+ item.resolution === "inputs"
+ ? `Needs ${formatInputList(item.missing_inputs ?? [])} before it can run on schedule.`
+ : "Every connection is in place; the schedule still has to be created.",
+ };
+}
+
+function formatInputList(names: string[]) {
+ if (names.length === 0) return "a few details from you";
+ if (names.length === 1) return names[0];
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
+}
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index d0cfdbca67..1f0addbae6 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -20988,12 +20988,17 @@
},
"resolution": {
"type": "string",
- "enum": ["connect", "allow", "workflow"],
+ "enum": ["connect", "allow", "inputs", "workflow"],
"title": "Resolution"
},
"credential_id": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Credential Id"
+ },
+ "missing_inputs": {
+ "items": { "type": "string" },
+ "type": "array",
+ "title": "Missing Inputs"
}
},
"type": "object",
@@ -21008,7 +21013,7 @@
"resolution"
],
"title": "ExpertSetupItem",
- "description": "One thing standing between a scheduled workflow and its schedule.\n\nRendered on the Team page as a row with a single fix. ``connect``: the\nuser has no credential for any of ``providers``. ``allow``: they have one\n(``credential_id``) that this expert may not use yet. ``workflow``: no\ncredential is missing, so the schedule needs creating from the workflow."
+ "description": "One thing standing between a scheduled workflow and its schedule.\n\nRendered on the Team page as a row with a single fix. ``connect``: the\nuser has no credential for any of ``providers``. ``allow``: they have one\n(``credential_id``) that this expert may not use yet. ``inputs``: the\nworkflow needs the values in ``missing_inputs`` before it can run\nunattended. ``workflow``: nothing is missing, so the schedule needs\ncreating from the workflow."
},
"ExpertSkillsUpdate": {
"properties": {