{#if kind === 'script'}
{
selectedKind = 'script'
}}
/>
{#if toolMode}
{
dispatch('pickMcpTool')
dispatch('close')
}}
/>
{
dispatch('pickWebsearchTool')
dispatch('close')
}}
/>
{#if allowAiAgentTool}
{
dispatch('pickAiAgentTool')
dispatch('close')
}}
/>
{/if}
{:else}
{#if customUi?.triggers != false && allowTrigger}
{
selectedKind = 'trigger'
}}
/>
{/if}
{
selectedKind = 'approval'
}}
/>
{#if customUi?.flowNode != false}
{
selectedKind = 'flow'
}}
/>
{/if}
{#if stop}
{
selectedKind = 'script'
}}
/>
{/if}
{
dispatch('close')
dispatch('new', { kind: 'forloop' })
}}
/>
{
dispatch('close')
dispatch('new', { kind: 'whileloop' })
}}
/>
{
dispatch('close')
dispatch('new', { kind: 'branchone' })
}}
/>
{
dispatch('close')
dispatch('new', { kind: 'branchall' })
}}
/>
{#if customUi?.aiAgent != false}
{
selectedKind = 'aiagent'
selectedByKeyboard = 0
loadSavedAgents()
// Clicking leaves focus on this button, where Enter would only re-select it.
stepGen?.focus()
}}
/>
{/if}
{#if customUi?.aiSandbox != false}
{
selectedKind = 'aisandbox'
selectedByKeyboard = 0
stepGen?.focus()
}}
/>
{/if}
{/if}
{/if}
{#if selectedKind === 'aiagent'}
(selectedByKeyboard = 0)}
role="menuitem"
variant="subtle"
unifiedSize="sm"
btnClasses="justify-start {aiSelected === 0
? 'bg-surface-hover'
: 'hover:bg-transparent'}"
>
Blank AI agent
{#if aiSelected === 0}
↵
{/if}
{#if savedAgentsLoading}
Loading saved agents
{:else if filteredAgents.length > 0}
Saved agents
{#each filteredAgents as agent, i (agent.path)}
newLinkedAgent(agent.path)}
onmousemove={() => (selectedByKeyboard = i + 1)}
role="menuitem"
variant="subtle"
unifiedSize="sm"
btnClasses="justify-start {aiSelected === i + 1
? 'bg-surface-hover'
: 'hover:bg-transparent'}"
title={agent.description || agent.path}
>
{agent.path}
{#if aiSelected === i + 1}
↵
{/if}
{/each}
{:else}
{savedAgents.length > 0
? 'No saved agent matches this search'
: 'No saved agent in this workspace yet. Configure a blank one, then Save as reusable agent to reuse it.'}
{/if}
{:else if selectedKind === 'aisandbox'}
(selectedByKeyboard = 0)}
/>
{:else}
{
dispatch('close')
}}
on:new
on:pickScript
on:pickFlow
{preFilter}
{displayPath}
refreshCount={refreshCount.val}
/>
{/if}