@introspection-sdk/introspection-node 0.5.0 → 0.5.1
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/.turbo/turbo-build.log +1 -1
- package/dist/pagination.d.ts +38 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +43 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/experiments.d.ts +6 -4
- package/dist/resources/experiments.d.ts.map +1 -1
- package/dist/resources/experiments.js +11 -15
- package/dist/resources/experiments.js.map +1 -1
- package/dist/resources/recipes.d.ts +6 -4
- package/dist/resources/recipes.d.ts.map +1 -1
- package/dist/resources/recipes.js +11 -15
- package/dist/resources/recipes.js.map +1 -1
- package/dist/resources/runtimes.d.ts +6 -4
- package/dist/resources/runtimes.d.ts.map +1 -1
- package/dist/resources/runtimes.js +11 -15
- package/dist/resources/runtimes.js.map +1 -1
- package/dist/runner-resources/conversations.d.ts +14 -10
- package/dist/runner-resources/conversations.d.ts.map +1 -1
- package/dist/runner-resources/conversations.js +24 -30
- package/dist/runner-resources/conversations.js.map +1 -1
- package/dist/runner-resources/files.d.ts +14 -11
- package/dist/runner-resources/files.d.ts.map +1 -1
- package/dist/runner-resources/files.js +31 -36
- package/dist/runner-resources/files.js.map +1 -1
- package/dist/runner-resources/tasks.d.ts +6 -4
- package/dist/runner-resources/tasks.d.ts.map +1 -1
- package/dist/runner-resources/tasks.js +11 -15
- package/dist/runner-resources/tasks.js.map +1 -1
- package/package.json +6 -6
- package/src/pagination.ts +69 -0
- package/src/resources/experiments.ts +15 -14
- package/src/resources/recipes.ts +15 -14
- package/src/resources/runtimes.ts +15 -14
- package/src/runner-resources/conversations.ts +37 -33
- package/src/runner-resources/files.ts +52 -37
- package/src/runner-resources/tasks.ts +15 -14
|
@@ -1,24 +1,20 @@
|
|
|
1
|
+
import { cursorPaginate } from "../pagination.js";
|
|
1
2
|
export class FileVersionsApi {
|
|
2
3
|
http;
|
|
3
4
|
constructor(http) {
|
|
4
5
|
this.http = http;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* List versions of a file. `await` the result for the first page, or
|
|
9
|
+
* `for await` it to stream every version across pages (fetched lazily;
|
|
10
|
+
* stop early to stop fetching).
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
query: { ...params, next },
|
|
17
|
-
});
|
|
18
|
-
for (const f of page.records)
|
|
19
|
-
yield f;
|
|
20
|
-
next = page.next ?? undefined;
|
|
21
|
-
} while (next);
|
|
12
|
+
list(fileId, params) {
|
|
13
|
+
return cursorPaginate((next) => this.http.request({
|
|
14
|
+
method: "GET",
|
|
15
|
+
path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
|
|
16
|
+
query: { ...params, next },
|
|
17
|
+
}), params?.next);
|
|
22
18
|
}
|
|
23
19
|
get(fileId, versionId) {
|
|
24
20
|
return this.http.request({
|
|
@@ -26,8 +22,8 @@ export class FileVersionsApi {
|
|
|
26
22
|
path: `/v1/files/${encodeURIComponent(fileId)}/versions/${encodeURIComponent(versionId)}`,
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
|
-
create(fileId, body) {
|
|
30
|
-
const form = toFormData(body);
|
|
25
|
+
create(fileId, body, options) {
|
|
26
|
+
const form = toFormData(body, options);
|
|
31
27
|
return this.http.request({
|
|
32
28
|
method: "POST",
|
|
33
29
|
path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
|
|
@@ -43,36 +39,33 @@ export class FilesApi {
|
|
|
43
39
|
this.versions = new FileVersionsApi(http);
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* starting cursor
|
|
42
|
+
* List files matching `params`. `await` the result for the first page,
|
|
43
|
+
* or `for await` it to stream every file across pages (fetched lazily —
|
|
44
|
+
* `limit` sets the page size, `next` the starting cursor; stop early to
|
|
45
|
+
* stop fetching).
|
|
49
46
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
query: { ...params, next },
|
|
57
|
-
});
|
|
58
|
-
for (const f of page.records)
|
|
59
|
-
yield f;
|
|
60
|
-
next = page.next ?? undefined;
|
|
61
|
-
} while (next);
|
|
47
|
+
list(params) {
|
|
48
|
+
return cursorPaginate((next) => this.http.request({
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: "/v1/files",
|
|
51
|
+
query: { ...params, next },
|
|
52
|
+
}), params?.next);
|
|
62
53
|
}
|
|
63
|
-
upload(body) {
|
|
64
|
-
const form = toFormData(body);
|
|
54
|
+
upload(body, options) {
|
|
55
|
+
const form = toFormData(body, options);
|
|
65
56
|
return this.http.request({
|
|
66
57
|
method: "POST",
|
|
67
58
|
path: "/v1/files",
|
|
68
59
|
body: form,
|
|
69
60
|
});
|
|
70
61
|
}
|
|
71
|
-
createText(body) {
|
|
62
|
+
createText(body, options) {
|
|
72
63
|
return this.http.request({
|
|
73
64
|
method: "POST",
|
|
74
65
|
path: "/v1/files",
|
|
75
|
-
body
|
|
66
|
+
body: options?.visibility
|
|
67
|
+
? { ...body, visibility: options.visibility }
|
|
68
|
+
: body,
|
|
76
69
|
});
|
|
77
70
|
}
|
|
78
71
|
get(fileId) {
|
|
@@ -110,7 +103,7 @@ export class FilesApi {
|
|
|
110
103
|
});
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
|
-
function toFormData(body) {
|
|
106
|
+
function toFormData(body, options) {
|
|
114
107
|
const fd = new FormData();
|
|
115
108
|
if ("file" in body && body.file instanceof Blob) {
|
|
116
109
|
fd.append("file", body.file, body.name);
|
|
@@ -129,6 +122,8 @@ function toFormData(body) {
|
|
|
129
122
|
fd.append("name", body.name);
|
|
130
123
|
if (body.file_type)
|
|
131
124
|
fd.append("file_type", body.file_type);
|
|
125
|
+
if (options?.visibility)
|
|
126
|
+
fd.append("visibility", options.visibility);
|
|
132
127
|
return fd;
|
|
133
128
|
}
|
|
134
129
|
//# sourceMappingURL=files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/runner-resources/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/runner-resources/files.ts"],"names":[],"mappings":"AAWA,OAAO,EAAa,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAW7D,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;OAIG;IACH,IAAI,CAAC,MAAc,EAAE,MAAmB;QACtC,OAAO,cAAc,CACnB,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,CAAC,OAAO,CAA0B;YACzC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,aAAa,kBAAkB,CAAC,MAAM,CAAC,WAAW;YACxD,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAA6B;SACtD,CAAC,EACJ,MAAM,EAAE,IAAI,CACb,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,MAAc,EAAE,SAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAe;YACrC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,aAAa,kBAAkB,CAAC,MAAM,CAAC,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE;SAC1F,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CACJ,MAAc,EACd,IAAoB,EACpB,OAA2B;QAE3B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAe;YACrC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,aAAa,kBAAkB,CAAC,MAAM,CAAC,WAAW;YACxD,IAAI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IAAI,CAAC;QAC/C,MAAM,EAAE,GACL,IAAiC,CAAC,WAAW;YAC9C,0BAA0B,CAAC;QAC7B,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CACxB,EAAE,CAAC,UAAU,EACb,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CACf,CAAC;QACjB,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,IAAI,CAAC,IAAI;QAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,CAAC,SAAS;QAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,OAAO,EAAE,UAAU;QAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrE,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SseEvent, Task, TaskCancelResponse, TaskCreateParams, TaskCreateResponse, TaskListParams, TaskRun, TaskRunCreateParams, TaskUpdateParams } from "@introspection-sdk/types";
|
|
2
2
|
import { HttpClient } from "../http.js";
|
|
3
|
+
import { Paginator } from "../pagination.js";
|
|
3
4
|
export interface StartParams extends TaskCreateParams {
|
|
4
5
|
prompt: string;
|
|
5
6
|
}
|
|
@@ -26,11 +27,12 @@ export declare class TasksApi {
|
|
|
26
27
|
readonly runs: TaskRunsApi;
|
|
27
28
|
constructor(http: HttpClient);
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* starting cursor
|
|
30
|
+
* List tasks matching `params`. `await` the result for the first page,
|
|
31
|
+
* or `for await` it to stream every task across pages (fetched lazily —
|
|
32
|
+
* `limit` sets the page size, `next` the starting cursor; stop early to
|
|
33
|
+
* stop fetching).
|
|
32
34
|
*/
|
|
33
|
-
list(params?: TaskListParams):
|
|
35
|
+
list(params?: TaskListParams): Paginator<Task>;
|
|
34
36
|
create(body: TaskCreateParams): Promise<TaskCreateResponse>;
|
|
35
37
|
get(taskId: string): Promise<Task>;
|
|
36
38
|
update(taskId: string, body: TaskUpdateParams): Promise<Task>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/runner-resources/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/runner-resources/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,SAAS;aAEF,IAAI,EAAE,IAAI,GAAG,IAAI;aACjB,GAAG,EAAE,OAAO;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFL,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,GAAG,EAAE,OAAO,EACX,IAAI,EAA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AM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,8EAA8E;IACxE,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;CAIrD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cursorPaginate } from "../pagination.js";
|
|
1
2
|
import { parseSse } from "../streaming.js";
|
|
2
3
|
export class RunHandle {
|
|
3
4
|
task;
|
|
@@ -64,22 +65,17 @@ export class TasksApi {
|
|
|
64
65
|
this.runs = new TaskRunsApi(http);
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* starting cursor
|
|
68
|
+
* List tasks matching `params`. `await` the result for the first page,
|
|
69
|
+
* or `for await` it to stream every task across pages (fetched lazily —
|
|
70
|
+
* `limit` sets the page size, `next` the starting cursor; stop early to
|
|
71
|
+
* stop fetching).
|
|
70
72
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
query: { ...params, next },
|
|
78
|
-
});
|
|
79
|
-
for (const t of page.records)
|
|
80
|
-
yield t;
|
|
81
|
-
next = page.next ?? undefined;
|
|
82
|
-
} while (next);
|
|
73
|
+
list(params) {
|
|
74
|
+
return cursorPaginate((next) => this.http.request({
|
|
75
|
+
method: "GET",
|
|
76
|
+
path: "/v1/tasks",
|
|
77
|
+
query: { ...params, next },
|
|
78
|
+
}), params?.next);
|
|
83
79
|
}
|
|
84
80
|
create(body) {
|
|
85
81
|
return this.http.request({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/runner-resources/tasks.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAM3C,MAAM,OAAO,SAAS;IAEF;IACA;IACC;IAHnB,YACkB,IAAiB,EACjB,GAAY,EACX,IAAiB;QAFlB,S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6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@introspection-sdk/introspection-node",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Introspection observability SDK for Node.js",
|
|
6
6
|
"engines": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"ai": "^6.0.197",
|
|
57
57
|
"openai": "^6.42.0",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
|
-
"@repo/
|
|
60
|
-
"@repo/
|
|
59
|
+
"@repo/eslint-config": "0.0.0",
|
|
60
|
+
"@repo/typescript-config": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@openai/agents": ">=0.0.1",
|
|
@@ -139,9 +139,9 @@
|
|
|
139
139
|
"@opentelemetry/api": "^1.9.1",
|
|
140
140
|
"https-proxy-agent": "^7.0.6",
|
|
141
141
|
"proxy-from-env": "^2.1.0",
|
|
142
|
-
"@introspection-sdk/types": "0.5.
|
|
143
|
-
"@introspection-sdk/introspection-
|
|
144
|
-
"@introspection-sdk/introspection-
|
|
142
|
+
"@introspection-sdk/types": "0.5.1",
|
|
143
|
+
"@introspection-sdk/introspection-pi": "0.5.1",
|
|
144
|
+
"@introspection-sdk/introspection-proxy": "0.5.1"
|
|
145
145
|
},
|
|
146
146
|
"scripts": {
|
|
147
147
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Paginated } from "@introspection-sdk/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adapts a wire pagination protocol for {@link Paginator}: how to fetch
|
|
5
|
+
* a page at a given cursor, pull the items out of it, and find the
|
|
6
|
+
* cursor for the next page (`undefined` once the list is exhausted).
|
|
7
|
+
*/
|
|
8
|
+
export interface PageSource<T, TPage> {
|
|
9
|
+
/** Fetch the page at `cursor` (`undefined` = the first page). */
|
|
10
|
+
fetch(cursor: string | undefined): Promise<TPage>;
|
|
11
|
+
/** Items contained in `page`, in iteration order. */
|
|
12
|
+
items(page: TPage): T[];
|
|
13
|
+
/** Cursor for the page after `page`, or `undefined` when exhausted. */
|
|
14
|
+
next(page: TPage): string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A lazy, auto-paging collection.
|
|
19
|
+
*
|
|
20
|
+
* - `await listing` resolves to the FIRST page, preserving the wire
|
|
21
|
+
* envelope's metadata (counts, `has_more`, …).
|
|
22
|
+
* - `for await (const item of listing)` streams every item across all
|
|
23
|
+
* pages, fetching each page only as the iterator reaches it; stop
|
|
24
|
+
* early to stop fetching.
|
|
25
|
+
*/
|
|
26
|
+
export class Paginator<T, TPage = Paginated<T>>
|
|
27
|
+
implements AsyncIterable<T>, PromiseLike<TPage>
|
|
28
|
+
{
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly source: PageSource<T, TPage>,
|
|
31
|
+
private readonly start?: string,
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
/** Thenable: resolves to the first page (no further pages fetched). */
|
|
35
|
+
then<R1 = TPage, R2 = never>(
|
|
36
|
+
onfulfilled?: ((page: TPage) => R1 | PromiseLike<R1>) | null,
|
|
37
|
+
onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,
|
|
38
|
+
): PromiseLike<R1 | R2> {
|
|
39
|
+
return this.source.fetch(this.start).then(onfulfilled, onrejected);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async *[Symbol.asyncIterator](): AsyncIterator<T> {
|
|
43
|
+
let cursor = this.start;
|
|
44
|
+
do {
|
|
45
|
+
const page = await this.source.fetch(cursor);
|
|
46
|
+
for (const item of this.source.items(page)) yield item;
|
|
47
|
+
cursor = this.source.next(page);
|
|
48
|
+
} while (cursor !== undefined);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Build a {@link Paginator} over the standard Introspection cursor
|
|
54
|
+
* envelope ({@link Paginated}): items live in `records` and the next
|
|
55
|
+
* page is reached via the opaque `next` token.
|
|
56
|
+
*/
|
|
57
|
+
export function cursorPaginate<T>(
|
|
58
|
+
fetch: (next: string | undefined) => Promise<Paginated<T>>,
|
|
59
|
+
start?: string,
|
|
60
|
+
): Paginator<T, Paginated<T>> {
|
|
61
|
+
return new Paginator(
|
|
62
|
+
{
|
|
63
|
+
fetch,
|
|
64
|
+
items: (page) => page.records,
|
|
65
|
+
next: (page) => page.next ?? undefined,
|
|
66
|
+
},
|
|
67
|
+
start,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
} from "@introspection-sdk/types";
|
|
12
12
|
import type { HttpClient } from "../http.js";
|
|
13
13
|
import type { IntrospectionClient } from "../client.js";
|
|
14
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
14
15
|
import { Runner, type RunnerSource } from "../runner.js";
|
|
15
16
|
|
|
16
17
|
interface ExperimentRunRequestBody {
|
|
@@ -37,21 +38,21 @@ export class ExperimentsApi {
|
|
|
37
38
|
) {}
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* List experiments matching `params`. `await` the result for the first
|
|
42
|
+
* page, or `for await` it to stream every experiment across pages
|
|
43
|
+
* (fetched lazily — `limit` sets the page size, `next` the starting
|
|
44
|
+
* cursor; stop early to stop fetching).
|
|
43
45
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} while (next);
|
|
46
|
+
list(params: ExperimentListParams): Paginator<Experiment> {
|
|
47
|
+
return cursorPaginate(
|
|
48
|
+
(next) =>
|
|
49
|
+
this.http.request<Paginated<Experiment>>({
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: "/v1/experiments",
|
|
52
|
+
query: { ...params, next } as unknown as Record<string, unknown>,
|
|
53
|
+
}),
|
|
54
|
+
params.next,
|
|
55
|
+
);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
get(id: Uuid): Promise<Experiment> {
|
package/src/resources/recipes.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
Uuid,
|
|
8
8
|
} from "@introspection-sdk/types";
|
|
9
9
|
import type { HttpClient } from "../http.js";
|
|
10
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Programmatic CRUD for `/v1/recipes` on the CP.
|
|
@@ -19,21 +20,21 @@ export class RecipesApi {
|
|
|
19
20
|
constructor(private readonly http: HttpClient) {}
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* starting cursor
|
|
23
|
+
* List recipes matching `params`. `await` the result for the first
|
|
24
|
+
* page, or `for await` it to stream every recipe across pages (fetched
|
|
25
|
+
* lazily — `limit` sets the page size, `next` the starting cursor; stop
|
|
26
|
+
* early to stop fetching).
|
|
25
27
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} while (next);
|
|
28
|
+
list(params: RecipeListParams): Paginator<Recipe> {
|
|
29
|
+
return cursorPaginate(
|
|
30
|
+
(next) =>
|
|
31
|
+
this.http.request<Paginated<Recipe>>({
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/v1/recipes",
|
|
34
|
+
query: { ...params, next } as unknown as Record<string, unknown>,
|
|
35
|
+
}),
|
|
36
|
+
params.next,
|
|
37
|
+
);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
get(id: Uuid): Promise<Recipe> {
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
import { NotFoundError } from "@introspection-sdk/types";
|
|
13
13
|
import type { HttpClient } from "../http.js";
|
|
14
14
|
import type { IntrospectionClient } from "../client.js";
|
|
15
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
15
16
|
import { Runner, type RunnerSource } from "../runner.js";
|
|
16
17
|
|
|
17
18
|
const UUID_RE =
|
|
@@ -51,21 +52,21 @@ export class RuntimesApi {
|
|
|
51
52
|
) {}
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* starting cursor
|
|
55
|
+
* List runtimes matching `params`. `await` the result for the first
|
|
56
|
+
* page, or `for await` it to stream every runtime across pages (fetched
|
|
57
|
+
* lazily — `limit` sets the page size, `next` the starting cursor; stop
|
|
58
|
+
* early to stop fetching).
|
|
57
59
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} while (next);
|
|
60
|
+
list(params: RuntimeListParams): Paginator<Runtime> {
|
|
61
|
+
return cursorPaginate(
|
|
62
|
+
(next) =>
|
|
63
|
+
this.http.request<Paginated<Runtime>>({
|
|
64
|
+
method: "GET",
|
|
65
|
+
path: "/v1/runtimes",
|
|
66
|
+
query: { ...params, next } as unknown as Record<string, unknown>,
|
|
67
|
+
}),
|
|
68
|
+
params.next,
|
|
69
|
+
);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
get(id: Uuid, params: { project_id?: Uuid }): Promise<Runtime> {
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
ToolCallResponsePart,
|
|
12
12
|
} from "@introspection-sdk/types";
|
|
13
13
|
import { HttpClient } from "../http.js";
|
|
14
|
+
import { Paginator, cursorPaginate } from "../pagination.js";
|
|
14
15
|
|
|
15
16
|
/** Includes requested when building a {@link ConversationResponse}. */
|
|
16
17
|
const RESPONSE_INCLUDES: ConversationItemInclude[] = [
|
|
@@ -30,29 +31,34 @@ export class ConversationItemsApi {
|
|
|
30
31
|
constructor(private readonly http: HttpClient) {}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* `
|
|
34
|
+
* List items of a conversation. `await` the result for the first page
|
|
35
|
+
* (an OpenAI-style {@link ConversationItemList} envelope), or
|
|
36
|
+
* `for await` it to stream every item across pages (fetched lazily —
|
|
37
|
+
* `limit` sets the page size, `after` the starting cursor; stop early to
|
|
38
|
+
* stop fetching). Pass `order: "asc"` to walk the transcript from the
|
|
39
|
+
* start.
|
|
37
40
|
*
|
|
38
41
|
* Items carry the turn-local delta in `input_messages` — only the
|
|
39
42
|
* messages new to that turn. Use `get()` for the full input history.
|
|
40
43
|
*/
|
|
41
|
-
|
|
44
|
+
list(
|
|
42
45
|
conversationId: string,
|
|
43
46
|
params?: ConversationItemListParams,
|
|
44
|
-
):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
): Paginator<ConversationItem, ConversationItemList> {
|
|
48
|
+
return new Paginator(
|
|
49
|
+
{
|
|
50
|
+
fetch: (after) =>
|
|
51
|
+
this.http.request<ConversationItemList>({
|
|
52
|
+
method: "GET",
|
|
53
|
+
path: `/v1/conversations/${encodeURIComponent(conversationId)}/items`,
|
|
54
|
+
query: { ...params, after } as Record<string, unknown>,
|
|
55
|
+
}),
|
|
56
|
+
items: (page) => page.data,
|
|
57
|
+
next: (page) =>
|
|
58
|
+
page.has_more && page.last_id !== null ? page.last_id : undefined,
|
|
59
|
+
},
|
|
60
|
+
params?.after,
|
|
61
|
+
);
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/**
|
|
@@ -90,23 +96,21 @@ export class ConversationsApi {
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* `
|
|
99
|
+
* List conversation summaries matching `params`. `await` the result for
|
|
100
|
+
* the first page, or `for await` it to stream every summary across
|
|
101
|
+
* pages (fetched lazily — `limit` sets the page size, `next` the
|
|
102
|
+
* starting cursor; stop early to stop fetching).
|
|
96
103
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
for (const c of page.records) yield c;
|
|
108
|
-
next = page.next ?? undefined;
|
|
109
|
-
} while (next);
|
|
104
|
+
list(params?: ConversationListParams): Paginator<ConversationSummary> {
|
|
105
|
+
return cursorPaginate(
|
|
106
|
+
(next) =>
|
|
107
|
+
this.http.request<Paginated<ConversationSummary>>({
|
|
108
|
+
method: "GET",
|
|
109
|
+
path: "/v1/conversations",
|
|
110
|
+
query: { ...params, next } as Record<string, unknown>,
|
|
111
|
+
}),
|
|
112
|
+
params?.next,
|
|
113
|
+
);
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/**
|