Skip to content

Commit 7953fd9

Browse files
authored
chore(task): add helper tasks for auto sandbox setup (#25)
1 parent 423d4a2 commit 7953fd9

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

taskfile.yaml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
11
version: "3"
22
output: interleaved
33
dotenv: [".env.local"]
4+
vars:
5+
INDENT: 4
6+
REL_PATH: "{{ relPath .USER_WORKING_DIR .ROOT_DIR }}"
7+
VENV_DIR: ".venv"
8+
PYTHON_MAIN: '{{ joinPath "./src" "agent.py" }}'
49

510
tasks:
611
post_create:
712
desc: "Runs after this template is instantiated as a Sandbox or Bootstrap"
813
cmds:
9-
- echo -e "To try the new agent directly in your terminal:\r\n"
10-
- echo -e "\tcd {{.ROOT_DIR}}\r"
11-
- echo -e "\tuv sync\r"
12-
- echo -e "\tuv run src/agent.py download-files\r"
13-
- echo -e "\tuv run src/agent.py console\r\n"
14+
- echo 'To try the new agent directly in your terminal:'
15+
- echo ''
16+
- echo '{{ indent .INDENT "cd" }} {{ .REL_PATH }}'
17+
- echo '{{ indent .INDENT "uv sync" }}'
18+
- echo '{{ indent .INDENT "uv run" }} {{ .PYTHON_MAIN }} download-files'
19+
- echo '{{ indent .INDENT "uv run" }} {{ .PYTHON_MAIN }} console'
20+
- echo ''
21+
- echo 'To deploy your agent to LiveKit cloud:'
22+
- echo ''
23+
- echo '{{ indent .INDENT "lk agent create" }}'
24+
- echo ''
25+
- task: set_agent_name_if_present
26+
- task: help_open_sandbox_if_present
27+
28+
set_agent_name_if_present:
29+
status:
30+
- test -z "$LIVEKIT_AGENT_NAME"
31+
cmds:
32+
- |
33+
old="WorkerOptions("
34+
new="WorkerOptions(agent_name=\"{{ .LIVEKIT_AGENT_NAME }}\", "
35+
file="{{ .PYTHON_MAIN }}"
36+
tmp="$(mktemp)"
37+
while IFS= read -r line; do
38+
printf '%s\n' "${line//$old/$new}" >> "$tmp"
39+
done < "$file"
40+
mv "$tmp" "$file"
41+
42+
help_open_sandbox_if_present:
43+
status:
44+
- test -z "$LIVEKIT_SANDBOX_ID"
45+
cmds:
46+
- echo 'To chat with your running agent, visit:'
47+
- echo ''
48+
- echo '{{ indent .INDENT "https://" }}{{ .LIVEKIT_SANDBOX_ID }}.sandbox.livekit.io'
49+
- echo ''
1450

1551
install:
1652
desc: "Bootstrap application for local development"
@@ -19,4 +55,4 @@ tasks:
1955
dev:
2056
interactive: true
2157
cmds:
22-
- "uv run src/agent.py dev"
58+
- "uv run src/agent.py dev"

0 commit comments

Comments
 (0)