Files
windmill/frontend/src/lib/components/flows/agentActions.ts
T
hugocasaandClaude Opus 5.5 fe2571ea53 feat: list agents with runnables, let them be starred, and fill out their menu (#11651)
* feat: star agents and add runs, audit logs and copy path to their menu

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

* fix: list an agent's runs as the previews they are

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

* feat: list agents in the merged runnables stream so they sort with everything else

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

* perf: index agent paths so the merged listing and owner counts skip other resources

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

* feat: find agents in the ctrl+k search

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

* feat: open an agent's version history from its menu

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vo7HXMdgqXJhR7p8YyVgjB

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 08:59:01 +00:00

85 lines
2.7 KiB
TypeScript

import { Copy, Eye, FileUp, History, List, Shield, Trash } from 'lucide-svelte'
import { ResourceService } from '$lib/gen'
import { sendUserToast } from '$lib/toast'
import { copyToClipboard, type Item } from '$lib/utils'
import { isDeployable } from '$lib/utils_deployable'
import { goto } from '$lib/navigation'
import type { WorkspaceDeployUISettings } from '$lib/gen'
/** Deletes a saved agent, saying how it went. Resolves whether it was deleted. */
export async function deleteAgent(workspace: string, path: string): Promise<boolean> {
try {
await ResourceService.deleteResource({ workspace, path })
sendUserToast(`Deleted agent ${path}`)
return true
} catch (err) {
sendUserToast(`Could not delete agent ${path}: ${err}`, true)
return false
}
}
/** An agent's menu, as its home row and its page both show it. */
export function agentMenuItems(agent: {
path: string
canWrite: boolean
/** Never deployed: no resource yet to hold permissions or to deploy onward. */
draftOnly?: boolean
wsSpecific?: boolean
/** Hides what an operator has no page for, as on a flow's menu. */
operator?: boolean
/** Undefined until loaded, when nothing is offered for deploy. */
deployUiSettings: WorkspaceDeployUISettings | undefined
onPermissions: () => void
onDeploy: () => void
onHistory: () => void
onDelete: (event?: MouseEvent) => void
}): Item[] {
const deployable =
!agent.wsSpecific &&
!agent.draftOnly &&
isDeployable('resource', agent.path, agent.deployUiSettings)
return [
// A draft-only agent has no runs, no audit trail, and only a placeholder path yet.
...(agent.draftOnly
? []
: [
{
// An agent run is a flow preview, which the runs page hides by default. Chat turns
// are filed under `<path>.chat` (agent_runs.rs) and listed by the agent's own chat.
displayName: 'View runs',
icon: List,
action: () => goto(`/runs/${agent.path}?job_kinds=previews`)
},
...(agent.operator
? []
: [
{
displayName: 'Audit logs',
icon: Eye,
action: () => goto(`/audit_logs?resource=${agent.path}`)
}
]),
{ displayName: 'Copy path', icon: Copy, action: () => copyToClipboard(agent.path) }
]),
{
displayName: 'Permissions',
icon: Shield,
disabled: !agent.canWrite || Boolean(agent.draftOnly),
action: agent.onPermissions
},
...(deployable
? [{ displayName: 'Deploy to prod/staging', icon: FileUp, action: agent.onDeploy }]
: []),
...(agent.draftOnly || agent.operator
? []
: [{ displayName: 'Version history', icon: History, action: agent.onHistory }]),
{
displayName: 'Delete',
icon: Trash,
type: 'delete' as const,
disabled: !agent.canWrite,
action: agent.onDelete
}
]
}