Files
pj0333-full-duplex/taskfile.yaml
T
u9g 07a75c4369 post_create: skip the install hint when deps already installed (#91)
The 'uv sync' next-step is redundant when the LiveKit CLI already ran the
install task during `lk agent init --install`. Move it into a guarded subtask
that is skipped when LIVEKIT_DEPS_INSTALLED is set (the CLI sets it on a
successful install), matching the existing status-guard pattern used for
LIVEKIT_AGENT_NAME and LIVEKIT_SANDBOX_ID.
2026-06-24 15:16:24 -04:00

94 lines
2.9 KiB
YAML

version: "3"
dotenv: [".env.local"]
vars:
INDENT: 4
REL_PATH: "{{ relPath .USER_WORKING_DIR .ROOT_DIR }}"
VENV_DIR: ".venv"
PYTHON_MAIN: '{{ joinPath "./src" "agent.py" }}'
tasks:
post_create:
desc: "Runs after this template is instantiated as a Sandbox or Bootstrap"
cmds:
- echo 'Your agent has been created!'
- task: help_run_console
- task: help_open_web_console
- echo ''
- echo 'To deploy your agent to LiveKit cloud:'
- echo ''
- echo '{{ indent .INDENT "lk agent deploy" }}'
- echo ''
- task: set_agent_name_if_present
- task: help_open_sandbox_if_present
help_install_hint_if_needed:
desc: "Print the local install hint, unless the CLI already installed dependencies"
status:
# Skip when `lk agent init --install` already ran the install task.
- test -n "$LIVEKIT_DEPS_INSTALLED"
cmds:
- echo '{{ indent .INDENT "uv sync" }}'
set_agent_name_if_present:
status:
- test -z "$LIVEKIT_AGENT_NAME"
cmds:
- |
old='agent_name="my-agent"'
new='agent_name="{{ .LIVEKIT_AGENT_NAME }}"'
file="{{ .PYTHON_MAIN }}"
tmp="$(mktemp)"
while IFS= read -r line; do
printf '%s\n' "${line//$old/$new}" >> "$tmp"
done < "$file"
mv "$tmp" "$file"
help_run_console:
status:
- test -n "$LIVEKIT_AGENT_NAME"
cmds:
- echo 'To try your new agent directly in your terminal:'
- echo ''
- echo '{{ indent .INDENT "cd" }} {{ .REL_PATH }}'
- task: help_install_hint_if_needed
- echo '{{ indent .INDENT "uv run" }} {{ .PYTHON_MAIN }} console'
help_open_web_console:
status:
- test -z "$LIVEKIT_AGENT_NAME"
vars:
CONSOLE_URL: "https://cloud.livekit.io/projects/p_/agents/console"
CONSOLE_LINK: '{{ print "\x1b]8;;" .CONSOLE_URL "/?autoStart=true&agentName=" .LIVEKIT_AGENT_NAME "\x1b\\\x1b[36;4m" .CONSOLE_URL "/?autoStart=true&agentName=" .LIVEKIT_AGENT_NAME "\x1b[0m\x1b]8;;\x1b\\" }}'
cmds:
- echo 'To try your new agent in the web console:'
- echo ''
- echo '{{ indent .INDENT "cd" }} {{ .REL_PATH }}'
- task: help_install_hint_if_needed
- echo '{{ indent .INDENT "uv run" }} {{ .PYTHON_MAIN }} dev'
- echo ''
- echo 'Then visit:'
- echo ''
- echo '{{ indent .INDENT .CONSOLE_LINK }}'
help_open_sandbox_if_present:
status:
- test -z "$LIVEKIT_SANDBOX_ID"
vars:
SANDBOX_URL: 'https://{{ .LIVEKIT_SANDBOX_ID }}.sandbox.livekit.io'
SANDBOX_LINK: '{{ print "\x1b]8;;" .SANDBOX_URL "\x1b\\\x1b[36;4m" .SANDBOX_URL "\x1b[0m\x1b]8;;\x1b\\" }}'
cmds:
- echo 'To chat with your running agent, visit:'
- echo ''
- echo '{{ indent .INDENT .SANDBOX_LINK }}'
- echo ''
install:
desc: "Bootstrap application for local development"
cmds:
- "uv sync"
dev:
interactive: true
cmds:
- "uv run src/agent.py dev"