Skip to content

Commit 927cab6

Browse files
feat: Per Invocation Logs
1 parent c1350d3 commit 927cab6

File tree

6 files changed

+32
-4
lines changed

6 files changed

+32
-4
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 50
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-d3a597bbbb25c131e2c06eb9b47d70932d14a97a6f916677a195a128e196f4db.yml
3-
openapi_spec_hash: c967b384624017eed0abff1b53a74530
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5ee2116982adf46664acf84b8ba4b56ba65780983506c63d9b005dab49def757.yml
3+
openapi_spec_hash: 42a3a519301d0e2bb2b5a71018915b55
44
config_hash: 0d150b61cae2dc57d3648ceae7784966

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Methods:
5252
- <code title="get /invocations/{id}">client.invocations.<a href="./src/resources/invocations.ts">retrieve</a>(id) -> InvocationRetrieveResponse</code>
5353
- <code title="patch /invocations/{id}">client.invocations.<a href="./src/resources/invocations.ts">update</a>(id, { ...params }) -> InvocationUpdateResponse</code>
5454
- <code title="delete /invocations/{id}/browsers">client.invocations.<a href="./src/resources/invocations.ts">deleteBrowsers</a>(id) -> void</code>
55-
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/resources/invocations.ts">follow</a>(id) -> InvocationFollowResponse</code>
55+
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/resources/invocations.ts">follow</a>(id, { ...params }) -> InvocationFollowResponse</code>
5656

5757
# Browsers
5858

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { KernelApp } from './core/app-framework';
3535
import {
3636
InvocationCreateParams,
3737
InvocationCreateResponse,
38+
InvocationFollowParams,
3839
InvocationFollowResponse,
3940
InvocationRetrieveResponse,
4041
InvocationStateEvent,
@@ -870,6 +871,7 @@ export declare namespace Kernel {
870871
type InvocationFollowResponse as InvocationFollowResponse,
871872
type InvocationCreateParams as InvocationCreateParams,
872873
type InvocationUpdateParams as InvocationUpdateParams,
874+
type InvocationFollowParams as InvocationFollowParams,
873875
};
874876

875877
export {

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
type InvocationFollowResponse,
3434
type InvocationCreateParams,
3535
type InvocationUpdateParams,
36+
type InvocationFollowParams,
3637
} from './invocations';
3738
export { Profiles, type ProfileListResponse, type ProfileCreateParams } from './profiles';
3839
export {

src/resources/invocations.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ export class Invocations extends APIResource {
8383
* const response = await client.invocations.follow('id');
8484
* ```
8585
*/
86-
follow(id: string, options?: RequestOptions): APIPromise<Stream<InvocationFollowResponse>> {
86+
follow(
87+
id: string,
88+
query: InvocationFollowParams | undefined = {},
89+
options?: RequestOptions,
90+
): APIPromise<Stream<InvocationFollowResponse>> {
8791
return this._client.get(path`/invocations/${id}/events`, {
92+
query,
8893
...options,
8994
headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
9095
stream: true,
@@ -335,6 +340,13 @@ export interface InvocationUpdateParams {
335340
output?: string;
336341
}
337342

343+
export interface InvocationFollowParams {
344+
/**
345+
* Show logs since the given time (RFC timestamps or durations like 5m).
346+
*/
347+
since?: string;
348+
}
349+
338350
export declare namespace Invocations {
339351
export {
340352
type InvocationStateEvent as InvocationStateEvent,
@@ -344,5 +356,6 @@ export declare namespace Invocations {
344356
type InvocationFollowResponse as InvocationFollowResponse,
345357
type InvocationCreateParams as InvocationCreateParams,
346358
type InvocationUpdateParams as InvocationUpdateParams,
359+
type InvocationFollowParams as InvocationFollowParams,
347360
};
348361
}

tests/api-resources/invocations.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,16 @@ describe('resource invocations', () => {
8787
expect(dataAndResponse.data).toBe(response);
8888
expect(dataAndResponse.response).toBe(rawResponse);
8989
});
90+
91+
// Prism doesn't support text/event-stream responses
92+
test.skip('follow: request options and params are passed correctly', async () => {
93+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
94+
await expect(
95+
client.invocations.follow(
96+
'id',
97+
{ since: '2025-06-20T12:00:00Z' },
98+
{ path: '/_stainless_unknown_path' },
99+
),
100+
).rejects.toThrow(Kernel.NotFoundError);
101+
});
90102
});

0 commit comments

Comments
 (0)