Skip to content

Commit e0c0e9b

Browse files
feat(api): add support for Managed Agents multiagents and outcomes, webhooks, vault validation
1 parent 9ddb1ad commit e0c0e9b

48 files changed

Lines changed: 6234 additions & 53 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 91
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-ad9228826393d94e86ecf4c22853ae51b1d4094960c836238b3ab79a1044be32.yml
3-
openapi_spec_hash: dc43ed54947d427a084a891b7c4a783a
4-
config_hash: bbf09e23cb2e12b5bb8cbcee3044ceec
1+
configured_endpoints: 97
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-9f858907356014087c51d59846cd158425826fc558a1683e6ebf49483503cd5e.yml
3+
openapi_spec_hash: 87cd38428be2fb157f6d79b50c00f573
4+
config_hash: 0ed9b1770bb175fa6bdc1e4d41afb180

MIGRATION.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ This affects the following methods:
5757
- `client.beta.sessions.resources.retrieve()`
5858
- `client.beta.sessions.resources.update()`
5959
- `client.beta.sessions.resources.delete()`
60+
- `client.beta.sessions.threads.retrieve()`
61+
- `client.beta.sessions.threads.archive()`
62+
- `client.beta.sessions.threads.events.list()`
63+
- `client.beta.sessions.threads.events.stream()`
6064
- `client.beta.vaults.credentials.retrieve()`
6165
- `client.beta.vaults.credentials.update()`
6266
- `client.beta.vaults.credentials.delete()`
6367
- `client.beta.vaults.credentials.archive()`
68+
- `client.beta.vaults.credentials.mcpOAuthValidate()`
6469
- `client.beta.memoryStores.memories.retrieve()`
6570
- `client.beta.memoryStores.memories.update()`
6671
- `client.beta.memoryStores.memories.delete()`
@@ -125,6 +130,7 @@ client.example.list(undefined, { headers: { ... } });
125130
- `client.beta.sessions.events.list()`
126131
- `client.beta.sessions.events.stream()`
127132
- `client.beta.sessions.resources.list()`
133+
- `client.beta.sessions.threads.list()`
128134
- `client.beta.vaults.retrieve()`
129135
- `client.beta.vaults.list()`
130136
- `client.beta.vaults.delete()`

api.md

Lines changed: 89 additions & 0 deletions
Large diffs are not rendered by default.

bin/migration-config.json

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,154 @@
115115
}
116116
]
117117
},
118+
{
119+
"base": "beta.sessions.threads",
120+
"name": "retrieve",
121+
"params": [
122+
{
123+
"type": "param",
124+
"key": "thread_id",
125+
"location": "path"
126+
},
127+
{
128+
"type": "params",
129+
"maybeOverload": false
130+
},
131+
{
132+
"type": "options"
133+
}
134+
],
135+
"oldParams": [
136+
{
137+
"type": "param",
138+
"key": "session_id",
139+
"location": "path"
140+
},
141+
{
142+
"type": "param",
143+
"key": "thread_id",
144+
"location": "path"
145+
},
146+
{
147+
"type": "params",
148+
"maybeOverload": true
149+
},
150+
{
151+
"type": "options"
152+
}
153+
]
154+
},
155+
{
156+
"base": "beta.sessions.threads",
157+
"name": "archive",
158+
"params": [
159+
{
160+
"type": "param",
161+
"key": "thread_id",
162+
"location": "path"
163+
},
164+
{
165+
"type": "params",
166+
"maybeOverload": false
167+
},
168+
{
169+
"type": "options"
170+
}
171+
],
172+
"oldParams": [
173+
{
174+
"type": "param",
175+
"key": "session_id",
176+
"location": "path"
177+
},
178+
{
179+
"type": "param",
180+
"key": "thread_id",
181+
"location": "path"
182+
},
183+
{
184+
"type": "params",
185+
"maybeOverload": true
186+
},
187+
{
188+
"type": "options"
189+
}
190+
]
191+
},
192+
{
193+
"base": "beta.sessions.threads.events",
194+
"name": "list",
195+
"params": [
196+
{
197+
"type": "param",
198+
"key": "thread_id",
199+
"location": "path"
200+
},
201+
{
202+
"type": "params",
203+
"maybeOverload": false
204+
},
205+
{
206+
"type": "options"
207+
}
208+
],
209+
"oldParams": [
210+
{
211+
"type": "param",
212+
"key": "session_id",
213+
"location": "path"
214+
},
215+
{
216+
"type": "param",
217+
"key": "thread_id",
218+
"location": "path"
219+
},
220+
{
221+
"type": "params",
222+
"maybeOverload": true
223+
},
224+
{
225+
"type": "options"
226+
}
227+
]
228+
},
229+
{
230+
"base": "beta.sessions.threads.events",
231+
"name": "stream",
232+
"params": [
233+
{
234+
"type": "param",
235+
"key": "thread_id",
236+
"location": "path"
237+
},
238+
{
239+
"type": "params",
240+
"maybeOverload": false
241+
},
242+
{
243+
"type": "options"
244+
}
245+
],
246+
"oldParams": [
247+
{
248+
"type": "param",
249+
"key": "session_id",
250+
"location": "path"
251+
},
252+
{
253+
"type": "param",
254+
"key": "thread_id",
255+
"location": "path"
256+
},
257+
{
258+
"type": "params",
259+
"maybeOverload": true
260+
},
261+
{
262+
"type": "options"
263+
}
264+
]
265+
},
118266
{
119267
"base": "beta.vaults.credentials",
120268
"name": "retrieve",
@@ -263,6 +411,43 @@
263411
}
264412
]
265413
},
414+
{
415+
"base": "beta.vaults.credentials",
416+
"name": "mcpOAuthValidate",
417+
"params": [
418+
{
419+
"type": "param",
420+
"key": "credential_id",
421+
"location": "path"
422+
},
423+
{
424+
"type": "params",
425+
"maybeOverload": false
426+
},
427+
{
428+
"type": "options"
429+
}
430+
],
431+
"oldParams": [
432+
{
433+
"type": "param",
434+
"key": "vault_id",
435+
"location": "path"
436+
},
437+
{
438+
"type": "param",
439+
"key": "credential_id",
440+
"location": "path"
441+
},
442+
{
443+
"type": "params",
444+
"maybeOverload": true
445+
},
446+
{
447+
"type": "options"
448+
}
449+
]
450+
},
266451
{
267452
"base": "beta.memoryStores.memories",
268453
"name": "retrieve",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"fix": "./scripts/format"
2828
},
2929
"dependencies": {
30+
"standardwebhooks": "^1.0.0",
3031
"json-schema-to-ts": "^3.1.1"
3132
},
3233
"peerDependencies": {

scripts/detect-breaking-changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ TEST_PATHS=(
2121
tests/api-resources/beta/sessions/sessions.test.ts
2222
tests/api-resources/beta/sessions/events.test.ts
2323
tests/api-resources/beta/sessions/resources.test.ts
24+
tests/api-resources/beta/sessions/threads/threads.test.ts
25+
tests/api-resources/beta/sessions/threads/events.test.ts
2426
tests/api-resources/beta/vaults/vaults.test.ts
2527
tests/api-resources/beta/vaults/credentials.test.ts
2628
tests/api-resources/beta/memory-stores/memory-stores.test.ts
@@ -29,6 +31,7 @@ TEST_PATHS=(
2931
tests/api-resources/beta/files.test.ts
3032
tests/api-resources/beta/skills/skills.test.ts
3133
tests/api-resources/beta/skills/versions.test.ts
34+
tests/api-resources/beta/webhooks.test.ts
3235
tests/api-resources/beta/user-profiles.test.ts
3336
tests/index.test.ts
3437
)

scripts/mock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ "$1" == "--daemon" ]; then
2424
# Pre-install the package so the download doesn't eat into the startup timeout
2525
npm exec --package=@stdy/cli@0.22.1 -- steady --version
2626

27-
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
27+
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
2828

2929
# Wait for server to come online via health endpoint (max 30s)
3030
echo -n "Waiting for server"
@@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then
4848

4949
echo
5050
else
51-
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
51+
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
5252
fi

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ elif ! steady_is_running ; then
4343
echo -e "To run the server, pass in the path or url of your OpenAPI"
4444
echo -e "spec to the steady command:"
4545
echo
46-
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
46+
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
4747
echo
4848

4949
exit 1

src/client.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ export interface ClientOptions {
341341
*/
342342
profile?: string | null | undefined;
343343

344+
/**
345+
* Defaults to process.env['ANTHROPIC_WEBHOOK_SIGNING_KEY'].
346+
*/
347+
webhookKey?: string | null | undefined;
348+
344349
/**
345350
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
346351
*
@@ -425,6 +430,7 @@ export const AI_PROMPT = '\\n\\nAssistant:';
425430
export class BaseAnthropic {
426431
apiKey: string | null;
427432
authToken: string | null;
433+
webhookKey: string | null;
428434

429435
/**
430436
* The active credential provider. Default credential resolution runs once
@@ -460,6 +466,7 @@ export class BaseAnthropic {
460466
*
461467
* @param {string | null | undefined} [opts.apiKey=process.env['ANTHROPIC_API_KEY'] ?? null]
462468
* @param {string | null | undefined} [opts.authToken=process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
469+
* @param {string | null | undefined} [opts.webhookKey=process.env['ANTHROPIC_WEBHOOK_SIGNING_KEY'] ?? null]
463470
* @param {string} [opts.baseURL=process.env['ANTHROPIC_BASE_URL'] ?? https://api.anthropic.com] - Override the default base URL for the API.
464471
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
465472
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -469,7 +476,13 @@ export class BaseAnthropic {
469476
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
470477
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
471478
*/
472-
constructor({ baseURL = readEnv('ANTHROPIC_BASE_URL'), apiKey, authToken, ...opts }: ClientOptions = {}) {
479+
constructor({
480+
baseURL = readEnv('ANTHROPIC_BASE_URL'),
481+
apiKey,
482+
authToken,
483+
webhookKey = readEnv('ANTHROPIC_WEBHOOK_SIGNING_KEY') ?? null,
484+
...opts
485+
}: ClientOptions = {}) {
473486
// An explicit `profile` is a constructor-level credential choice; when set,
474487
// do not let env ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN shadow it.
475488
if (apiKey === undefined) {
@@ -484,6 +497,7 @@ export class BaseAnthropic {
484497
const options: ClientOptions = {
485498
apiKey,
486499
authToken,
500+
webhookKey,
487501
...opts,
488502
baseURL: baseURL || `https://api.anthropic.com`,
489503
};
@@ -538,6 +552,7 @@ export class BaseAnthropic {
538552

539553
this.apiKey = typeof apiKey === 'string' ? apiKey : null;
540554
this.authToken = authToken;
555+
this.webhookKey = webhookKey;
541556

542557
if (inherited) {
543558
this._authState = inherited;
@@ -644,6 +659,7 @@ export class BaseAnthropic {
644659
fetchOptions: this.fetchOptions,
645660
apiKey: this.apiKey,
646661
authToken: this.authToken,
662+
webhookKey: this.webhookKey,
647663
// credentials: this.credentials is a no-op when __auth is shared (the
648664
// ctor takes the inherited path and ignores options.credentials); when
649665
// overridesAuth is true via apiKey/authToken only, it lets the clone
@@ -780,9 +796,6 @@ export class BaseAnthropic {
780796
return buildHeaders([{ Authorization: `Bearer ${this.authToken}` }]);
781797
}
782798

783-
/**
784-
* Basic re-implementation of `qs.stringify` for primitive types.
785-
*/
786799
protected stringifyQuery(query: object | Record<string, unknown>): string {
787800
return stringifyQuery(query);
788801
}

src/core/streaming.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,21 @@ export class Stream<Item> implements AsyncIterable<Item> {
8686
sse.event === 'session.error' ||
8787
sse.event === 'session.deleted' ||
8888
sse.event === 'span.model_request_start' ||
89-
sse.event === 'span.model_request_end'
89+
sse.event === 'span.model_request_end' ||
90+
sse.event === 'span.outcome_evaluation_start' ||
91+
sse.event === 'span.outcome_evaluation_ongoing' ||
92+
sse.event === 'span.outcome_evaluation_end' ||
93+
sse.event === 'user.define_outcome' ||
94+
sse.event === 'agent.thread_message_received' ||
95+
sse.event === 'agent.thread_message_sent' ||
96+
sse.event === 'agent.session_thread_message_received' ||
97+
sse.event === 'agent.session_thread_message_sent' ||
98+
sse.event === 'session.thread_created' ||
99+
sse.event === 'session.thread_status_created' ||
100+
sse.event === 'session.thread_status_running' ||
101+
sse.event === 'session.thread_status_idle' ||
102+
sse.event === 'session.thread_status_rescheduled' ||
103+
sse.event === 'session.thread_status_terminated'
90104
) {
91105
try {
92106
yield JSON.parse(sse.data) as Item;

0 commit comments

Comments
 (0)