@onkernel/sdk 0.148.0 → 0.149.0

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/client.d.mts +18 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +18 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +18 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +18 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/index.d.mts +3 -0
  12. package/resources/index.d.mts.map +1 -1
  13. package/resources/index.d.ts +3 -0
  14. package/resources/index.d.ts.map +1 -1
  15. package/resources/index.js +7 -1
  16. package/resources/index.js.map +1 -1
  17. package/resources/index.mjs +3 -0
  18. package/resources/index.mjs.map +1 -1
  19. package/resources/report-types/index.d.mts +3 -0
  20. package/resources/report-types/index.d.mts.map +1 -0
  21. package/resources/report-types/index.d.ts +3 -0
  22. package/resources/report-types/index.d.ts.map +1 -0
  23. package/resources/report-types/index.js +9 -0
  24. package/resources/report-types/index.js.map +1 -0
  25. package/resources/report-types/index.mjs +4 -0
  26. package/resources/report-types/index.mjs.map +1 -0
  27. package/resources/report-types/report-types.d.mts +98 -0
  28. package/resources/report-types/report-types.d.mts.map +1 -0
  29. package/resources/report-types/report-types.d.ts +98 -0
  30. package/resources/report-types/report-types.d.ts.map +1 -0
  31. package/resources/report-types/report-types.js +38 -0
  32. package/resources/report-types/report-types.js.map +1 -0
  33. package/resources/report-types/report-types.mjs +33 -0
  34. package/resources/report-types/report-types.mjs.map +1 -0
  35. package/resources/report-types/versions.d.mts +47 -0
  36. package/resources/report-types/versions.d.mts.map +1 -0
  37. package/resources/report-types/versions.d.ts +47 -0
  38. package/resources/report-types/versions.d.ts.map +1 -0
  39. package/resources/report-types/versions.js +20 -0
  40. package/resources/report-types/versions.js.map +1 -0
  41. package/resources/report-types/versions.mjs +16 -0
  42. package/resources/report-types/versions.mjs.map +1 -0
  43. package/resources/report-types.d.mts +2 -0
  44. package/resources/report-types.d.mts.map +1 -0
  45. package/resources/report-types.d.ts +2 -0
  46. package/resources/report-types.d.ts.map +1 -0
  47. package/resources/report-types.js +6 -0
  48. package/resources/report-types.js.map +1 -0
  49. package/resources/report-types.mjs +3 -0
  50. package/resources/report-types.mjs.map +1 -0
  51. package/resources/reports.d.mts +136 -0
  52. package/resources/reports.d.mts.map +1 -0
  53. package/resources/reports.d.ts +136 -0
  54. package/resources/reports.d.ts.map +1 -0
  55. package/resources/reports.js +58 -0
  56. package/resources/reports.js.map +1 -0
  57. package/resources/reports.mjs +54 -0
  58. package/resources/reports.mjs.map +1 -0
  59. package/resources/tasks.d.mts +144 -0
  60. package/resources/tasks.d.mts.map +1 -0
  61. package/resources/tasks.d.ts +144 -0
  62. package/resources/tasks.d.ts.map +1 -0
  63. package/resources/tasks.js +67 -0
  64. package/resources/tasks.js.map +1 -0
  65. package/resources/tasks.mjs +63 -0
  66. package/resources/tasks.mjs.map +1 -0
  67. package/resources/vaults/items.d.mts +61 -10
  68. package/resources/vaults/items.d.mts.map +1 -1
  69. package/resources/vaults/items.d.ts +61 -10
  70. package/resources/vaults/items.d.ts.map +1 -1
  71. package/resources/vaults/items.js +4 -0
  72. package/resources/vaults/items.js.map +1 -1
  73. package/resources/vaults/items.mjs +4 -0
  74. package/resources/vaults/items.mjs.map +1 -1
  75. package/resources/vaults/vaults.d.mts +4 -1
  76. package/resources/vaults/vaults.d.mts.map +1 -1
  77. package/resources/vaults/vaults.d.ts +4 -1
  78. package/resources/vaults/vaults.d.ts.map +1 -1
  79. package/resources/vaults/vaults.js +4 -1
  80. package/resources/vaults/vaults.js.map +1 -1
  81. package/resources/vaults/vaults.mjs +4 -1
  82. package/resources/vaults/vaults.mjs.map +1 -1
  83. package/src/client.ts +66 -0
  84. package/src/resources/index.ts +24 -0
  85. package/src/resources/report-types/index.ts +11 -0
  86. package/src/resources/report-types/report-types.ts +137 -0
  87. package/src/resources/report-types/versions.ts +61 -0
  88. package/src/resources/report-types.ts +3 -0
  89. package/src/resources/reports.ts +166 -0
  90. package/src/resources/tasks.ts +183 -0
  91. package/src/resources/vaults/items.ts +64 -2
  92. package/src/resources/vaults/vaults.ts +4 -1
  93. package/src/version.ts +1 -1
  94. package/version.d.mts +1 -1
  95. package/version.d.ts +1 -1
  96. package/version.js +1 -1
  97. package/version.mjs +1 -1
@@ -0,0 +1,137 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as VersionsAPI from './versions';
5
+ import { ReportTypeVersion, VersionRetrieveParams, Versions } from './versions';
6
+ import { APIPromise } from '../../core/api-promise';
7
+ import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../core/pagination';
8
+ import { RequestOptions } from '../../internal/request-options';
9
+ import { path } from '../../internal/utils/path';
10
+
11
+ /**
12
+ * Discover report types and submit typed reports against tasks.
13
+ */
14
+ export class ReportTypes extends APIResource {
15
+ versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client);
16
+
17
+ /**
18
+ * Retrieve a report type, its versions, and the JSON Schema of its latest version.
19
+ */
20
+ retrieve(type: string, options?: RequestOptions): APIPromise<ReportType> {
21
+ return this._client.get(path`/report_types/${type}`, options);
22
+ }
23
+
24
+ /**
25
+ * List the report types agents can submit for a task. Retrieve a type for the JSON
26
+ * Schema of its data.
27
+ */
28
+ list(
29
+ query: ReportTypeListParams,
30
+ options?: RequestOptions,
31
+ ): PagePromise<ReportTypeSummariesOffsetPagination, ReportTypeSummary> {
32
+ return this._client.getAPIList('/report_types', OffsetPagination<ReportTypeSummary>, {
33
+ query,
34
+ ...options,
35
+ });
36
+ }
37
+ }
38
+
39
+ export type ReportTypeSummariesOffsetPagination = OffsetPagination<ReportTypeSummary>;
40
+
41
+ /**
42
+ * A kind of report agents can submit against a task, with its versions and the
43
+ * JSON Schema of its latest version. A shipped version never changes; changes ship
44
+ * as new versions.
45
+ */
46
+ export interface ReportType {
47
+ /**
48
+ * What the report type records and when to submit it
49
+ */
50
+ description: string;
51
+
52
+ /**
53
+ * Highest version that is not retired. A report submitted without a schema_version
54
+ * uses this version. It is 0 when every version is retired.
55
+ */
56
+ latest_version: number;
57
+
58
+ /**
59
+ * JSON Schema (draft 2020-12) of the latest version, which a report's data must
60
+ * match. Its field descriptions and examples describe what to send. Null when
61
+ * every version is retired.
62
+ */
63
+ schema: { [key: string]: unknown } | null;
64
+
65
+ /**
66
+ * Report type name, such as task.result
67
+ */
68
+ type: string;
69
+
70
+ /**
71
+ * Every version of the type, oldest first, including retired versions.
72
+ */
73
+ versions: Array<ReportTypeVersionSummary>;
74
+ }
75
+
76
+ /**
77
+ * A kind of report agents can submit against a task. Retrieve the type for the
78
+ * JSON Schema of its data.
79
+ */
80
+ export interface ReportTypeSummary {
81
+ /**
82
+ * What the report type records and when to submit it
83
+ */
84
+ description: string;
85
+
86
+ /**
87
+ * Highest version that is not retired. A report submitted without a schema_version
88
+ * uses this version. It is 0 when every version is retired.
89
+ */
90
+ latest_version: number;
91
+
92
+ /**
93
+ * Report type name, such as task.result
94
+ */
95
+ type: string;
96
+ }
97
+
98
+ /**
99
+ * One schema version of a report type, without its schema.
100
+ */
101
+ export interface ReportTypeVersionSummary {
102
+ /**
103
+ * Whether the version is retired. Retired versions are no longer accepted for new
104
+ * reports; existing reports keep them.
105
+ */
106
+ retired: boolean;
107
+
108
+ /**
109
+ * Schema version number, starting at 1.
110
+ */
111
+ version: number;
112
+ }
113
+
114
+ export interface ReportTypeListParams extends OffsetPaginationParams {
115
+ /**
116
+ * Task the agent is finding a report type for.
117
+ */
118
+ task_id: string;
119
+ }
120
+
121
+ ReportTypes.Versions = Versions;
122
+
123
+ export declare namespace ReportTypes {
124
+ export {
125
+ type ReportType as ReportType,
126
+ type ReportTypeSummary as ReportTypeSummary,
127
+ type ReportTypeVersionSummary as ReportTypeVersionSummary,
128
+ type ReportTypeSummariesOffsetPagination as ReportTypeSummariesOffsetPagination,
129
+ type ReportTypeListParams as ReportTypeListParams,
130
+ };
131
+
132
+ export {
133
+ Versions as Versions,
134
+ type ReportTypeVersion as ReportTypeVersion,
135
+ type VersionRetrieveParams as VersionRetrieveParams,
136
+ };
137
+ }
@@ -0,0 +1,61 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { RequestOptions } from '../../internal/request-options';
6
+ import { path } from '../../internal/utils/path';
7
+
8
+ /**
9
+ * Discover report types and submit typed reports against tasks.
10
+ */
11
+ export class Versions extends APIResource {
12
+ /**
13
+ * Retrieve one schema version of a report type, including retired versions.
14
+ */
15
+ retrieve(
16
+ version: number,
17
+ params: VersionRetrieveParams,
18
+ options?: RequestOptions,
19
+ ): APIPromise<ReportTypeVersion> {
20
+ const { type } = params;
21
+ return this._client.get(path`/report_types/${type}/versions/${version}`, options);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * One immutable schema version of a report type.
27
+ */
28
+ export interface ReportTypeVersion {
29
+ /**
30
+ * Whether the version is retired. Retired versions are no longer accepted for new
31
+ * reports; existing reports keep them.
32
+ */
33
+ retired: boolean;
34
+
35
+ /**
36
+ * JSON Schema (draft 2020-12) that a report's data must match. Its field
37
+ * descriptions and examples describe what to send.
38
+ */
39
+ schema: { [key: string]: unknown };
40
+
41
+ /**
42
+ * Report type name, such as task.result
43
+ */
44
+ type: string;
45
+
46
+ /**
47
+ * Schema version number, starting at 1.
48
+ */
49
+ version: number;
50
+ }
51
+
52
+ export interface VersionRetrieveParams {
53
+ /**
54
+ * Report type name, such as task.result
55
+ */
56
+ type: string;
57
+ }
58
+
59
+ export declare namespace Versions {
60
+ export { type ReportTypeVersion as ReportTypeVersion, type VersionRetrieveParams as VersionRetrieveParams };
61
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './report-types/index';
@@ -0,0 +1,166 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
8
+
9
+ /**
10
+ * Discover report types and submit typed reports against tasks.
11
+ */
12
+ export class Reports extends APIResource {
13
+ /**
14
+ * Submit a typed report against a task. The data is validated against the report
15
+ * type's schema; a validation failure returns 400 with one detail per invalid
16
+ * field. A task can have at most 500 reports.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const report = await client.reports.create({
21
+ * data: { result: 'bar', evidence: 'bar' },
22
+ * task_id: 'x',
23
+ * type: 'task.result',
24
+ * });
25
+ * ```
26
+ */
27
+ create(body: ReportCreateParams, options?: RequestOptions): APIPromise<Report> {
28
+ return this._client.post('/reports', { body, ...options });
29
+ }
30
+
31
+ /**
32
+ * Retrieve a report.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const report = await client.reports.retrieve('id');
37
+ * ```
38
+ */
39
+ retrieve(id: string, options?: RequestOptions): APIPromise<Report> {
40
+ return this._client.get(path`/reports/${id}`, options);
41
+ }
42
+
43
+ /**
44
+ * List a task's reports in the order they were submitted, oldest first.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // Automatically fetches more pages as needed.
49
+ * for await (const report of client.reports.list({
50
+ * task_id: 'task_id',
51
+ * })) {
52
+ * // ...
53
+ * }
54
+ * ```
55
+ */
56
+ list(query: ReportListParams, options?: RequestOptions): PagePromise<ReportsOffsetPagination, Report> {
57
+ return this._client.getAPIList('/reports', OffsetPagination<Report>, { query, ...options });
58
+ }
59
+ }
60
+
61
+ export type ReportsOffsetPagination = OffsetPagination<Report>;
62
+
63
+ /**
64
+ * A typed, schema-validated report an agent submitted against a task. Reports are
65
+ * immutable.
66
+ */
67
+ export interface Report {
68
+ /**
69
+ * Unique identifier for the report
70
+ */
71
+ id: string;
72
+
73
+ /**
74
+ * When the report was submitted
75
+ */
76
+ created_at: string;
77
+
78
+ /**
79
+ * Report data, matching the report type's schema
80
+ */
81
+ data: { [key: string]: unknown };
82
+
83
+ /**
84
+ * When the reported event happened
85
+ */
86
+ occurred_at: string;
87
+
88
+ /**
89
+ * Version of the report type's schema that data was validated against
90
+ */
91
+ schema_version: number;
92
+
93
+ /**
94
+ * ID of the task the report belongs to
95
+ */
96
+ task_id: string;
97
+
98
+ /**
99
+ * Report type name
100
+ */
101
+ type: string;
102
+
103
+ /**
104
+ * ID of the browser the report was observed in, if any
105
+ */
106
+ session_id?: string | null;
107
+ }
108
+
109
+ export interface ReportCreateParams {
110
+ /**
111
+ * Report data. It must match the schema of the report type's version and encode to
112
+ * at most 16 KB of JSON.
113
+ */
114
+ data: { [key: string]: unknown };
115
+
116
+ /**
117
+ * ID of the task to report against.
118
+ */
119
+ task_id: string;
120
+
121
+ /**
122
+ * Report type name. List report types to see the available types and their
123
+ * schemas.
124
+ */
125
+ type: string;
126
+
127
+ /**
128
+ * When the reported event happened. Defaults to the time the report is submitted.
129
+ * Must be no more than 5 minutes in the future or 30 days in the past.
130
+ */
131
+ occurred_at?: string;
132
+
133
+ /**
134
+ * Version of the report type's schema to validate data against. Defaults to the
135
+ * type's latest version, which the response returns.
136
+ */
137
+ schema_version?: number;
138
+
139
+ /**
140
+ * ID of the browser the report was observed in. It must belong to the task's
141
+ * project; deleted browsers are accepted. The browser is linked to the task if it
142
+ * is not already.
143
+ */
144
+ session_id?: string;
145
+ }
146
+
147
+ export interface ReportListParams extends OffsetPaginationParams {
148
+ /**
149
+ * Task whose reports to list.
150
+ */
151
+ task_id: string;
152
+
153
+ /**
154
+ * Only return reports of this type.
155
+ */
156
+ type?: string;
157
+ }
158
+
159
+ export declare namespace Reports {
160
+ export {
161
+ type Report as Report,
162
+ type ReportsOffsetPagination as ReportsOffsetPagination,
163
+ type ReportCreateParams as ReportCreateParams,
164
+ type ReportListParams as ReportListParams,
165
+ };
166
+ }
@@ -0,0 +1,183 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
8
+
9
+ /**
10
+ * Define tasks that agents work toward and link the browsers they use.
11
+ */
12
+ export class Tasks extends APIResource {
13
+ /**
14
+ * Define a task before or while an agent works on it, optionally linking the
15
+ * browsers it uses. Submit reports against the returned task ID.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const task = await client.tasks.create({
20
+ * description: 'Book a hotel room for two nights',
21
+ * });
22
+ * ```
23
+ */
24
+ create(body: TaskCreateParams, options?: RequestOptions): APIPromise<Task> {
25
+ return this._client.post('/tasks', { body, ...options });
26
+ }
27
+
28
+ /**
29
+ * Retrieve a task and the IDs of its linked browsers.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const task = await client.tasks.retrieve('id');
34
+ * ```
35
+ */
36
+ retrieve(id: string, options?: RequestOptions): APIPromise<Task> {
37
+ return this._client.get(path`/tasks/${id}`, options);
38
+ }
39
+
40
+ /**
41
+ * List tasks in the request's project, newest first.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * // Automatically fetches more pages as needed.
46
+ * for await (const task of client.tasks.list()) {
47
+ * // ...
48
+ * }
49
+ * ```
50
+ */
51
+ list(
52
+ query: TaskListParams | null | undefined = {},
53
+ options?: RequestOptions,
54
+ ): PagePromise<TasksOffsetPagination, Task> {
55
+ return this._client.getAPIList('/tasks', OffsetPagination<Task>, { query, ...options });
56
+ }
57
+
58
+ /**
59
+ * Link browsers to an existing task. Linking a browser that is already linked has
60
+ * no effect, so the call is safe to retry. Returns the updated task.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const task = await client.tasks.linkBrowsers('id', {
65
+ * session_ids: ['x'],
66
+ * });
67
+ * ```
68
+ */
69
+ linkBrowsers(id: string, body: TaskLinkBrowsersParams, options?: RequestOptions): APIPromise<Task> {
70
+ return this._client.post(path`/tasks/${id}/browsers`, { body, ...options });
71
+ }
72
+ }
73
+
74
+ export type TasksOffsetPagination = OffsetPagination<Task>;
75
+
76
+ /**
77
+ * A goal an agent works toward. Reports are submitted against a task, and browsers
78
+ * can be linked to it. Tasks are immutable apart from added browser links.
79
+ */
80
+ export interface Task {
81
+ /**
82
+ * Unique identifier for the task
83
+ */
84
+ id: string;
85
+
86
+ /**
87
+ * When the task was created
88
+ */
89
+ created_at: string;
90
+
91
+ /**
92
+ * What the task is meant to accomplish
93
+ */
94
+ description: string;
95
+
96
+ /**
97
+ * Caller-defined string key-value pairs for grouping and filtering tasks, such as
98
+ * a user or thread ID. At most 20 keys; keys are 1-64 characters, values at most
99
+ * 256 characters, and keys and values together at most 4 KB.
100
+ */
101
+ metadata: TaskMetadata;
102
+
103
+ /**
104
+ * IDs of browsers linked to the task, oldest link first. Linked browsers may since
105
+ * have been deleted.
106
+ */
107
+ session_ids: Array<string>;
108
+
109
+ /**
110
+ * When work on the task started
111
+ */
112
+ started_at: string;
113
+
114
+ /**
115
+ * Hostname of the website the task targets
116
+ */
117
+ target_website?: string | null;
118
+ }
119
+
120
+ /**
121
+ * Caller-defined string key-value pairs for grouping and filtering tasks, such as
122
+ * a user or thread ID. At most 20 keys; keys are 1-64 characters, values at most
123
+ * 256 characters, and keys and values together at most 4 KB.
124
+ */
125
+ export type TaskMetadata = { [key: string]: string };
126
+
127
+ export interface TaskCreateParams {
128
+ /**
129
+ * What the task is meant to accomplish, at most 4 KB.
130
+ */
131
+ description: string;
132
+
133
+ /**
134
+ * Caller-defined string key-value pairs for grouping and filtering tasks, such as
135
+ * a user or thread ID. At most 20 keys; keys are 1-64 characters, values at most
136
+ * 256 characters, and keys and values together at most 4 KB.
137
+ */
138
+ metadata?: TaskMetadata;
139
+
140
+ /**
141
+ * IDs of browsers to link to the task. Each must belong to the request's project;
142
+ * deleted browsers can be linked.
143
+ */
144
+ session_ids?: Array<string>;
145
+
146
+ /**
147
+ * When work on the task started. Defaults to the time the task is created. Must be
148
+ * no more than 5 minutes in the future or 30 days in the past.
149
+ */
150
+ started_at?: string;
151
+
152
+ /**
153
+ * Hostname of the website the task targets, without a scheme or path.
154
+ */
155
+ target_website?: string;
156
+ }
157
+
158
+ export interface TaskListParams extends OffsetPaginationParams {
159
+ /**
160
+ * Only return tasks linked to this browser ID.
161
+ */
162
+ session_id?: string;
163
+ }
164
+
165
+ export interface TaskLinkBrowsersParams {
166
+ /**
167
+ * IDs of browsers to link. Each must belong to the task's project; deleted
168
+ * browsers can be linked. Browsers already linked are ignored. A task can have at
169
+ * most 100 linked browsers.
170
+ */
171
+ session_ids: Array<string>;
172
+ }
173
+
174
+ export declare namespace Tasks {
175
+ export {
176
+ type Task as Task,
177
+ type TaskMetadata as TaskMetadata,
178
+ type TasksOffsetPagination as TasksOffsetPagination,
179
+ type TaskCreateParams as TaskCreateParams,
180
+ type TaskListParams as TaskListParams,
181
+ type TaskLinkBrowsersParams as TaskLinkBrowsersParams,
182
+ };
183
+ }