Skip to content

Commit 81f048a

Browse files
feat: [beta] adding axon, an event communication channel (#8268)
1 parent 049b89c commit 81f048a

6 files changed

Lines changed: 284 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 117
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-64b2ded3d3cc58131c7ebf36c411f43c3d8dabae0b5b1edd65dd7dab307c54a1.yml
3-
openapi_spec_hash: 80fabb5e89a61299203113505a894dc2
4-
config_hash: de99cfce88e2d1f02246dc6c2f43bc6c
1+
configured_endpoints: 122
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-d3f6f5cc574b570bb31c768e755f957273a97846257c7144ff5c0dcf7c00fd75.yml
3+
openapi_spec_hash: 8d7f2b3ed5c1504d3d238e0e43d45383
4+
config_hash: 1b42d9862d8d811030df0ac4094f7a1d

api.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ Methods:
7676
- <code title="get /v1/agents/{id}">client.agents.<a href="./src/resources/agents.ts">retrieve</a>(id) -> AgentView</code>
7777
- <code title="get /v1/agents">client.agents.<a href="./src/resources/agents.ts">list</a>({ ...params }) -> AgentViewsAgentsCursorIDPage</code>
7878

79+
# Axons
80+
81+
Types:
82+
83+
- <code><a href="./src/resources/axons.ts">AxonCreateParams</a></code>
84+
- <code><a href="./src/resources/axons.ts">AxonListView</a></code>
85+
- <code><a href="./src/resources/axons.ts">AxonView</a></code>
86+
- <code><a href="./src/resources/axons.ts">PublishParams</a></code>
87+
- <code><a href="./src/resources/axons.ts">PublishResultView</a></code>
88+
89+
Methods:
90+
91+
- <code title="post /v1/axons">client.axons.<a href="./src/resources/axons.ts">create</a>() -> AxonView</code>
92+
- <code title="get /v1/axons/{id}">client.axons.<a href="./src/resources/axons.ts">retrieve</a>(id) -> AxonView</code>
93+
- <code title="get /v1/axons">client.axons.<a href="./src/resources/axons.ts">list</a>() -> AxonListView</code>
94+
- <code title="post /v1/axons/{id}/publish">client.axons.<a href="./src/resources/axons.ts">publish</a>(id, { ...params }) -> PublishResultView</code>
95+
- <code title="get /v1/axons/{id}/subscribe/sse">client.axons.<a href="./src/resources/axons.ts">subscribeSse</a>(id) -> void</code>
96+
7997
# Blueprints
8098

8199
Types:

src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ import {
4545
AgentViewsAgentsCursorIDPage,
4646
Agents,
4747
} from './resources/agents';
48+
import {
49+
AxonCreateParams,
50+
AxonListView,
51+
AxonPublishParams,
52+
AxonView,
53+
Axons,
54+
PublishParams,
55+
PublishResultView,
56+
} from './resources/axons';
4857
import {
4958
BenchmarkJobCreateParameters,
5059
BenchmarkJobCreateParams,
@@ -363,6 +372,7 @@ export class Runloop extends Core.APIClient {
363372
benchmarkRuns: API.BenchmarkRuns = new API.BenchmarkRuns(this);
364373
benchmarkJobs: API.BenchmarkJobs = new API.BenchmarkJobs(this);
365374
agents: API.Agents = new API.Agents(this);
375+
axons: API.Axons = new API.Axons(this);
366376
blueprints: API.Blueprints = new API.Blueprints(this);
367377
devboxes: API.Devboxes = new API.Devboxes(this);
368378
scenarios: API.Scenarios = new API.Scenarios(this);
@@ -423,6 +433,7 @@ Runloop.BenchmarkRunViewsBenchmarkRunsCursorIDPage = BenchmarkRunViewsBenchmarkR
423433
Runloop.BenchmarkJobs = BenchmarkJobs;
424434
Runloop.Agents = Agents;
425435
Runloop.AgentViewsAgentsCursorIDPage = AgentViewsAgentsCursorIDPage;
436+
Runloop.Axons = Axons;
426437
Runloop.Blueprints = Blueprints;
427438
Runloop.BlueprintViewsBlueprintsCursorIDPage = BlueprintViewsBlueprintsCursorIDPage;
428439
Runloop.Devboxes = Devboxes;
@@ -575,6 +586,16 @@ export declare namespace Runloop {
575586
type AgentListParams as AgentListParams,
576587
};
577588

589+
export {
590+
Axons as Axons,
591+
type AxonCreateParams as AxonCreateParams,
592+
type AxonListView as AxonListView,
593+
type AxonView as AxonView,
594+
type PublishParams as PublishParams,
595+
type PublishResultView as PublishResultView,
596+
type AxonPublishParams as AxonPublishParams,
597+
};
598+
578599
export {
579600
Blueprints as Blueprints,
580601
type BlueprintBuildFromInspectionParameters as BlueprintBuildFromInspectionParameters,

src/resources/axons.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../resource';
4+
import * as Core from '../core';
5+
6+
export class Axons extends APIResource {
7+
/**
8+
* [Beta] Create a new axon.
9+
*/
10+
create(
11+
body?: AxonCreateParams | null | undefined,
12+
options?: Core.RequestOptions,
13+
): Core.APIPromise<AxonView> {
14+
return this._client.post('/v1/axons', { body, ...options });
15+
}
16+
17+
/**
18+
* [Beta] Get an axon given ID.
19+
*/
20+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<AxonView> {
21+
return this._client.get(`/v1/axons/${id}`, options);
22+
}
23+
24+
/**
25+
* [Beta] List all active axons.
26+
*/
27+
list(options?: Core.RequestOptions): Core.APIPromise<AxonListView> {
28+
return this._client.get('/v1/axons', options);
29+
}
30+
31+
/**
32+
* [Beta] Publish an event to a specified axon.
33+
*/
34+
publish(
35+
id: string,
36+
body: AxonPublishParams,
37+
options?: Core.RequestOptions,
38+
): Core.APIPromise<PublishResultView> {
39+
return this._client.post(`/v1/axons/${id}/publish`, { body, ...options });
40+
}
41+
}
42+
43+
export type AxonCreateParams = unknown;
44+
45+
export interface AxonListView {
46+
/**
47+
* List of active axons.
48+
*/
49+
axons: Array<AxonView>;
50+
}
51+
52+
export interface AxonView {
53+
/**
54+
* The axon identifier.
55+
*/
56+
id: string;
57+
58+
/**
59+
* Creation time in milliseconds since epoch.
60+
*/
61+
created_at_ms: number;
62+
}
63+
64+
export interface PublishParams {
65+
/**
66+
* The event type (e.g. push, pull_request).
67+
*/
68+
event_type: string;
69+
70+
/**
71+
* Event origin.
72+
*/
73+
origin: 'EXTERNAL_EVENT' | 'AGENT_EVENT' | 'USER_EVENT';
74+
75+
/**
76+
* Event payload.
77+
*/
78+
payload: string;
79+
80+
/**
81+
* The source of the event (e.g. github, slack).
82+
*/
83+
source: string;
84+
}
85+
86+
export interface PublishResultView {
87+
/**
88+
* Assigned sequence number.
89+
*/
90+
sequence: number;
91+
92+
/**
93+
* Timestamp in milliseconds since epoch.
94+
*/
95+
timestamp_ms: number;
96+
}
97+
98+
export interface AxonCreateParams {}
99+
100+
export interface AxonPublishParams {
101+
/**
102+
* The event type (e.g. push, pull_request).
103+
*/
104+
event_type: string;
105+
106+
/**
107+
* Event origin.
108+
*/
109+
origin: 'EXTERNAL_EVENT' | 'AGENT_EVENT' | 'USER_EVENT';
110+
111+
/**
112+
* Event payload.
113+
*/
114+
payload: string;
115+
116+
/**
117+
* The source of the event (e.g. github, slack).
118+
*/
119+
source: string;
120+
}
121+
122+
export declare namespace Axons {
123+
export {
124+
type AxonCreateParams as AxonCreateParams,
125+
type AxonListView as AxonListView,
126+
type AxonView as AxonView,
127+
type PublishParams as PublishParams,
128+
type PublishResultView as PublishResultView,
129+
type AxonPublishParams as AxonPublishParams,
130+
};
131+
}

src/resources/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ export {
1010
type AgentCreateParams,
1111
type AgentListParams,
1212
} from './agents';
13+
export {
14+
Axons,
15+
type AxonCreateParams,
16+
type AxonListView,
17+
type AxonView,
18+
type PublishParams,
19+
type PublishResultView,
20+
type AxonPublishParams,
21+
} from './axons';
1322
export {
1423
BenchmarkJobs,
1524
type BenchmarkJobCreateParameters,

tests/api-resources/axons.test.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Runloop from '@runloop/api-client';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Runloop({
7+
bearerToken: 'My Bearer Token',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource axons', () => {
12+
test('create', async () => {
13+
const responsePromise = client.axons.create();
14+
const rawResponse = await responsePromise.asResponse();
15+
expect(rawResponse).toBeInstanceOf(Response);
16+
const response = await responsePromise;
17+
expect(response).not.toBeInstanceOf(Response);
18+
const dataAndResponse = await responsePromise.withResponse();
19+
expect(dataAndResponse.data).toBe(response);
20+
expect(dataAndResponse.response).toBe(rawResponse);
21+
});
22+
23+
test('create: request options and params are passed correctly', async () => {
24+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
25+
await expect(client.axons.create({}, { path: '/_stainless_unknown_path' })).rejects.toThrow(
26+
Runloop.NotFoundError,
27+
);
28+
});
29+
30+
test('retrieve', async () => {
31+
const responsePromise = client.axons.retrieve('id');
32+
const rawResponse = await responsePromise.asResponse();
33+
expect(rawResponse).toBeInstanceOf(Response);
34+
const response = await responsePromise;
35+
expect(response).not.toBeInstanceOf(Response);
36+
const dataAndResponse = await responsePromise.withResponse();
37+
expect(dataAndResponse.data).toBe(response);
38+
expect(dataAndResponse.response).toBe(rawResponse);
39+
});
40+
41+
test('retrieve: request options instead of params are passed correctly', async () => {
42+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
43+
await expect(client.axons.retrieve('id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
44+
Runloop.NotFoundError,
45+
);
46+
});
47+
48+
test('list', async () => {
49+
const responsePromise = client.axons.list();
50+
const rawResponse = await responsePromise.asResponse();
51+
expect(rawResponse).toBeInstanceOf(Response);
52+
const response = await responsePromise;
53+
expect(response).not.toBeInstanceOf(Response);
54+
const dataAndResponse = await responsePromise.withResponse();
55+
expect(dataAndResponse.data).toBe(response);
56+
expect(dataAndResponse.response).toBe(rawResponse);
57+
});
58+
59+
test('list: request options instead of params are passed correctly', async () => {
60+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
61+
await expect(client.axons.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
62+
Runloop.NotFoundError,
63+
);
64+
});
65+
66+
test('publish: only required params', async () => {
67+
const responsePromise = client.axons.publish('id', {
68+
event_type: 'event_type',
69+
origin: 'EXTERNAL_EVENT',
70+
payload: 'payload',
71+
source: 'source',
72+
});
73+
const rawResponse = await responsePromise.asResponse();
74+
expect(rawResponse).toBeInstanceOf(Response);
75+
const response = await responsePromise;
76+
expect(response).not.toBeInstanceOf(Response);
77+
const dataAndResponse = await responsePromise.withResponse();
78+
expect(dataAndResponse.data).toBe(response);
79+
expect(dataAndResponse.response).toBe(rawResponse);
80+
});
81+
82+
test('publish: required and optional params', async () => {
83+
const response = await client.axons.publish('id', {
84+
event_type: 'event_type',
85+
origin: 'EXTERNAL_EVENT',
86+
payload: 'payload',
87+
source: 'source',
88+
});
89+
});
90+
91+
test('subscribeSse', async () => {
92+
const responsePromise = client.axons.subscribeSse('id');
93+
const rawResponse = await responsePromise.asResponse();
94+
expect(rawResponse).toBeInstanceOf(Response);
95+
const response = await responsePromise;
96+
expect(response).not.toBeInstanceOf(Response);
97+
const dataAndResponse = await responsePromise.withResponse();
98+
expect(dataAndResponse.data).toBe(response);
99+
expect(dataAndResponse.response).toBe(rawResponse);
100+
});
101+
});

0 commit comments

Comments
 (0)