Skip to content

Commit dcb86ba

Browse files
committed
feat(sdk,cli,core,build): phase 1 of agent skills
Full Phase 1 for the new ai.skills primitive — SDK + CLI, no backend. Developer-authored folders (SKILL.md + scripts/references/ assets) discovered at build time, bundled into the deploy image at /app/.trigger/skills/{id}/, and auto-wired into streamText at runtime via the loadSkill/readFile/bash tools. Adds a time-utils example skill to the ai-chat reference: two bash scripts (now.sh, add.sh) plus a timezones.txt cheat-sheet, wired into the aiChat agent via chat.skills.set() in onChatStart and onPreload. Exercises the full pipeline end-to-end. Changeset: patch bump for @trigger.dev/sdk, @trigger.dev/core, @trigger.dev/build, trigger.dev.
1 parent 3298d09 commit dcb86ba

6 files changed

Lines changed: 101 additions & 1 deletion

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
"@trigger.dev/core": patch
4+
"@trigger.dev/build": patch
5+
"trigger.dev": patch
6+
---
7+
8+
Add agent skills — developer-authored folders (`SKILL.md` + scripts/references/assets) bundled into the deploy image automatically, discovered by the chat agent via progressive disclosure. Built on the [AI SDK cookbook pattern](https://ai-sdk.dev/cookbook/guides/agent-skills) — portable across providers.
9+
10+
**New:**
11+
- `skills.define({ id, path })` registers a skill with the resource catalog; the Trigger.dev CLI bundles the folder into `/app/.trigger/skills/{id}/` automatically — no `trigger.config.ts` changes, no build extension.
12+
- `SkillHandle.local()` reads the bundled `SKILL.md` at runtime, parses frontmatter, returns a `ResolvedSkill`.
13+
- `chat.skills.set([...])` stores resolved skills for the current run.
14+
- `chat.toStreamTextOptions()` auto-injects the skills preamble into the system prompt and merges three tools — `loadSkill`, `readFile`, `bash` — scoped per-skill with path-traversal guards and output caps (64 KB stdout/stderr, 1 MB `readFile`). `bash` runs with `cwd` = skill directory; the turn's abort signal propagates.
15+
16+
Phase 1 is SDK + CLI only — no backend, no dashboard overrides. Dashboard-editable `SKILL.md` text lands in Phase 2 (`skill.resolve()` currently throws).

references/ai-chat/src/trigger/chat.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { chat, type ChatTaskWirePayload } from "@trigger.dev/sdk/ai";
2-
import { logger, prompts } from "@trigger.dev/sdk";
2+
import { logger, prompts, skills } from "@trigger.dev/sdk";
33
import {
44
streamText,
55
generateText,
@@ -89,6 +89,11 @@ When the user asks you to research a topic, use the deep research tool with rele
8989
- Keep responses under a few paragraphs unless the user asks for more.`,
9090
});
9191

92+
const timeUtilsSkill = skills.define({
93+
id: "time-utils",
94+
path: "./skills/time-utils",
95+
});
96+
9297
const selfReviewPrompt = prompts.define({
9398
id: "ai-chat-self-review",
9499
model: "openai:gpt-4o-mini" satisfies RegistryLanguageModelId,
@@ -274,6 +279,7 @@ export const aiChat = chat
274279
plan: user.plan as string,
275280
});
276281
chat.prompt.set(resolved);
282+
chat.skills.set([await timeUtilsSkill.local()]);
277283

278284
await prisma.chat.upsert({
279285
where: { id: chatId },
@@ -322,6 +328,7 @@ export const aiChat = chat
322328
plan: user.plan as string,
323329
});
324330
chat.prompt.set(resolved);
331+
chat.skills.set([await timeUtilsSkill.local()]);
325332

326333
if (!continuation) {
327334
await prisma.chat.upsert({
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: time-utils
3+
description: Compute and format dates/times in arbitrary timezones using a small set of bundled bash scripts. Use when the user asks about "what time is it", "current time in <city>", date math, or timezone conversions.
4+
---
5+
6+
# Time utilities
7+
8+
This skill bundles small bash scripts that shell out to `date` for timezone-aware answers without the model having to reason about offsets.
9+
10+
## When to use
11+
12+
- The user asks for the current time in a specific timezone (e.g. "what time is it in Tokyo?")
13+
- The user wants a date formatted in a specific way
14+
- The user needs a relative time (e.g. "what's the date 3 days from now?")
15+
16+
## Scripts
17+
18+
### `scripts/now.sh [TZ]`
19+
20+
Prints the current time in the given IANA timezone (default `UTC`). Example:
21+
22+
```
23+
bash scripts/now.sh America/Los_Angeles
24+
```
25+
26+
### `scripts/add.sh DAYS [TZ]`
27+
28+
Prints a date `DAYS` days from now in the given timezone. `DAYS` can be negative. Example:
29+
30+
```
31+
bash scripts/add.sh 3 Europe/London
32+
```
33+
34+
## Tips
35+
36+
- IANA timezone names only (`America/New_York`, not `EST`).
37+
- See `references/timezones.txt` for a short cheat-sheet of common zones.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Common IANA timezones:
2+
3+
North America:
4+
America/New_York (US Eastern)
5+
America/Chicago (US Central)
6+
America/Denver (US Mountain)
7+
America/Los_Angeles (US Pacific)
8+
America/Toronto
9+
America/Mexico_City
10+
11+
Europe:
12+
Europe/London
13+
Europe/Paris
14+
Europe/Berlin
15+
Europe/Amsterdam
16+
Europe/Madrid
17+
Europe/Dublin
18+
19+
Asia & Pacific:
20+
Asia/Tokyo
21+
Asia/Shanghai
22+
Asia/Singapore
23+
Asia/Kolkata (India, UTC+5:30)
24+
Australia/Sydney
25+
Pacific/Auckland
26+
27+
Others:
28+
UTC
29+
America/Sao_Paulo
30+
Africa/Johannesburg
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
DAYS="${1:?days argument required}"
4+
TZ="${2:-UTC}"
5+
TZ="$TZ" date -d "${DAYS} days" '+%Y-%m-%d %H:%M:%S %Z' 2>/dev/null \
6+
|| TZ="$TZ" date -v"${DAYS}d" '+%Y-%m-%d %H:%M:%S %Z'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
TZ="${1:-UTC}"
4+
TZ="$TZ" date -u '+%Y-%m-%d %H:%M:%S %Z' 2>/dev/null || TZ="$TZ" date '+%Y-%m-%d %H:%M:%S %Z'

0 commit comments

Comments
 (0)