Commit 07bca6a
examples: hello.ts — the smallest useful ComputerAgent program
45 lines (incl. comments + blank lines). ~25 lines of real code.
Replaces the need to wade through security-agent.ts (169 lines) or
binary-artifact-demo.ts (170 lines) just to learn the shape. Covers
everything a first-touch user actually needs:
- Inline agent definition (no GitHub repo to clone, no GAP folder
structure to learn)
- LocalSubstrate (no Docker, no E2B account, no Tart VM)
- The Claude Agent SDK engine end-to-end — Write tool included
- agent.fetchArtifactText() to read back what the agent produced
- usage rollup printed at the end so people see token + cost data
from line one
Live-validated against the real Anthropic API:
$ bun run examples/hello.ts
Types protect the code
Errors caught at compile time
Fewer runtime bugs
984 tokens • $0.0468 • session sess_...
The other examples stay — they prove richer use cases (multi-turn
marketing, security audit, binary artifacts, session resume). But
hello.ts is now THE canonical entry point.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0b803cd commit 07bca6a
2 files changed
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
0 commit comments