Set by a parameter
diff --git a/nextjs-frontend/components/workflows/workflow-editor.tsx b/nextjs-frontend/components/workflows/workflow-editor.tsx
index ffacd60e8..9a2e69d39 100644
--- a/nextjs-frontend/components/workflows/workflow-editor.tsx
+++ b/nextjs-frontend/components/workflows/workflow-editor.tsx
@@ -6,7 +6,7 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect, useMemo, useRef, useState } from "react";
-import { Activities, Automations, Fields, Workflows } from "@/app/openapi-client";
+import { Activities, Automations, Feeds, Fields, Workflows } from "@/app/openapi-client";
import type { TemplateSummary, Workflow, WorkflowTry } from "@/app/openapi-client/types.gen";
import { useTemplateList, useWorkflowCatalog } from "@/components/pipelines/catalog-header";
import { RunDialog } from "@/components/pipelines/pipeline-editor";
@@ -120,6 +120,13 @@ export function WorkflowEditor({ id }: { id?: number }) {
);
const named = name.trim() || guess;
const problems = findProblems(graph, (tid) => tpl.get(tid)?.kind, scope, "workflow", customOf, actionDefs);
+ // The feeds a Publish to feed or Podcast episode node can add to, named on the canvas (graph workflows only).
+ const feeds = useQuery({
+ queryKey: ["feeds", "list", null],
+ queryFn: () => data(Feeds.listFeeds({ client })),
+ enabled: scope === "graph",
+ staleTime: 60_000,
+ });
const firstProblem = Object.entries(problems)[0];
const nextV = latest + 1;
const publishReason =
@@ -453,6 +460,8 @@ export function WorkflowEditor({ id }: { id?: number }) {
fields={fields}
trace={tried?.trace}
onSaveAsCustom={saveAsCustom}
+ feeds={scope === "graph" ? (feeds.data ?? []) : undefined}
+ namespaces={scope === "graph" ? namespaces.map((n) => n.name) : undefined}
actions={actionDefs}
emptyPanel={
scope === "event" ? (
@@ -480,6 +489,10 @@ export function WorkflowEditor({ id }: { id?: number }) {
may be one thing, Ask the model judges each pair, and Apply changes merges or links the sure ones and
proposes the rest.
+
+ It also publishes: Select assets or Select activities picks what came in since the routine last ran,
+ Publish to feed adds it to a feed, and Podcast episode makes an episode about it.
+
Run it from a routine. Proposed changes wait in Routines → Proposed changes, and every change can be
undone. Try it runs it now and keeps nothing.
diff --git a/nextjs-frontend/components/workflows/workflow-model.ts b/nextjs-frontend/components/workflows/workflow-model.ts
index f139f1510..032494a13 100644
--- a/nextjs-frontend/components/workflows/workflow-model.ts
+++ b/nextjs-frontend/components/workflows/workflow-model.ts
@@ -9,6 +9,8 @@ import {
Bolt,
CheckCheck,
FileText,
+ FolderSearch,
+ History,
Group,
ListFilter,
ListTree,
@@ -22,6 +24,8 @@ import {
Milestone,
Network,
PlayCircle,
+ Podcast,
+ Rss,
Save,
ScanSearch,
SearchCheck,
@@ -395,6 +399,73 @@ export const NODES: Record = {
gives: "merges · links · proposals",
group: "Keep",
},
+ // Publishing from the graph (feed_nodes.py): what came in, to a feed or into an episode
+ select_assets: {
+ label: "Select assets",
+ describe:
+ "The resources that came in since the routine last ran (or in the past day, week or month), newest first, in its namespaces",
+ icon: FolderSearch,
+ tone: "green",
+ inputs: 1,
+ outputs: ["out"],
+ takes: "namespaces",
+ gives: "resources[]",
+ group: "Data",
+ },
+ select_activities: {
+ label: "Select activities",
+ describe:
+ "What happened on the timeline since the routine last ran, of the kinds you pick: resources added, imports, changes",
+ icon: History,
+ tone: "green",
+ inputs: 1,
+ outputs: ["out"],
+ takes: "namespaces",
+ gives: "activities[]",
+ group: "Data",
+ },
+ publish_feed: {
+ label: "Publish to feed",
+ describe:
+ "Adds what comes in to a feed: resources and episodes, timeline activities, or text; what’s there already isn’t added twice",
+ icon: Rss,
+ tone: "gold",
+ inputs: 1,
+ outputs: [],
+ takes: "resources[] · activities[] · text",
+ gives: "items in the feed",
+ group: "Keep",
+ },
+ podcast_episode: {
+ label: "Podcast episode",
+ describe:
+ "Makes a two-host episode about the resources that come in, cited and fact-checked, and adds it to a feed once it’s made",
+ icon: Podcast,
+ tone: "gold",
+ inputs: 1,
+ outputs: [],
+ takes: "resources[]",
+ gives: "an episode",
+ group: "Keep",
+ },
+};
+
+/** When Select assets and Select activities look back, as the canvas says it. */
+export const SINCE: Record = {
+ last_run: "since the routine last ran",
+ day: "the past day",
+ week: "the past week",
+ month: "the past month",
+ all: "everything",
+};
+/** The most a Select node passes on. */
+export const SELECT_LIMITS: Record = { select_assets: 500, select_activities: 200 };
+/** Styles of a podcast episode, as Podcasts names them. */
+export const EPISODE_STYLES: Record = {
+ "deep-dive": "Deep dive",
+ recap: "Quick recap",
+ debate: "Compare and contrast",
+ beginner: "For a beginner",
};
/** The start of a graph workflow: the namespaces a routine runs it over. */
@@ -445,7 +516,16 @@ export const PRIMITIVES = [
/** Node types per scope, for when the catalog hasn't said (it lists each type's scopes). */
const SCOPE_NODES: Record = {
recording: [...PRIMITIVES, "extract_rules", "extract_llm", "save_entities", "llm", "classify", "output", "field"],
- graph: [...PRIMITIVES, "candidates", "llm_judge", "apply_changes"],
+ graph: [
+ ...PRIMITIVES,
+ "candidates",
+ "llm_judge",
+ "apply_changes",
+ "select_assets",
+ "select_activities",
+ "publish_feed",
+ "podcast_episode",
+ ],
tool: [...PRIMITIVES, "ask_model", "call_tool"],
event: [...PRIMITIVES, "action", "decide"],
};
@@ -457,6 +537,8 @@ export function inScope(type: string, scope: Scope, catalog?: { type: string; sc
}
export const GROUPS = ["Entities", "AI", "Logic", "Data", "Loops", "Keep"] as const;
+/** The nodes a graph workflow ends in: they change the graph or publish from it. */
+export const GRAPH_KEEPS = ["apply_changes", "publish_feed", "podcast_episode"];
/** An action as the actions catalog (GET /api/v1/automations/actions) lists it: enough to set one up and say what it
* reaches. */
export type ActionDef = {
@@ -496,7 +578,7 @@ export function wouldDo(i: Record, actions?: ActionDef[]): stri
/** An action node waits before it acts: for a delay, or until a time. */
export const waits = (n: WfNode) => n.config.delay != null || n.config.when != null;
/** Nodes that keep something: a workflow needs one (or a node that keeps something as set up, see savesAsSet). */
-export const KEEPS = ["output", "field", "save_entities", "apply_changes"];
+export const KEEPS = ["output", "field", "save_entities", ...GRAPH_KEEPS];
/** A node that keeps something only as it's set up: a classify node that acts on a sure answer. */
export const savesAsSet = (n: WfNode) => n.type === "classify" && Boolean(n.config.apply);
/** What a classify node chooses from. */
@@ -605,6 +687,8 @@ export function defaultConfig(type: string): Record {
if (type === "output") return { key: "" };
if (type === "candidates") return { kind: "merge", min_confidence: 0.7, limit: 100 };
if (type === "llm_judge") return { batch: 25 };
+ if (type === "select_assets" || type === "select_activities") return { since: "last_run", limit: 50 };
+ if (type === "podcast_episode") return { length: 10, style: "deep-dive" };
if (type === "filter") return { path: "verdict.same", op: "equals", value: true };
if (type === "switch") return { cases: [{ port: "first", op: "exists" }] };
if (type === "set") return { fields: [{ key: "value", path: "" }] };
@@ -887,6 +971,7 @@ export function nodeSummary(
template: (id: number) => string | undefined;
field: (id: number) => string | undefined;
custom?: (id: number) => CustomDef | undefined;
+ feed?: (id: number) => string | undefined;
actions?: ActionDef[];
},
) {
@@ -1004,6 +1089,25 @@ export function nodeSummary(
return c.apply_above == null
? "Propose every change"
: `Make ${Math.round(Number(c.apply_above) * 100)}%+ (up to ${Number(c.max_apply ?? 50)}), propose the rest`;
+ case "select_assets":
+ case "select_activities":
+ return [
+ SINCE[String(c.since ?? "last_run")] ?? String(c.since),
+ `up to ${Number(c.limit ?? 50)}`,
+ ...(n.type === "select_activities" && (c.kinds as string[] | undefined)?.length
+ ? [(c.kinds as string[]).join(", ")]
+ : []),
+ ...(c.q ? [`“${String(c.q)}”`] : []),
+ ...((c.namespaces as string[] | undefined)?.length ? [`in ${(c.namespaces as string[]).join(", ")}`] : []),
+ ].join(" · ");
+ case "publish_feed":
+ return c.feed == null ? "Choose a feed" : `to ${names.feed?.(Number(c.feed)) ?? `feed #${c.feed}`}`;
+ case "podcast_episode":
+ return [
+ `about ${Number(c.length ?? 10)} minutes`,
+ EPISODE_STYLES[String(c.style ?? "deep-dive")] ?? String(c.style),
+ ...(c.feed == null ? [] : [`to ${names.feed?.(Number(c.feed)) ?? `feed #${c.feed}`}`]),
+ ].join(" · ");
default:
return ref ? `‹${ref[0]} from a parameter›` : (NODES[n.type]?.describe ?? "");
}
@@ -1171,6 +1275,26 @@ export function problems(
else if (n.type === "apply_changes" && !between(c.apply_above, 0, 1, false))
fail("Sure enough at is a number from 0 to 1.");
else if (n.type === "apply_changes" && !between(c.max_apply, 0, 1000, true)) fail("At most is 0 to 1000.");
+ else if (
+ (n.type === "select_assets" || n.type === "select_activities") &&
+ c.since != null &&
+ !SINCE[String(c.since)]
+ )
+ fail("Since is the last run, the past day, week or month, or everything.");
+ else if (n.type === "select_assets" && !between(c.limit, 1, SELECT_LIMITS.select_assets, true))
+ fail(`At most is 1 to ${SELECT_LIMITS.select_assets} resources.`);
+ else if (n.type === "select_activities" && !between(c.limit, 1, SELECT_LIMITS.select_activities, true))
+ fail(`At most is 1 to ${SELECT_LIMITS.select_activities} activities.`);
+ else if (n.type === "publish_feed" && c.feed == null) fail("Choose a feed.");
+ else if (n.type === "podcast_episode" && !between(c.length, 1, 180, true)) fail("Length is 1 to 180 minutes.");
+ else if (n.type === "podcast_episode" && c.style != null && !EPISODE_STYLES[String(c.style)])
+ fail("Choose a style.");
+ else if (n.type === "podcast_episode" && !between(c.max_sources, 1, 20, true)) fail("Most sources is 1 to 20.");
+ else if (
+ n.type === "podcast_episode" &&
+ !between(c.min_sources, 1, typeof c.max_sources === "number" ? c.max_sources : 20, true)
+ )
+ fail("Fewest sources is 1 to the most.");
else if (n.type === "for_each" && !between(c.max_items, 1, 1000, true)) fail("At most is 1 to 1000 items.");
else if (n.type === "repeat" && !between(c.max_rounds, 1, 50, true)) fail("At most is 1 to 50 rounds.");
else if (n.type === "extract_rules") {
@@ -1207,7 +1331,7 @@ export function problems(
if (kind === "workflow" && !out[""] && !keeps(g, custom, scope))
out[""] =
scope === "graph"
- ? "Add an Apply changes node, or the workflow changes nothing."
+ ? "Add an Apply changes, Publish to feed or Podcast episode node, or the workflow changes nothing."
: scope === "event"
? "Add an action, or the automation does nothing."
: "Add a Save output, Set field or Save entities node (or a Classify node that acts), or the workflow keeps nothing.";
@@ -1217,7 +1341,7 @@ export function problems(
/** Whether a graph keeps something: a saving node here, inside a body, or in a custom node. */
function keeps(g: WfGraph, custom?: (id: number) => CustomDef | undefined, scope: Scope = "recording"): boolean {
const saving =
- scope === "graph" ? ["apply_changes"] : scope === "event" ? ["action"] : KEEPS.filter((t) => t !== "apply_changes");
+ scope === "graph" ? GRAPH_KEEPS : scope === "event" ? ["action"] : KEEPS.filter((t) => !GRAPH_KEEPS.includes(t));
return g.nodes.some(
(n) =>
saving.includes(n.type) ||