@preapexis/piexis 0.1.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +35 -0
- package/AGENTS.md +21 -41
- package/README.md +75 -142
- package/extensions/agents.ts +205 -0
- package/extensions/ask-question.ts +54 -95
- package/extensions/recommended-tools.ts +62 -0
- package/extensions/ui.ts +204 -58
- package/lib/agent-config.ts +55 -0
- package/lib/agents.ts +208 -0
- package/lib/question-model.ts +98 -0
- package/lib/question-ui.ts +214 -0
- package/lib/recommended-tools.ts +119 -0
- package/lib/subagent-runner.ts +146 -0
- package/lib/ui-tips.json +41 -0
- package/package.json +9 -12
- package/prompts/init.md +10 -2
- package/prompts/summary.md +7 -6
- package/schemas/agent.schema.json +48 -0
- package/scripts/release.mjs +32 -0
- package/skills/{claude-api/LICENSE.txt → caveman/LICENSE} +2 -2
- package/skills/caveman/LICENSE-MIT +21 -0
- package/skills/caveman/NOTICE +10 -0
- package/skills/caveman/SKILL.md +89 -0
- package/skills/find-skills/SKILL.md +141 -0
- package/skills/ponytail/LICENSE +21 -0
- package/skills/ponytail/NOTICE +9 -0
- package/skills/ponytail/SKILL.md +52 -0
- package/skills-lock.json +6 -0
- package/tests/agents.test.mjs +605 -0
- package/tests/ask-question-pty.test.mjs +16 -0
- package/tests/ask-question.test.mjs +269 -0
- package/tests/fixtures/agents-provider.ts +55 -0
- package/tests/fixtures/ask-question-pty.py +91 -0
- package/tests/fixtures/ask-question-terminal.mjs +69 -0
- package/tests/fixtures/recommended-tools-terminal.mjs +103 -0
- package/tests/init-workflow.test.mjs +31 -0
- package/tests/recommended-tools-pty.test.mjs +16 -0
- package/tests/recommended-tools.test.mjs +423 -0
- package/tests/resources.test.mjs +66 -0
- package/tests/skills-routing.test.mjs +7 -4
- package/tests/ui-tip-reload.test.mjs +70 -0
- package/tests/ui.test.mjs +450 -0
- package/tsconfig.json +1 -0
- package/.github/workflows/npm-publish.yml +0 -63
- package/PERMISSION_MODES_PLAN.md +0 -279
- package/WHAT_YOU_GET.md +0 -153
- package/eval/README.md +0 -72
- package/eval/permission-cases.json +0 -28
- package/eval/permissions.mjs +0 -103
- package/extensions/background-tasks.ts +0 -433
- package/extensions/background-worker.ts +0 -50
- package/extensions/glob.ts +0 -32
- package/extensions/mode.ts +0 -397
- package/lib/bash-approvals.ts +0 -113
- package/lib/bash-policy.ts +0 -164
- package/lib/mode-policy.ts +0 -174
- package/lib/path-policy.ts +0 -182
- package/lib/permission-classifier.ts +0 -128
- package/lib/permission-config.ts +0 -91
- package/lib/permission-denials.ts +0 -32
- package/lib/permission-intent.ts +0 -128
- package/lib/permission-taxonomy.ts +0 -15
- package/lib/task-broker.ts +0 -65
- package/lib/task-checkout.ts +0 -39
- package/lib/task-git.ts +0 -44
- package/lib/task-patch.ts +0 -106
- package/lib/task-permissions.ts +0 -51
- package/lib/task-report.ts +0 -62
- package/lib/task-worktree-policy.ts +0 -56
- package/skills/claude-api/SKILL.md +0 -572
- package/skills/claude-api/csharp/claude-api/README.md +0 -362
- package/skills/claude-api/csharp/claude-api/batches.md +0 -14
- package/skills/claude-api/csharp/claude-api/files-api.md +0 -25
- package/skills/claude-api/csharp/claude-api/streaming.md +0 -28
- package/skills/claude-api/csharp/claude-api/tool-use.md +0 -164
- package/skills/claude-api/curl/examples.md +0 -256
- package/skills/claude-api/curl/managed-agents.md +0 -371
- package/skills/claude-api/go/claude-api/README.md +0 -188
- package/skills/claude-api/go/claude-api/files-api.md +0 -23
- package/skills/claude-api/go/claude-api/streaming.md +0 -43
- package/skills/claude-api/go/claude-api/tool-use.md +0 -220
- package/skills/claude-api/go/managed-agents/README.md +0 -564
- package/skills/claude-api/java/claude-api/README.md +0 -238
- package/skills/claude-api/java/claude-api/files-api.md +0 -27
- package/skills/claude-api/java/claude-api/streaming.md +0 -24
- package/skills/claude-api/java/claude-api/tool-use.md +0 -228
- package/skills/claude-api/java/managed-agents/README.md +0 -443
- package/skills/claude-api/php/claude-api/README.md +0 -174
- package/skills/claude-api/php/claude-api/batches.md +0 -15
- package/skills/claude-api/php/claude-api/files-api.md +0 -13
- package/skills/claude-api/php/claude-api/streaming.md +0 -27
- package/skills/claude-api/php/claude-api/tool-use.md +0 -253
- package/skills/claude-api/php/managed-agents/README.md +0 -443
- package/skills/claude-api/python/claude-api/README.md +0 -565
- package/skills/claude-api/python/claude-api/batches.md +0 -198
- package/skills/claude-api/python/claude-api/files-api.md +0 -170
- package/skills/claude-api/python/claude-api/sdk-upgrade.md +0 -286
- package/skills/claude-api/python/claude-api/streaming.md +0 -179
- package/skills/claude-api/python/claude-api/tool-use.md +0 -627
- package/skills/claude-api/python/managed-agents/README.md +0 -335
- package/skills/claude-api/ruby/claude-api/README.md +0 -134
- package/skills/claude-api/ruby/claude-api/streaming.md +0 -16
- package/skills/claude-api/ruby/claude-api/tool-use.md +0 -41
- package/skills/claude-api/ruby/managed-agents/README.md +0 -394
- package/skills/claude-api/shared/admin-api.md +0 -179
- package/skills/claude-api/shared/agent-design.md +0 -101
- package/skills/claude-api/shared/anthropic-cli.md +0 -269
- package/skills/claude-api/shared/claude-platform-on-aws.md +0 -59
- package/skills/claude-api/shared/cost-optimization.md +0 -233
- package/skills/claude-api/shared/error-codes.md +0 -262
- package/skills/claude-api/shared/live-sources.md +0 -166
- package/skills/claude-api/shared/managed-agents-api-reference.md +0 -455
- package/skills/claude-api/shared/managed-agents-client-patterns.md +0 -220
- package/skills/claude-api/shared/managed-agents-core.md +0 -359
- package/skills/claude-api/shared/managed-agents-environments.md +0 -226
- package/skills/claude-api/shared/managed-agents-events.md +0 -290
- package/skills/claude-api/shared/managed-agents-memory.md +0 -201
- package/skills/claude-api/shared/managed-agents-multiagent.md +0 -260
- package/skills/claude-api/shared/managed-agents-onboarding.md +0 -82
- package/skills/claude-api/shared/managed-agents-outcomes.md +0 -108
- package/skills/claude-api/shared/managed-agents-overview.md +0 -77
- package/skills/claude-api/shared/managed-agents-scheduled-deployments.md +0 -156
- package/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +0 -282
- package/skills/claude-api/shared/managed-agents-tools.md +0 -504
- package/skills/claude-api/shared/managed-agents-webhooks.md +0 -143
- package/skills/claude-api/shared/model-migration.md +0 -1872
- package/skills/claude-api/shared/models.md +0 -142
- package/skills/claude-api/shared/platform-availability.md +0 -53
- package/skills/claude-api/shared/prompt-audit.md +0 -223
- package/skills/claude-api/shared/prompt-caching.md +0 -292
- package/skills/claude-api/shared/token-counting.md +0 -56
- package/skills/claude-api/shared/tool-use-concepts.md +0 -526
- package/skills/claude-api/typescript/claude-api/README.md +0 -405
- package/skills/claude-api/typescript/claude-api/batches.md +0 -106
- package/skills/claude-api/typescript/claude-api/files-api.md +0 -98
- package/skills/claude-api/typescript/claude-api/streaming.md +0 -178
- package/skills/claude-api/typescript/claude-api/tool-use.md +0 -586
- package/skills/claude-api/typescript/managed-agents/README.md +0 -359
- package/tests/auto-permissions.test.mjs +0 -315
- package/tests/background-tasks.test.mjs +0 -27
- package/tests/background-worker.test.mjs +0 -60
- package/tests/bash-permissions.test.mjs +0 -276
- package/tests/glob.test.mjs +0 -31
- package/tests/mode.test.mjs +0 -62
- package/tests/permission-evaluation.test.mjs +0 -70
- package/tests/permission-foundation.test.mjs +0 -194
- package/tests/permission-policy.test.mjs +0 -158
- package/tests/runtime/README.md +0 -51
- package/tests/runtime/harness.mjs +0 -190
- package/tests/runtime/permissions.test.mjs +0 -192
- package/tests/runtime/tui.test.mjs +0 -60
- package/tests/task-integration.test.mjs +0 -324
- package/tests/task-permissions.test.mjs +0 -178
- package/tests/task-worktree-policy.test.mjs +0 -53
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
# Claude API - cURL / Raw HTTP
|
|
2
|
-
|
|
3
|
-
Use these examples when the user needs raw HTTP requests or is working in a language without an official SDK.
|
|
4
|
-
|
|
5
|
-
## Setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
export ANTHROPIC_API_KEY="your-api-key"
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Basic Message Request
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
curl https://api.anthropic.com/v1/messages \
|
|
17
|
-
-H "Content-Type: application/json" \
|
|
18
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
19
|
-
-H "anthropic-version: 2023-06-01" \
|
|
20
|
-
-d '{
|
|
21
|
-
"model": "claude-opus-5",
|
|
22
|
-
"max_tokens": 16000,
|
|
23
|
-
"messages": [
|
|
24
|
-
{"role": "user", "content": "What is the capital of France?"}
|
|
25
|
-
]
|
|
26
|
-
}'
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Parsing the response
|
|
30
|
-
|
|
31
|
-
Use `jq` to extract fields from the JSON response. Do not use `grep`/`sed` -
|
|
32
|
-
JSON strings can contain any character and regex parsing will break on quotes,
|
|
33
|
-
escapes, or multi-line content.
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Capture the response, then extract fields
|
|
37
|
-
response=$(curl -s https://api.anthropic.com/v1/messages \
|
|
38
|
-
-H "Content-Type: application/json" \
|
|
39
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
40
|
-
-H "anthropic-version: 2023-06-01" \
|
|
41
|
-
-d '{"model":"claude-opus-5","max_tokens":16000,"messages":[{"role":"user","content":"Hello"}]}')
|
|
42
|
-
|
|
43
|
-
# Print the first text block (-r strips the JSON quotes)
|
|
44
|
-
echo "$response" | jq -r '.content[0].text'
|
|
45
|
-
|
|
46
|
-
# Read usage fields
|
|
47
|
-
input_tokens=$(echo "$response" | jq -r '.usage.input_tokens')
|
|
48
|
-
output_tokens=$(echo "$response" | jq -r '.usage.output_tokens')
|
|
49
|
-
|
|
50
|
-
# Read stop reason (for tool-use loops)
|
|
51
|
-
stop_reason=$(echo "$response" | jq -r '.stop_reason')
|
|
52
|
-
|
|
53
|
-
# Extract all text blocks (content is an array; filter to type=="text")
|
|
54
|
-
echo "$response" | jq -r '.content[] | select(.type == "text") | .text'
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Streaming (SSE)
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
curl https://api.anthropic.com/v1/messages \
|
|
64
|
-
-H "Content-Type: application/json" \
|
|
65
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
66
|
-
-H "anthropic-version: 2023-06-01" \
|
|
67
|
-
-d '{
|
|
68
|
-
"model": "claude-opus-5",
|
|
69
|
-
"max_tokens": 64000,
|
|
70
|
-
"stream": true,
|
|
71
|
-
"messages": [{"role": "user", "content": "Write a haiku"}]
|
|
72
|
-
}'
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
The response is a stream of Server-Sent Events:
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
event: message_start
|
|
79
|
-
data: {"type":"message_start","message":{"id":"msg_...","type":"message",...}}
|
|
80
|
-
|
|
81
|
-
event: content_block_start
|
|
82
|
-
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
83
|
-
|
|
84
|
-
event: content_block_delta
|
|
85
|
-
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
|
|
86
|
-
|
|
87
|
-
event: content_block_stop
|
|
88
|
-
data: {"type":"content_block_stop","index":0}
|
|
89
|
-
|
|
90
|
-
event: message_delta
|
|
91
|
-
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":12}}
|
|
92
|
-
|
|
93
|
-
event: message_stop
|
|
94
|
-
data: {"type":"message_stop"}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## Tool Use
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
curl https://api.anthropic.com/v1/messages \
|
|
103
|
-
-H "Content-Type: application/json" \
|
|
104
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
105
|
-
-H "anthropic-version: 2023-06-01" \
|
|
106
|
-
-d '{
|
|
107
|
-
"model": "claude-opus-5",
|
|
108
|
-
"max_tokens": 16000,
|
|
109
|
-
"tools": [{
|
|
110
|
-
"name": "get_weather",
|
|
111
|
-
"description": "Get current weather for a location",
|
|
112
|
-
"input_schema": {
|
|
113
|
-
"type": "object",
|
|
114
|
-
"properties": {
|
|
115
|
-
"location": {"type": "string", "description": "City name"}
|
|
116
|
-
},
|
|
117
|
-
"required": ["location"]
|
|
118
|
-
}
|
|
119
|
-
}],
|
|
120
|
-
"messages": [{"role": "user", "content": "What is the weather in Paris?"}]
|
|
121
|
-
}'
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
When Claude responds with a `tool_use` block, send the result back:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
curl https://api.anthropic.com/v1/messages \
|
|
128
|
-
-H "Content-Type: application/json" \
|
|
129
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
130
|
-
-H "anthropic-version: 2023-06-01" \
|
|
131
|
-
-d '{
|
|
132
|
-
"model": "claude-opus-5",
|
|
133
|
-
"max_tokens": 16000,
|
|
134
|
-
"tools": [{
|
|
135
|
-
"name": "get_weather",
|
|
136
|
-
"description": "Get current weather for a location",
|
|
137
|
-
"input_schema": {
|
|
138
|
-
"type": "object",
|
|
139
|
-
"properties": {
|
|
140
|
-
"location": {"type": "string", "description": "City name"}
|
|
141
|
-
},
|
|
142
|
-
"required": ["location"]
|
|
143
|
-
}
|
|
144
|
-
}],
|
|
145
|
-
"messages": [
|
|
146
|
-
{"role": "user", "content": "What is the weather in Paris?"},
|
|
147
|
-
{"role": "assistant", "content": [
|
|
148
|
-
{"type": "text", "text": "Let me check the weather."},
|
|
149
|
-
{"type": "tool_use", "id": "toolu_abc123", "name": "get_weather", "input": {"location": "Paris"}}
|
|
150
|
-
]},
|
|
151
|
-
{"role": "user", "content": [
|
|
152
|
-
{"type": "tool_result", "tool_use_id": "toolu_abc123", "content": "72°F and sunny"}
|
|
153
|
-
]}
|
|
154
|
-
]
|
|
155
|
-
}'
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Prompt Caching
|
|
161
|
-
|
|
162
|
-
Put `cache_control` on the last block of the stable prefix. See `shared/prompt-caching.md` for placement patterns and the silent-invalidator audit checklist.
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
curl https://api.anthropic.com/v1/messages \
|
|
166
|
-
-H "Content-Type: application/json" \
|
|
167
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
168
|
-
-H "anthropic-version: 2023-06-01" \
|
|
169
|
-
-d '{
|
|
170
|
-
"model": "claude-opus-5",
|
|
171
|
-
"max_tokens": 16000,
|
|
172
|
-
"system": [
|
|
173
|
-
{"type": "text", "text": "<large shared prompt...>", "cache_control": {"type": "ephemeral"}}
|
|
174
|
-
],
|
|
175
|
-
"messages": [{"role": "user", "content": "Summarize the key points"}]
|
|
176
|
-
}'
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
For 1-hour TTL: `"cache_control": {"type": "ephemeral", "ttl": "1h"}`. Top-level `"cache_control"` on the request body auto-places on the last cacheable block. Verify hits via the response `usage.cache_creation_input_tokens` / `usage.cache_read_input_tokens` fields.
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## Extended Thinking
|
|
184
|
-
|
|
185
|
-
> **Fable 5, Claude Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, and Sonnet 4.6:** Use adaptive thinking. `budget_tokens` is removed on Fable 5, Claude Opus 5, Opus 4.8, and 4.7 (400 if sent); deprecated on Opus 4.6 and Sonnet 4.6.
|
|
186
|
-
> **Claude Opus 5:** thinking is on by default - omitting `"thinking"` runs adaptive (`{"type": "adaptive"}` is equivalent), unlike Opus 4.8/4.7 where omitting it meant no thinking. `{"type": "disabled"}` is accepted only at effort `high` or lower; pairing it with `xhigh`/`max` returns a 400.
|
|
187
|
-
> **Older models:** Use `"type": "enabled"` with `"budget_tokens": N` (must be < `max_tokens`, min 1024).
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
# Fable 5 / Claude Opus 5 / Opus 4.8 / 4.7 / 4.6: adaptive thinking (recommended)
|
|
191
|
-
curl https://api.anthropic.com/v1/messages \
|
|
192
|
-
-H "Content-Type: application/json" \
|
|
193
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
194
|
-
-H "anthropic-version: 2023-06-01" \
|
|
195
|
-
-d '{
|
|
196
|
-
"model": "claude-opus-5",
|
|
197
|
-
"max_tokens": 16000,
|
|
198
|
-
"thinking": {
|
|
199
|
-
"type": "adaptive",
|
|
200
|
-
"display": "summarized"
|
|
201
|
-
},
|
|
202
|
-
"output_config": {
|
|
203
|
-
"effort": "high"
|
|
204
|
-
},
|
|
205
|
-
"messages": [{"role": "user", "content": "Solve this step by step..."}]
|
|
206
|
-
}'
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## Refusal Fallbacks (Claude Fable 5.1) - opt in by default
|
|
212
|
-
|
|
213
|
-
On `claude-fable-5-1`, safety classifiers may decline a request (HTTP 200 with `stop_reason: "refusal"`). Fallbacks are **opt-in**: without them the request simply stops. Include the `fallbacks` parameter and its beta header by default - on a policy decline the API re-runs the same request on the fallback model inside the same call. A decline before any output isn't billed (a mid-stream decline bills the streamed partial); the rescue bills at the fallback model's own rates.
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
response=$(curl -s https://api.anthropic.com/v1/messages \
|
|
217
|
-
-H "Content-Type: application/json" \
|
|
218
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
219
|
-
-H "anthropic-version: 2023-06-01" \
|
|
220
|
-
-H "anthropic-beta: server-side-fallback-2026-06-01" \
|
|
221
|
-
-d '{
|
|
222
|
-
"model": "claude-fable-5-1",
|
|
223
|
-
"max_tokens": 16000,
|
|
224
|
-
"fallbacks": [{"model": "claude-opus-4-8"}],
|
|
225
|
-
"messages": [{"role": "user", "content": "Hello"}]
|
|
226
|
-
}')
|
|
227
|
-
|
|
228
|
-
# Which model produced the message
|
|
229
|
-
echo "$response" | jq -r '.model'
|
|
230
|
-
|
|
231
|
-
# Refusal on the final response means the whole chain refused
|
|
232
|
-
echo "$response" | jq -r '.stop_reason'
|
|
233
|
-
|
|
234
|
-
# Switch points: one fallback block per model that ran and declined this turn
|
|
235
|
-
echo "$response" | jq -r '.content[] | select(.type == "fallback") | "\(.from.model) declined; \(.to.model) continued"'
|
|
236
|
-
|
|
237
|
-
# Served-by signal - covers sticky turns, which carry no fallback block.
|
|
238
|
-
# Pair with stop_reason: the fallback model can itself refuse.
|
|
239
|
-
if [ "$(echo "$response" | jq -r '.stop_reason')" != "refusal" ] && \
|
|
240
|
-
echo "$response" | jq -e '[.usage.iterations[]? | select(.type == "fallback_message")] | length > 0' > /dev/null; then
|
|
241
|
-
echo "fallback model served this turn"
|
|
242
|
-
fi
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
The header must be exactly `server-side-fallback-2026-06-01` **for this array form**; the newer `fallbacks: "default"` scalar form uses `server-side-fallback-2026-07-01` instead (see `shared/model-migration.md` -> Migrating to Claude Opus 5 -> New API features), and pairing either header with the other form returns a 400. The parameter is rejected on the Batches API and unavailable on Amazon Bedrock, Vertex AI, and Microsoft Foundry. Full semantics (sticky routing, billing, streaming, echoing fallback turns back): `shared/model-migration.md` -> Migrating to Claude Fable 5.1 -> `refusal` stop reason.
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
## Required Headers
|
|
250
|
-
|
|
251
|
-
| Header | Value | Description |
|
|
252
|
-
| ------------------- | ------------------ | -------------------------- |
|
|
253
|
-
| `Content-Type` | `application/json` | Required |
|
|
254
|
-
| `x-api-key` | Your API key | Authentication |
|
|
255
|
-
| `anthropic-version` | `2023-06-01` | API version |
|
|
256
|
-
| `anthropic-beta` | Beta feature IDs | Required for beta features |
|
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
# Managed Agents - cURL / Raw HTTP
|
|
2
|
-
|
|
3
|
-
Use these examples when the user needs raw HTTP requests or is working without an SDK.
|
|
4
|
-
|
|
5
|
-
## Setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
export ANTHROPIC_API_KEY="your-api-key"
|
|
9
|
-
|
|
10
|
-
# Common headers
|
|
11
|
-
HEADERS=(
|
|
12
|
-
-H "Content-Type: application/json"
|
|
13
|
-
-H "x-api-key: $ANTHROPIC_API_KEY"
|
|
14
|
-
-H "anthropic-version: 2023-06-01"
|
|
15
|
-
-H "anthropic-beta: managed-agents-2026-04-01"
|
|
16
|
-
)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Create an Environment
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
curl -X POST https://api.anthropic.com/v1/environments \
|
|
25
|
-
"${HEADERS[@]}" \
|
|
26
|
-
-d '{
|
|
27
|
-
"name": "my-dev-env",
|
|
28
|
-
"config": {
|
|
29
|
-
"type": "cloud",
|
|
30
|
-
"networking": { "type": "unrestricted" }
|
|
31
|
-
}
|
|
32
|
-
}'
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### With restricted networking
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
curl -X POST https://api.anthropic.com/v1/environments \
|
|
39
|
-
"${HEADERS[@]}" \
|
|
40
|
-
-d '{
|
|
41
|
-
"name": "restricted-env",
|
|
42
|
-
"config": {
|
|
43
|
-
"type": "cloud",
|
|
44
|
-
"networking": {
|
|
45
|
-
"type": "limited",
|
|
46
|
-
"allow_package_managers": true,
|
|
47
|
-
"allow_mcp_servers": true,
|
|
48
|
-
"allowed_hosts": ["api.example.com"]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}'
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Create an Agent (required first step)
|
|
57
|
-
|
|
58
|
-
> Warning: **There is no inline agent config.** Under `managed-agents-2026-04-01`, `model`/`system`/`tools` are top-level fields on `POST /v1/agents`, not on the session. Always create the agent first - the session only takes `"agent": {"type": "agent", "id": "..."}`.
|
|
59
|
-
|
|
60
|
-
### Minimal
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
# 1. Create the agent
|
|
64
|
-
curl -X POST https://api.anthropic.com/v1/agents \
|
|
65
|
-
"${HEADERS[@]}" \
|
|
66
|
-
-d '{
|
|
67
|
-
"name": "Coding Assistant",
|
|
68
|
-
"model": "claude-opus-5",
|
|
69
|
-
"tools": [{ "type": "agent_toolset_20260401" }]
|
|
70
|
-
}'
|
|
71
|
-
# -> { "id": "agent_abc123", ... }
|
|
72
|
-
|
|
73
|
-
# 2. Start a session
|
|
74
|
-
curl -X POST https://api.anthropic.com/v1/sessions \
|
|
75
|
-
"${HEADERS[@]}" \
|
|
76
|
-
-d '{
|
|
77
|
-
"agent": { "type": "agent", "id": "agent_abc123", "version": 1 },
|
|
78
|
-
"environment_id": "env_abc123"
|
|
79
|
-
}'
|
|
80
|
-
# -> { "id": "sesn_abc123", ... }
|
|
81
|
-
# Trace: https://platform.claude.com/workspaces/default/sessions/sesn_abc123 (swap 'default' for your workspace ID if the API key is not in the Default workspace)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### With system prompt, custom tools, and GitHub repo
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# 1. Create the agent
|
|
88
|
-
curl -X POST https://api.anthropic.com/v1/agents \
|
|
89
|
-
"${HEADERS[@]}" \
|
|
90
|
-
-d '{
|
|
91
|
-
"name": "Code Reviewer",
|
|
92
|
-
"model": "claude-opus-5",
|
|
93
|
-
"system": "You are a senior code reviewer. Be thorough and constructive.",
|
|
94
|
-
"tools": [
|
|
95
|
-
{ "type": "agent_toolset_20260401" },
|
|
96
|
-
{
|
|
97
|
-
"type": "custom",
|
|
98
|
-
"name": "run_linter",
|
|
99
|
-
"description": "Run the project linter on a file",
|
|
100
|
-
"input_schema": {
|
|
101
|
-
"type": "object",
|
|
102
|
-
"properties": {
|
|
103
|
-
"file_path": { "type": "string", "description": "Path to lint" }
|
|
104
|
-
},
|
|
105
|
-
"required": ["file_path"]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}'
|
|
110
|
-
|
|
111
|
-
# 2. Start a session with the repo mounted
|
|
112
|
-
curl -X POST https://api.anthropic.com/v1/sessions \
|
|
113
|
-
"${HEADERS[@]}" \
|
|
114
|
-
-d '{
|
|
115
|
-
"agent": { "type": "agent", "id": "agent_abc123", "version": 1 },
|
|
116
|
-
"environment_id": "env_abc123",
|
|
117
|
-
"title": "Code review session",
|
|
118
|
-
"resources": [
|
|
119
|
-
{
|
|
120
|
-
"type": "github_repository",
|
|
121
|
-
"url": "https://github.com/owner/repo",
|
|
122
|
-
"mount_path": "/workspace/repo",
|
|
123
|
-
"authorization_token": "ghp_...",
|
|
124
|
-
"branch": "feature-branch"
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}'
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### With a session budget
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
# Create a session with a hard $25.00 spend cap (list-priced; USD only; create-only).
|
|
134
|
-
# amount is in minor units (cents) as an integer string: "2500" = $25.00
|
|
135
|
-
curl -X POST https://api.anthropic.com/v1/sessions \
|
|
136
|
-
"${HEADERS[@]}" \
|
|
137
|
-
-d '{
|
|
138
|
-
"agent": { "type": "agent", "id": "agent_abc123" },
|
|
139
|
-
"environment_id": "env_abc123",
|
|
140
|
-
"budget": {
|
|
141
|
-
"type": "limit",
|
|
142
|
-
"max_list_cost": { "amount": "2500", "currency": "USD" }
|
|
143
|
-
}
|
|
144
|
-
}'
|
|
145
|
-
|
|
146
|
-
# Change the cap - higher or lower, but it must exceed the consumed list cost.
|
|
147
|
-
# An accepted update resumes work paused at budget_reached
|
|
148
|
-
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID \
|
|
149
|
-
"${HEADERS[@]}" \
|
|
150
|
-
-d '{ "budget": { "type": "limit", "max_list_cost": { "amount": "4000", "currency": "USD" } } }'
|
|
151
|
-
|
|
152
|
-
# Remove the cap entirely - one-way; a removed budget can never be re-added
|
|
153
|
-
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID \
|
|
154
|
-
"${HEADERS[@]}" \
|
|
155
|
-
-d '{ "budget": null }'
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
See `shared/managed-agents-core.md` § Session budgets for list-cost composition, the settle-event allowlist at the cap, and multiagent semantics.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Send a User Message
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID/events \
|
|
166
|
-
"${HEADERS[@]}" \
|
|
167
|
-
-d '{
|
|
168
|
-
"events": [
|
|
169
|
-
{
|
|
170
|
-
"type": "user.message",
|
|
171
|
-
"content": [{ "type": "text", "text": "Review the auth module for security issues" }]
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}'
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## Stream Events (SSE)
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
curl -N https://api.anthropic.com/v1/sessions/$SESSION_ID/events/stream \
|
|
183
|
-
"${HEADERS[@]}"
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Response format:
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
event: session.status_running
|
|
190
|
-
data: {"type":"session.status_running","id":"sevt_...","processed_at":"..."}
|
|
191
|
-
|
|
192
|
-
event: agent.message
|
|
193
|
-
data: {"type":"agent.message","id":"sevt_...","content":[{"type":"text","text":"I'll review..."}],"processed_at":"..."}
|
|
194
|
-
|
|
195
|
-
event: session.status_idle
|
|
196
|
-
data: {"type":"session.status_idle","id":"sevt_...","processed_at":"..."}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
## Poll Events
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# Get all events
|
|
205
|
-
curl https://api.anthropic.com/v1/sessions/$SESSION_ID/events \
|
|
206
|
-
"${HEADERS[@]}"
|
|
207
|
-
|
|
208
|
-
# Paginated - get next page of events
|
|
209
|
-
curl "https://api.anthropic.com/v1/sessions/$SESSION_ID/events?page=page_abc123" \
|
|
210
|
-
"${HEADERS[@]}"
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## Provide Custom Tool Result
|
|
216
|
-
|
|
217
|
-
When the agent calls a custom tool, send the result back:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID/events \
|
|
221
|
-
"${HEADERS[@]}" \
|
|
222
|
-
-d '{
|
|
223
|
-
"events": [
|
|
224
|
-
{
|
|
225
|
-
"type": "user.custom_tool_result",
|
|
226
|
-
"custom_tool_use_id": "sevt_abc123",
|
|
227
|
-
"content": [{ "type": "text", "text": "No linting errors found." }]
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
}'
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
## Interrupt a Running Session
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID/events \
|
|
239
|
-
"${HEADERS[@]}" \
|
|
240
|
-
-d '{
|
|
241
|
-
"events": [
|
|
242
|
-
{
|
|
243
|
-
"type": "user.interrupt"
|
|
244
|
-
}
|
|
245
|
-
]
|
|
246
|
-
}'
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## Get Session Details
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
curl https://api.anthropic.com/v1/sessions/$SESSION_ID \
|
|
255
|
-
"${HEADERS[@]}"
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## List Sessions
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
curl https://api.anthropic.com/v1/sessions \
|
|
264
|
-
"${HEADERS[@]}"
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
|
-
## Delete a Session
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
curl -X DELETE https://api.anthropic.com/v1/sessions/$SESSION_ID \
|
|
273
|
-
"${HEADERS[@]}"
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## Upload a File
|
|
279
|
-
|
|
280
|
-
```bash
|
|
281
|
-
curl -X POST https://api.anthropic.com/v1/files \
|
|
282
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
283
|
-
-H "anthropic-version: 2023-06-01" \
|
|
284
|
-
-H "anthropic-beta: files-api-2025-04-14" \
|
|
285
|
-
-F "file=@path/to/file.txt" \
|
|
286
|
-
-F "purpose=agent"
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## List and Download Session Files
|
|
292
|
-
|
|
293
|
-
List files the agent wrote to `/mnt/session/outputs/` during a session, then download them.
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
# List files associated with a session
|
|
297
|
-
curl "https://api.anthropic.com/v1/files?scope_id=$SESSION_ID" \
|
|
298
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
299
|
-
-H "anthropic-version: 2023-06-01" \
|
|
300
|
-
-H "anthropic-beta: files-api-2025-04-14,managed-agents-2026-04-01"
|
|
301
|
-
|
|
302
|
-
# Download a specific file
|
|
303
|
-
curl "https://api.anthropic.com/v1/files/$FILE_ID/content" \
|
|
304
|
-
-H "x-api-key: $ANTHROPIC_API_KEY" \
|
|
305
|
-
-H "anthropic-version: 2023-06-01" \
|
|
306
|
-
-H "anthropic-beta: files-api-2025-04-14,managed-agents-2026-04-01" \
|
|
307
|
-
-o downloaded_file.txt
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## List Agents
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
curl https://api.anthropic.com/v1/agents \
|
|
316
|
-
"${HEADERS[@]}"
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
---
|
|
320
|
-
|
|
321
|
-
## MCP Server Integration
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
# 1. Agent declares MCP server (no auth here - auth goes in a vault)
|
|
325
|
-
curl -X POST https://api.anthropic.com/v1/agents \
|
|
326
|
-
"${HEADERS[@]}" \
|
|
327
|
-
-d '{
|
|
328
|
-
"name": "MCP Agent",
|
|
329
|
-
"model": "claude-opus-5",
|
|
330
|
-
"mcp_servers": [
|
|
331
|
-
{ "type": "url", "name": "my-tools", "url": "https://my-mcp-server.example.com/sse" }
|
|
332
|
-
],
|
|
333
|
-
"tools": [
|
|
334
|
-
{ "type": "agent_toolset_20260401" },
|
|
335
|
-
{ "type": "mcp_toolset", "mcp_server_name": "my-tools" }
|
|
336
|
-
]
|
|
337
|
-
}'
|
|
338
|
-
|
|
339
|
-
# 2. Session attaches vault containing credentials for that MCP server URL
|
|
340
|
-
curl -X POST https://api.anthropic.com/v1/sessions \
|
|
341
|
-
"${HEADERS[@]}" \
|
|
342
|
-
-d '{
|
|
343
|
-
"agent": "agent_abc123",
|
|
344
|
-
"environment_id": "env_abc123",
|
|
345
|
-
"vault_ids": ["vlt_abc123"]
|
|
346
|
-
}'
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
See `shared/managed-agents-tools.md` §Vaults for creating vaults and adding credentials.
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
## Tool Configuration
|
|
354
|
-
|
|
355
|
-
```bash
|
|
356
|
-
curl -X POST https://api.anthropic.com/v1/agents \
|
|
357
|
-
"${HEADERS[@]}" \
|
|
358
|
-
-d '{
|
|
359
|
-
"name": "Restricted Agent",
|
|
360
|
-
"model": "claude-opus-5",
|
|
361
|
-
"tools": [
|
|
362
|
-
{
|
|
363
|
-
"type": "agent_toolset_20260401",
|
|
364
|
-
"default_config": { "enabled": true },
|
|
365
|
-
"configs": [
|
|
366
|
-
{ "name": "bash", "enabled": false }
|
|
367
|
-
]
|
|
368
|
-
}
|
|
369
|
-
]
|
|
370
|
-
}'
|
|
371
|
-
```
|