mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-16 09:31:37 +00:00
refactor(cron): rebrand Cron Recipes -> Automation Blueprints
Product rename across every surface: module/file names (blueprint_catalog, tools/blueprints, blueprint_cmd), slash command /cron-recipe -> /blueprint (alias /bp), dashboard API /api/cron/blueprints, desktop deep-link hermes://blueprint/<key>, docs catalog page + extract script, and the skill frontmatter block metadata.hermes.blueprint. No behavior change.
This commit is contained in:
parent
3c489fda81
commit
cb29e8a82e
29 changed files with 627 additions and 627 deletions
|
|
@ -10,19 +10,19 @@ import { Badge } from "@nous-research/ui/ui/components/badge";
|
|||
import { useToast } from "@nous-research/ui/hooks/use-toast";
|
||||
import { Toast } from "@nous-research/ui/ui/components/toast";
|
||||
import { api } from "@/lib/api";
|
||||
import type { CronRecipe, CronRecipeField } from "@/lib/api";
|
||||
import type { AutomationBlueprint, AutomationBlueprintField } from "@/lib/api";
|
||||
import { cn, themedBody } from "@/lib/utils";
|
||||
|
||||
interface CronRecipesProps {
|
||||
interface AutomationBlueprintsProps {
|
||||
profile: string;
|
||||
/** Called after a recipe is instantiated so the parent can refresh its job list. */
|
||||
/** Called after a blueprint is instantiated so the parent can refresh its job list. */
|
||||
onCreated?: () => void;
|
||||
}
|
||||
|
||||
/** Initial form values for a recipe = each field's default (or ""). */
|
||||
function initialValues(recipe: CronRecipe): Record<string, string> {
|
||||
/** Initial form values for a blueprint = each field's default (or ""). */
|
||||
function initialValues(blueprint: AutomationBlueprint): Record<string, string> {
|
||||
const out: Record<string, string> = {};
|
||||
for (const f of recipe.fields) out[f.name] = f.default ?? "";
|
||||
for (const f of blueprint.fields) out[f.name] = f.default ?? "";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ function FieldInput({
|
|||
value,
|
||||
onChange,
|
||||
}: {
|
||||
field: CronRecipeField;
|
||||
field: AutomationBlueprintField;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
}) {
|
||||
|
|
@ -66,19 +66,19 @@ function FieldInput({
|
|||
);
|
||||
}
|
||||
|
||||
function RecipeCard({
|
||||
recipe,
|
||||
function BlueprintCard({
|
||||
blueprint,
|
||||
profile,
|
||||
showToast,
|
||||
onCreated,
|
||||
}: {
|
||||
recipe: CronRecipe;
|
||||
blueprint: AutomationBlueprint;
|
||||
profile: string;
|
||||
showToast: (message: string, type: "error" | "success") => void;
|
||||
onCreated?: () => void;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [values, setValues] = useState<Record<string, string>>(() => initialValues(recipe));
|
||||
const [values, setValues] = useState<Record<string, string>>(() => initialValues(blueprint));
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
|
|
@ -86,11 +86,11 @@ function RecipeCard({
|
|||
setSubmitting(true);
|
||||
setError(null);
|
||||
try {
|
||||
const job = await api.instantiateCronRecipe({ recipe: recipe.key, values }, profile);
|
||||
const job = await api.instantiateAutomationBlueprint({ blueprint: blueprint.key, values }, profile);
|
||||
const when = job.schedule_display ? ` — ${job.schedule_display}` : "";
|
||||
showToast(`${recipe.title} scheduled${when}`, "success");
|
||||
showToast(`${blueprint.title} scheduled${when}`, "success");
|
||||
setOpen(false);
|
||||
setValues(initialValues(recipe));
|
||||
setValues(initialValues(blueprint));
|
||||
onCreated?.();
|
||||
} catch (e) {
|
||||
// 422 from the API carries the slot-level validation message.
|
||||
|
|
@ -99,7 +99,7 @@ function RecipeCard({
|
|||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
}, [recipe, values, profile, showToast, onCreated]);
|
||||
}, [blueprint, values, profile, showToast, onCreated]);
|
||||
|
||||
return (
|
||||
<Card className={cn("overflow-hidden", themedBody)}>
|
||||
|
|
@ -108,11 +108,11 @@ function RecipeCard({
|
|||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<Wand2 className="h-4 w-4 shrink-0 opacity-70" />
|
||||
<span className="font-medium">{recipe.title}</span>
|
||||
<span className="font-medium">{blueprint.title}</span>
|
||||
</div>
|
||||
<p className="mt-1 text-sm opacity-70">{recipe.description}</p>
|
||||
<p className="mt-1 text-sm opacity-70">{blueprint.description}</p>
|
||||
<div className="mt-2 flex flex-wrap gap-1">
|
||||
{recipe.tags.map((t) => (
|
||||
{blueprint.tags.map((t) => (
|
||||
<Badge key={t} tone="secondary">
|
||||
{t}
|
||||
</Badge>
|
||||
|
|
@ -130,9 +130,9 @@ function RecipeCard({
|
|||
|
||||
{open && (
|
||||
<div className="space-y-3 border-t pt-3">
|
||||
{recipe.fields.map((f) => (
|
||||
{blueprint.fields.map((f) => (
|
||||
<div key={f.name} className="space-y-1">
|
||||
<Label htmlFor={`${recipe.key}-${f.name}`}>{f.label}</Label>
|
||||
<Label htmlFor={`${blueprint.key}-${f.name}`}>{f.label}</Label>
|
||||
<FieldInput
|
||||
field={f}
|
||||
value={values[f.name] ?? ""}
|
||||
|
|
@ -162,22 +162,22 @@ function RecipeCard({
|
|||
}
|
||||
|
||||
/**
|
||||
* Cron Recipes gallery — the form-where-there's-a-screen surface. Each recipe
|
||||
* Automation Blueprints gallery — the form-where-there's-a-screen surface. Each blueprint
|
||||
* card expands into an inline form (one field per typed slot); submitting POSTs
|
||||
* to /api/cron/recipes/instantiate which fills the recipe and creates the job
|
||||
* to /api/cron/blueprints/instantiate which fills the blueprint and creates the job
|
||||
* via the same create_job path as everything else.
|
||||
*/
|
||||
export function CronRecipes({ profile, onCreated }: CronRecipesProps) {
|
||||
export function AutomationBlueprints({ profile, onCreated }: AutomationBlueprintsProps) {
|
||||
const { toast, showToast } = useToast();
|
||||
const [recipes, setRecipes] = useState<CronRecipe[] | null>(null);
|
||||
const [blueprints, setBlueprints] = useState<AutomationBlueprint[] | null>(null);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
api
|
||||
.getCronRecipes()
|
||||
.getAutomationBlueprints()
|
||||
.then((r) => {
|
||||
if (!cancelled) setRecipes(r.recipes);
|
||||
if (!cancelled) setBlueprints(r.blueprints);
|
||||
})
|
||||
.catch((e) => {
|
||||
if (!cancelled) setLoadError(e instanceof Error ? e.message : String(e));
|
||||
|
|
@ -188,27 +188,27 @@ export function CronRecipes({ profile, onCreated }: CronRecipesProps) {
|
|||
}, []);
|
||||
|
||||
if (loadError) {
|
||||
return <p className="text-sm text-red-500">Couldn't load recipes: {loadError}</p>;
|
||||
return <p className="text-sm text-red-500">Couldn't load blueprints: {loadError}</p>;
|
||||
}
|
||||
if (recipes === null) {
|
||||
if (blueprints === null) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 opacity-70">
|
||||
<Spinner className="h-4 w-4" /> Loading recipes…
|
||||
<Spinner className="h-4 w-4" /> Loading blueprints…
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (recipes.length === 0) {
|
||||
return <p className="opacity-70">No cron recipes available.</p>;
|
||||
if (blueprints.length === 0) {
|
||||
return <p className="opacity-70">No automation blueprints available.</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Toast toast={toast} />
|
||||
<div className="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
{recipes.map((r) => (
|
||||
<RecipeCard
|
||||
{blueprints.map((r) => (
|
||||
<BlueprintCard
|
||||
key={r.key}
|
||||
recipe={r}
|
||||
blueprint={r}
|
||||
profile={profile}
|
||||
showToast={showToast}
|
||||
onCreated={onCreated}
|
||||
|
|
@ -219,4 +219,4 @@ export function CronRecipes({ profile, onCreated }: CronRecipesProps) {
|
|||
);
|
||||
}
|
||||
|
||||
export default CronRecipes;
|
||||
export default AutomationBlueprints;
|
||||
|
|
@ -497,14 +497,14 @@ export const api = {
|
|||
deleteCronJob: (id: string, profile = "default") =>
|
||||
fetchJSON<{ ok: boolean }>(`/api/cron/jobs/${encodeURIComponent(id)}?profile=${encodeURIComponent(profile)}`, { method: "DELETE" }),
|
||||
|
||||
// Cron Recipes — parameterized automation templates
|
||||
getCronRecipes: () =>
|
||||
fetchJSON<{ recipes: CronRecipe[] }>("/api/cron/recipes"),
|
||||
instantiateCronRecipe: (
|
||||
body: { recipe: string; values: Record<string, string> },
|
||||
// Automation Blueprints — parameterized automation templates
|
||||
getAutomationBlueprints: () =>
|
||||
fetchJSON<{ blueprints: AutomationBlueprint[] }>("/api/cron/blueprints"),
|
||||
instantiateAutomationBlueprint: (
|
||||
body: { blueprint: string; values: Record<string, string> },
|
||||
profile = "default",
|
||||
) =>
|
||||
fetchJSON<CronJob>(`/api/cron/recipes/instantiate?profile=${encodeURIComponent(profile)}`, {
|
||||
fetchJSON<CronJob>(`/api/cron/blueprints/instantiate?profile=${encodeURIComponent(profile)}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
|
|
@ -1838,7 +1838,7 @@ export interface CronDeliveryTarget {
|
|||
home_env_var: string | null;
|
||||
}
|
||||
|
||||
export interface CronRecipeField {
|
||||
export interface AutomationBlueprintField {
|
||||
name: string;
|
||||
type: "time" | "enum" | "text" | "weekdays";
|
||||
label: string;
|
||||
|
|
@ -1850,13 +1850,13 @@ export interface CronRecipeField {
|
|||
help: string;
|
||||
}
|
||||
|
||||
export interface CronRecipe {
|
||||
export interface AutomationBlueprint {
|
||||
key: string;
|
||||
title: string;
|
||||
description: string;
|
||||
category: string;
|
||||
tags: string[];
|
||||
fields: CronRecipeField[];
|
||||
fields: AutomationBlueprintField[];
|
||||
command: string;
|
||||
appUrl: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import { useI18n } from "@/i18n";
|
|||
import { usePageHeader } from "@/contexts/usePageHeader";
|
||||
import { PluginSlot } from "@/plugins";
|
||||
import { Segmented } from "@nous-research/ui/ui/components/segmented";
|
||||
import { CronRecipes } from "@/components/CronRecipes";
|
||||
import { AutomationBlueprints } from "@/components/AutomationBlueprints";
|
||||
import { cn, themedBody } from "@/lib/utils";
|
||||
|
||||
function formatTime(iso?: string | null): string {
|
||||
|
|
@ -178,7 +178,7 @@ export default function CronPage() {
|
|||
const [jobs, setJobs] = useState<CronJob[]>([]);
|
||||
const [profiles, setProfiles] = useState<ProfileInfo[]>([]);
|
||||
const [selectedProfile, setSelectedProfile] = useState("all");
|
||||
const [view, setView] = useState<"jobs" | "recipes">("jobs");
|
||||
const [view, setView] = useState<"jobs" | "blueprints">("jobs");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const { toast, showToast } = useToast();
|
||||
const { t, locale } = useI18n();
|
||||
|
|
@ -512,15 +512,15 @@ export default function CronPage() {
|
|||
|
||||
<Segmented
|
||||
value={view}
|
||||
onChange={(v) => setView(v as "jobs" | "recipes")}
|
||||
onChange={(v) => setView(v as "jobs" | "blueprints")}
|
||||
options={[
|
||||
{ value: "jobs", label: "Jobs" },
|
||||
{ value: "recipes", label: "Recipes" },
|
||||
{ value: "blueprints", label: "Blueprints" },
|
||||
]}
|
||||
/>
|
||||
|
||||
{view === "recipes" && (
|
||||
<CronRecipes
|
||||
{view === "blueprints" && (
|
||||
<AutomationBlueprints
|
||||
profile={selectedProfile === "all" ? "default" : selectedProfile}
|
||||
onCreated={loadJobs}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue