@onkernel/sdk 0.5.0 → 0.6.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/client.d.mts +15 -5
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +15 -5
  6. package/client.d.ts.map +1 -1
  7. package/client.js +31 -22
  8. package/client.js.map +1 -1
  9. package/client.mjs +20 -11
  10. package/client.mjs.map +1 -1
  11. package/core/resource.d.mts +1 -1
  12. package/core/resource.d.mts.map +1 -1
  13. package/core/resource.d.ts +1 -1
  14. package/core/resource.d.ts.map +1 -1
  15. package/core/resource.js.map +1 -1
  16. package/core/resource.mjs.map +1 -1
  17. package/internal/headers.d.mts.map +1 -1
  18. package/internal/headers.d.ts.map +1 -1
  19. package/internal/headers.js +4 -4
  20. package/internal/headers.js.map +1 -1
  21. package/internal/headers.mjs +4 -4
  22. package/internal/headers.mjs.map +1 -1
  23. package/internal/request-options.d.mts +1 -0
  24. package/internal/request-options.d.mts.map +1 -1
  25. package/internal/request-options.d.ts +1 -0
  26. package/internal/request-options.d.ts.map +1 -1
  27. package/internal/request-options.js.map +1 -1
  28. package/internal/request-options.mjs.map +1 -1
  29. package/internal/uploads.js +1 -1
  30. package/internal/uploads.js.map +1 -1
  31. package/internal/uploads.mjs +1 -1
  32. package/internal/uploads.mjs.map +1 -1
  33. package/internal/utils/log.js +1 -1
  34. package/internal/utils/log.js.map +1 -1
  35. package/internal/utils/log.mjs +1 -1
  36. package/internal/utils/log.mjs.map +1 -1
  37. package/internal/utils/path.d.mts.map +1 -1
  38. package/internal/utils/path.d.ts.map +1 -1
  39. package/internal/utils/path.js.map +1 -1
  40. package/internal/utils/path.mjs +1 -1
  41. package/internal/utils/path.mjs.map +1 -1
  42. package/internal/utils/values.d.mts +2 -0
  43. package/internal/utils/values.d.mts.map +1 -1
  44. package/internal/utils/values.d.ts +2 -0
  45. package/internal/utils/values.d.ts.map +1 -1
  46. package/internal/utils/values.js +4 -1
  47. package/internal/utils/values.js.map +1 -1
  48. package/internal/utils/values.mjs +2 -0
  49. package/internal/utils/values.mjs.map +1 -1
  50. package/package.json +1 -1
  51. package/resources/apps/apps.d.mts +1 -5
  52. package/resources/apps/apps.d.mts.map +1 -1
  53. package/resources/apps/apps.d.ts +1 -5
  54. package/resources/apps/apps.d.ts.map +1 -1
  55. package/resources/apps/apps.js +0 -4
  56. package/resources/apps/apps.js.map +1 -1
  57. package/resources/apps/apps.mjs +0 -4
  58. package/resources/apps/apps.mjs.map +1 -1
  59. package/resources/apps/deployments.d.mts +2 -18
  60. package/resources/apps/deployments.d.mts.map +1 -1
  61. package/resources/apps/deployments.d.ts +2 -18
  62. package/resources/apps/deployments.d.ts.map +1 -1
  63. package/resources/apps/deployments.js.map +1 -1
  64. package/resources/apps/deployments.mjs.map +1 -1
  65. package/resources/apps/index.d.mts +0 -1
  66. package/resources/apps/index.d.mts.map +1 -1
  67. package/resources/apps/index.d.ts +0 -1
  68. package/resources/apps/index.d.ts.map +1 -1
  69. package/resources/apps/index.js +1 -3
  70. package/resources/apps/index.js.map +1 -1
  71. package/resources/apps/index.mjs +0 -1
  72. package/resources/apps/index.mjs.map +1 -1
  73. package/resources/deployments.d.mts +255 -0
  74. package/resources/deployments.d.mts.map +1 -0
  75. package/resources/deployments.d.ts +255 -0
  76. package/resources/deployments.d.ts.map +1 -0
  77. package/resources/deployments.js +54 -0
  78. package/resources/deployments.js.map +1 -0
  79. package/resources/deployments.mjs +50 -0
  80. package/resources/deployments.mjs.map +1 -0
  81. package/resources/index.d.mts +3 -0
  82. package/resources/index.d.mts.map +1 -1
  83. package/resources/index.d.ts +3 -0
  84. package/resources/index.d.ts.map +1 -1
  85. package/resources/index.js +7 -1
  86. package/resources/index.js.map +1 -1
  87. package/resources/index.mjs +3 -0
  88. package/resources/index.mjs.map +1 -1
  89. package/resources/{apps/invocations.d.mts → invocations.d.mts} +91 -10
  90. package/resources/invocations.d.mts.map +1 -0
  91. package/resources/{apps/invocations.d.ts → invocations.d.ts} +91 -10
  92. package/resources/invocations.d.ts.map +1 -0
  93. package/resources/invocations.js +83 -0
  94. package/resources/invocations.js.map +1 -0
  95. package/resources/invocations.mjs +79 -0
  96. package/resources/invocations.mjs.map +1 -0
  97. package/resources/shared.d.mts +57 -0
  98. package/resources/shared.d.mts.map +1 -0
  99. package/resources/shared.d.ts +57 -0
  100. package/resources/shared.d.ts.map +1 -0
  101. package/resources/shared.js +4 -0
  102. package/resources/shared.js.map +1 -0
  103. package/resources/shared.mjs +3 -0
  104. package/resources/shared.mjs.map +1 -0
  105. package/src/client.ts +75 -11
  106. package/src/core/resource.ts +1 -1
  107. package/src/internal/headers.ts +5 -5
  108. package/src/internal/request-options.ts +1 -0
  109. package/src/internal/uploads.ts +2 -2
  110. package/src/internal/utils/log.ts +1 -1
  111. package/src/internal/utils/path.ts +1 -1
  112. package/src/internal/utils/values.ts +3 -0
  113. package/src/resources/apps/apps.ts +1 -21
  114. package/src/resources/apps/deployments.ts +2 -21
  115. package/src/resources/apps/index.ts +0 -8
  116. package/src/resources/deployments.ts +326 -0
  117. package/src/resources/index.ts +19 -0
  118. package/src/resources/{apps/invocations.ts → invocations.ts} +120 -10
  119. package/src/resources/shared.ts +69 -0
  120. package/src/version.ts +1 -1
  121. package/version.d.mts +1 -1
  122. package/version.d.ts +1 -1
  123. package/version.js +1 -1
  124. package/version.mjs +1 -1
  125. package/resources/apps/invocations.d.mts.map +0 -1
  126. package/resources/apps/invocations.d.ts.map +0 -1
  127. package/resources/apps/invocations.js +0 -52
  128. package/resources/apps/invocations.js.map +0 -1
  129. package/resources/apps/invocations.mjs +0 -48
  130. package/resources/apps/invocations.mjs.map +0 -1
@@ -1,13 +1,15 @@
1
- import { APIResource } from "../../core/resource.js";
2
- import { APIPromise } from "../../core/api-promise.js";
3
- import { RequestOptions } from "../../internal/request-options.js";
1
+ import { APIResource } from "../core/resource.js";
2
+ import * as Shared from "./shared.js";
3
+ import { APIPromise } from "../core/api-promise.js";
4
+ import { Stream } from "../core/streaming.js";
5
+ import { RequestOptions } from "../internal/request-options.js";
4
6
  export declare class Invocations extends APIResource {
5
7
  /**
6
8
  * Invoke an action.
7
9
  *
8
10
  * @example
9
11
  * ```ts
10
- * const invocation = await client.apps.invocations.create({
12
+ * const invocation = await client.invocations.create({
11
13
  * action_name: 'analyze',
12
14
  * app_name: 'my-app',
13
15
  * version: '1.0.0',
@@ -20,7 +22,7 @@ export declare class Invocations extends APIResource {
20
22
  *
21
23
  * @example
22
24
  * ```ts
23
- * const invocation = await client.apps.invocations.retrieve(
25
+ * const invocation = await client.invocations.retrieve(
24
26
  * 'rr33xuugxj9h0bkf1rdt2bet',
25
27
  * );
26
28
  * ```
@@ -31,13 +33,88 @@ export declare class Invocations extends APIResource {
31
33
  *
32
34
  * @example
33
35
  * ```ts
34
- * const invocation = await client.apps.invocations.update(
35
- * 'id',
36
- * { status: 'succeeded' },
37
- * );
36
+ * const invocation = await client.invocations.update('id', {
37
+ * status: 'succeeded',
38
+ * });
38
39
  * ```
39
40
  */
40
41
  update(id: string, body: InvocationUpdateParams, options?: RequestOptions): APIPromise<InvocationUpdateResponse>;
42
+ /**
43
+ * Delete all browser sessions created within the specified invocation.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * await client.invocations.deleteBrowsers('id');
48
+ * ```
49
+ */
50
+ deleteBrowsers(id: string, options?: RequestOptions): APIPromise<void>;
51
+ /**
52
+ * Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
53
+ * status updates for an invocation. The stream terminates automatically once the
54
+ * invocation reaches a terminal state.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const response = await client.invocations.follow('id');
59
+ * ```
60
+ */
61
+ follow(id: string, options?: RequestOptions): APIPromise<Stream<InvocationFollowResponse>>;
62
+ }
63
+ /**
64
+ * An event representing the current state of an invocation.
65
+ */
66
+ export interface InvocationStateEvent {
67
+ /**
68
+ * Event type identifier (always "invocation_state").
69
+ */
70
+ event: 'invocation_state';
71
+ invocation: InvocationStateEvent.Invocation;
72
+ /**
73
+ * Time the state was reported.
74
+ */
75
+ timestamp: string;
76
+ }
77
+ export declare namespace InvocationStateEvent {
78
+ interface Invocation {
79
+ /**
80
+ * ID of the invocation
81
+ */
82
+ id: string;
83
+ /**
84
+ * Name of the action invoked
85
+ */
86
+ action_name: string;
87
+ /**
88
+ * Name of the application
89
+ */
90
+ app_name: string;
91
+ /**
92
+ * RFC 3339 Nanoseconds timestamp when the invocation started
93
+ */
94
+ started_at: string;
95
+ /**
96
+ * Status of the invocation
97
+ */
98
+ status: 'queued' | 'running' | 'succeeded' | 'failed';
99
+ /**
100
+ * RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
101
+ * running)
102
+ */
103
+ finished_at?: string | null;
104
+ /**
105
+ * Output produced by the action, rendered as a JSON string. This could be: string,
106
+ * number, boolean, array, object, or null.
107
+ */
108
+ output?: string;
109
+ /**
110
+ * Payload provided to the invocation. This is a string that can be parsed as JSON.
111
+ */
112
+ payload?: string;
113
+ /**
114
+ * Status reason
115
+ */
116
+ status_reason?: string;
117
+ }
41
118
  }
42
119
  export interface InvocationCreateResponse {
43
120
  /**
@@ -138,6 +215,10 @@ export interface InvocationUpdateResponse {
138
215
  */
139
216
  status_reason?: string;
140
217
  }
218
+ /**
219
+ * Union type representing any invocation event.
220
+ */
221
+ export type InvocationFollowResponse = Shared.LogEvent | InvocationStateEvent | Shared.ErrorEvent;
141
222
  export interface InvocationCreateParams {
142
223
  /**
143
224
  * Name of the action to invoke
@@ -172,6 +253,6 @@ export interface InvocationUpdateParams {
172
253
  output?: string;
173
254
  }
174
255
  export declare namespace Invocations {
175
- export { type InvocationCreateResponse as InvocationCreateResponse, type InvocationRetrieveResponse as InvocationRetrieveResponse, type InvocationUpdateResponse as InvocationUpdateResponse, type InvocationCreateParams as InvocationCreateParams, type InvocationUpdateParams as InvocationUpdateParams, };
256
+ export { type InvocationStateEvent as InvocationStateEvent, type InvocationCreateResponse as InvocationCreateResponse, type InvocationRetrieveResponse as InvocationRetrieveResponse, type InvocationUpdateResponse as InvocationUpdateResponse, type InvocationFollowResponse as InvocationFollowResponse, type InvocationCreateParams as InvocationCreateParams, type InvocationUpdateParams as InvocationUpdateParams, };
176
257
  }
177
258
  //# sourceMappingURL=invocations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocations.d.ts","sourceRoot":"","sources":["../src/resources/invocations.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,MAAM;OACX,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE;OAEV,EAAE,cAAc,EAAE;AAGzB,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,wBAAwB,CAAC;IAIpG;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,0BAA0B,CAAC;IAItF;;;;;;;;;OASG;IACH,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,sBAAsB,EAC5B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,wBAAwB,CAAC;IAIvC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAOtE;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;CAO3F;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;IAE1B,UAAU,EAAE,oBAAoB,CAAC,UAAU,C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0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Invocations = void 0;
5
+ const resource_1 = require("../core/resource.js");
6
+ const headers_1 = require("../internal/headers.js");
7
+ const path_1 = require("../internal/utils/path.js");
8
+ class Invocations extends resource_1.APIResource {
9
+ /**
10
+ * Invoke an action.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const invocation = await client.invocations.create({
15
+ * action_name: 'analyze',
16
+ * app_name: 'my-app',
17
+ * version: '1.0.0',
18
+ * });
19
+ * ```
20
+ */
21
+ create(body, options) {
22
+ return this._client.post('/invocations', { body, ...options });
23
+ }
24
+ /**
25
+ * Get details about an invocation's status and output.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const invocation = await client.invocations.retrieve(
30
+ * 'rr33xuugxj9h0bkf1rdt2bet',
31
+ * );
32
+ * ```
33
+ */
34
+ retrieve(id, options) {
35
+ return this._client.get((0, path_1.path) `/invocations/${id}`, options);
36
+ }
37
+ /**
38
+ * Update an invocation's status or output.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const invocation = await client.invocations.update('id', {
43
+ * status: 'succeeded',
44
+ * });
45
+ * ```
46
+ */
47
+ update(id, body, options) {
48
+ return this._client.patch((0, path_1.path) `/invocations/${id}`, { body, ...options });
49
+ }
50
+ /**
51
+ * Delete all browser sessions created within the specified invocation.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * await client.invocations.deleteBrowsers('id');
56
+ * ```
57
+ */
58
+ deleteBrowsers(id, options) {
59
+ return this._client.delete((0, path_1.path) `/invocations/${id}/browsers`, {
60
+ ...options,
61
+ headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
62
+ });
63
+ }
64
+ /**
65
+ * Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
66
+ * status updates for an invocation. The stream terminates automatically once the
67
+ * invocation reaches a terminal state.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const response = await client.invocations.follow('id');
72
+ * ```
73
+ */
74
+ follow(id, options) {
75
+ return this._client.get((0, path_1.path) `/invocations/${id}/events`, {
76
+ ...options,
77
+ headers: (0, headers_1.buildHeaders)([{ Accept: 'text/event-stream' }, options?.headers]),
78
+ stream: true,
79
+ });
80
+ }
81
+ }
82
+ exports.Invocations = Invocations;
83
+ //# sourceMappingURL=invocations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocations.js","sourceRoot":"","sources":["../src/resources/invocations.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,oDAAmD;AAEnD,oDAA8C;AAE9C,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAA4B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAU,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,gBAAgB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CACJ,EAAU,EACV,IAA4B,EAC5B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAI,EAAA,gBAAgB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CAAC,EAAU,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,gBAAgB,EAAE,WAAW,EAAE;YAC5D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,gBAAgB,EAAE,SAAS,EAAE;YACvD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1E,MAAM,EAAE,IAAI;SACb,CAAiD,CAAC;IACrD,CAAC;CACF;AAjFD,kCAiFC"}
@@ -0,0 +1,79 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../core/resource.mjs";
3
+ import { buildHeaders } from "../internal/headers.mjs";
4
+ import { path } from "../internal/utils/path.mjs";
5
+ export class Invocations extends APIResource {
6
+ /**
7
+ * Invoke an action.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const invocation = await client.invocations.create({
12
+ * action_name: 'analyze',
13
+ * app_name: 'my-app',
14
+ * version: '1.0.0',
15
+ * });
16
+ * ```
17
+ */
18
+ create(body, options) {
19
+ return this._client.post('/invocations', { body, ...options });
20
+ }
21
+ /**
22
+ * Get details about an invocation's status and output.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const invocation = await client.invocations.retrieve(
27
+ * 'rr33xuugxj9h0bkf1rdt2bet',
28
+ * );
29
+ * ```
30
+ */
31
+ retrieve(id, options) {
32
+ return this._client.get(path `/invocations/${id}`, options);
33
+ }
34
+ /**
35
+ * Update an invocation's status or output.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const invocation = await client.invocations.update('id', {
40
+ * status: 'succeeded',
41
+ * });
42
+ * ```
43
+ */
44
+ update(id, body, options) {
45
+ return this._client.patch(path `/invocations/${id}`, { body, ...options });
46
+ }
47
+ /**
48
+ * Delete all browser sessions created within the specified invocation.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * await client.invocations.deleteBrowsers('id');
53
+ * ```
54
+ */
55
+ deleteBrowsers(id, options) {
56
+ return this._client.delete(path `/invocations/${id}/browsers`, {
57
+ ...options,
58
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
59
+ });
60
+ }
61
+ /**
62
+ * Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
63
+ * status updates for an invocation. The stream terminates automatically once the
64
+ * invocation reaches a terminal state.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const response = await client.invocations.follow('id');
69
+ * ```
70
+ */
71
+ follow(id, options) {
72
+ return this._client.get(path `/invocations/${id}/events`, {
73
+ ...options,
74
+ headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
75
+ stream: true,
76
+ });
77
+ }
78
+ }
79
+ //# sourceMappingURL=invocations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocations.mjs","sourceRoot":"","sources":["../src/resources/invocations.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,YAAY,EAAE;OAEhB,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAA4B,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAU,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,gBAAgB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CACJ,EAAU,EACV,IAA4B,EAC5B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA,gBAAgB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CAAC,EAAU,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,gBAAgB,EAAE,WAAW,EAAE;YAC5D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,gBAAgB,EAAE,SAAS,EAAE;YACvD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1E,MAAM,EAAE,IAAI;SACb,CAAiD,CAAC;IACrD,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ export interface ErrorDetail {
2
+ /**
3
+ * Lower-level error code providing more specific detail
4
+ */
5
+ code?: string;
6
+ /**
7
+ * Further detail about the error
8
+ */
9
+ message?: string;
10
+ }
11
+ /**
12
+ * An error event from the application.
13
+ */
14
+ export interface ErrorEvent {
15
+ error: ErrorModel;
16
+ /**
17
+ * Event type identifier (always "error").
18
+ */
19
+ event: 'error';
20
+ /**
21
+ * Time the error occurred.
22
+ */
23
+ timestamp: string;
24
+ }
25
+ export interface ErrorModel {
26
+ /**
27
+ * Application-specific error code (machine-readable)
28
+ */
29
+ code: string;
30
+ /**
31
+ * Human-readable error description for debugging
32
+ */
33
+ message: string;
34
+ /**
35
+ * Additional error details (for multiple errors)
36
+ */
37
+ details?: Array<ErrorDetail>;
38
+ inner_error?: ErrorDetail;
39
+ }
40
+ /**
41
+ * A log entry from the application.
42
+ */
43
+ export interface LogEvent {
44
+ /**
45
+ * Event type identifier (always "log").
46
+ */
47
+ event: 'log';
48
+ /**
49
+ * Log message text.
50
+ */
51
+ message: string;
52
+ /**
53
+ * Time the log entry was produced.
54
+ */
55
+ timestamp: string;
56
+ }
57
+ //# sourceMappingURL=shared.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.mts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAE7B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,57 @@
1
+ export interface ErrorDetail {
2
+ /**
3
+ * Lower-level error code providing more specific detail
4
+ */
5
+ code?: string;
6
+ /**
7
+ * Further detail about the error
8
+ */
9
+ message?: string;
10
+ }
11
+ /**
12
+ * An error event from the application.
13
+ */
14
+ export interface ErrorEvent {
15
+ error: ErrorModel;
16
+ /**
17
+ * Event type identifier (always "error").
18
+ */
19
+ event: 'error';
20
+ /**
21
+ * Time the error occurred.
22
+ */
23
+ timestamp: string;
24
+ }
25
+ export interface ErrorModel {
26
+ /**
27
+ * Application-specific error code (machine-readable)
28
+ */
29
+ code: string;
30
+ /**
31
+ * Human-readable error description for debugging
32
+ */
33
+ message: string;
34
+ /**
35
+ * Additional error details (for multiple errors)
36
+ */
37
+ details?: Array<ErrorDetail>;
38
+ inner_error?: ErrorDetail;
39
+ }
40
+ /**
41
+ * A log entry from the application.
42
+ */
43
+ export interface LogEvent {
44
+ /**
45
+ * Event type identifier (always "log").
46
+ */
47
+ event: 'log';
48
+ /**
49
+ * Log message text.
50
+ */
51
+ message: string;
52
+ /**
53
+ * Time the log entry was produced.
54
+ */
55
+ timestamp: string;
56
+ }
57
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAE7B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export {};
3
+ //# sourceMappingURL=shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.mjs","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
package/src/client.ts CHANGED
@@ -5,7 +5,6 @@ import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestIni
5
5
  import { uuid4 } from './internal/utils/uuid';
6
6
  import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values';
7
7
  import { sleep } from './internal/utils/sleep';
8
- import { type Logger, type LogLevel, parseLogLevel } from './internal/utils/log';
9
8
  export type { Logger, LogLevel } from './internal/utils/log';
10
9
  import { castToError, isAbortError } from './internal/errors';
11
10
  import type { APIResponseProps } from './internal/parse';
@@ -17,9 +16,6 @@ import * as Errors from './core/error';
17
16
  import * as Uploads from './core/uploads';
18
17
  import * as API from './resources/index';
19
18
  import { APIPromise } from './core/api-promise';
20
- import { type Fetch } from './internal/builtin-types';
21
- import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
22
- import { FinalRequestOptions, RequestOptions } from './internal/request-options';
23
19
  import {
24
20
  BrowserCreateParams,
25
21
  BrowserCreateResponse,
@@ -29,11 +25,38 @@ import {
29
25
  BrowserRetrieveResponse,
30
26
  Browsers,
31
27
  } from './resources/browsers';
32
- import { readEnv } from './internal/utils/env';
33
- import { formatRequestDetails, loggerFor } from './internal/utils/log';
34
- import { isEmptyObj } from './internal/utils/values';
28
+ import {
29
+ DeploymentCreateParams,
30
+ DeploymentCreateResponse,
31
+ DeploymentFollowResponse,
32
+ DeploymentRetrieveResponse,
33
+ DeploymentStateEvent,
34
+ Deployments,
35
+ } from './resources/deployments';
35
36
  import { KernelApp } from './core/app-framework';
37
+ import {
38
+ InvocationCreateParams,
39
+ InvocationCreateResponse,
40
+ InvocationFollowResponse,
41
+ InvocationRetrieveResponse,
42
+ InvocationStateEvent,
43
+ InvocationUpdateParams,
44
+ InvocationUpdateResponse,
45
+ Invocations,
46
+ } from './resources/invocations';
36
47
  import { AppListParams, AppListResponse, Apps } from './resources/apps/apps';
48
+ import { type Fetch } from './internal/builtin-types';
49
+ import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
50
+ import { FinalRequestOptions, RequestOptions } from './internal/request-options';
51
+ import { readEnv } from './internal/utils/env';
52
+ import {
53
+ type LogLevel,
54
+ type Logger,
55
+ formatRequestDetails,
56
+ loggerFor,
57
+ parseLogLevel,
58
+ } from './internal/utils/log';
59
+ import { isEmptyObj } from './internal/utils/values';
37
60
 
38
61
  const environments = {
39
62
  production: 'https://api.onkernel.com/',
@@ -216,6 +239,13 @@ export class Kernel {
216
239
  });
217
240
  }
218
241
 
242
+ /**
243
+ * Check whether the base URL is set to its default.
244
+ */
245
+ #baseURLOverridden(): boolean {
246
+ return this.baseURL !== environments[this._options.environment || 'production'];
247
+ }
248
+
219
249
  protected defaultQuery(): Record<string, string | undefined> | undefined {
220
250
  return this._options.defaultQuery;
221
251
  }
@@ -265,11 +295,16 @@ export class Kernel {
265
295
  return Errors.APIError.generate(status, error, message, headers);
266
296
  }
267
297
 
268
- buildURL(path: string, query: Record<string, unknown> | null | undefined): string {
298
+ buildURL(
299
+ path: string,
300
+ query: Record<string, unknown> | null | undefined,
301
+ defaultBaseURL?: string | undefined,
302
+ ): string {
303
+ const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
269
304
  const url =
270
305
  isAbsoluteURL(path) ?
271
306
  new URL(path)
272
- : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
307
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
273
308
 
274
309
  const defaultQuery = this.defaultQuery();
275
310
  if (!isEmptyObj(defaultQuery)) {
@@ -610,9 +645,9 @@ export class Kernel {
610
645
  { retryCount = 0 }: { retryCount?: number } = {},
611
646
  ): { req: FinalizedRequestInit; url: string; timeout: number } {
612
647
  const options = { ...inputOptions };
613
- const { method, path, query } = options;
648
+ const { method, path, query, defaultBaseURL } = options;
614
649
 
615
- const url = this.buildURL(path!, query as Record<string, unknown>);
650
+ const url = this.buildURL(path!, query as Record<string, unknown>, defaultBaseURL);
616
651
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
617
652
  options.timeout = options.timeout ?? this.timeout;
618
653
  const { bodyHeaders, body } = this.buildBody({ options });
@@ -735,16 +770,40 @@ export class Kernel {
735
770
 
736
771
  static toFile = Uploads.toFile;
737
772
 
773
+ deployments: API.Deployments = new API.Deployments(this);
738
774
  apps: API.Apps = new API.Apps(this);
775
+ invocations: API.Invocations = new API.Invocations(this);
739
776
  browsers: API.Browsers = new API.Browsers(this);
740
777
  }
778
+ Kernel.Deployments = Deployments;
741
779
  Kernel.Apps = Apps;
780
+ Kernel.Invocations = Invocations;
742
781
  Kernel.Browsers = Browsers;
743
782
  export declare namespace Kernel {
744
783
  export type RequestOptions = Opts.RequestOptions;
745
784
 
785
+ export {
786
+ Deployments as Deployments,
787
+ type DeploymentStateEvent as DeploymentStateEvent,
788
+ type DeploymentCreateResponse as DeploymentCreateResponse,
789
+ type DeploymentRetrieveResponse as DeploymentRetrieveResponse,
790
+ type DeploymentFollowResponse as DeploymentFollowResponse,
791
+ type DeploymentCreateParams as DeploymentCreateParams,
792
+ };
793
+
746
794
  export { Apps as Apps, type AppListResponse as AppListResponse, type AppListParams as AppListParams };
747
795
 
796
+ export {
797
+ Invocations as Invocations,
798
+ type InvocationStateEvent as InvocationStateEvent,
799
+ type InvocationCreateResponse as InvocationCreateResponse,
800
+ type InvocationRetrieveResponse as InvocationRetrieveResponse,
801
+ type InvocationUpdateResponse as InvocationUpdateResponse,
802
+ type InvocationFollowResponse as InvocationFollowResponse,
803
+ type InvocationCreateParams as InvocationCreateParams,
804
+ type InvocationUpdateParams as InvocationUpdateParams,
805
+ };
806
+
748
807
  export {
749
808
  Browsers as Browsers,
750
809
  type BrowserPersistence as BrowserPersistence,
@@ -754,4 +813,9 @@ export declare namespace Kernel {
754
813
  type BrowserCreateParams as BrowserCreateParams,
755
814
  type BrowserDeleteParams as BrowserDeleteParams,
756
815
  };
816
+
817
+ export type ErrorDetail = API.ErrorDetail;
818
+ export type ErrorEvent = API.ErrorEvent;
819
+ export type ErrorModel = API.ErrorModel;
820
+ export type LogEvent = API.LogEvent;
757
821
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { Kernel } from '../client';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: Kernel;
7
7
 
8
8
  constructor(client: Kernel) {
@@ -1,5 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ import { isReadonlyArray } from './utils/values';
4
+
3
5
  type HeaderValue = string | undefined | null;
4
6
  export type HeadersLike =
5
7
  | Headers
@@ -9,7 +11,7 @@ export type HeadersLike =
9
11
  | null
10
12
  | NullableHeaders;
11
13
 
12
- const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
14
+ const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
13
15
 
14
16
  /**
15
17
  * @internal
@@ -25,8 +27,6 @@ export type NullableHeaders = {
25
27
  nulls: Set<string>;
26
28
  };
27
29
 
28
- const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];
29
-
30
30
  function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
31
31
  if (!headers) return;
32
32
 
@@ -43,7 +43,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
43
43
  let iter: Iterable<readonly (HeaderValue | readonly HeaderValue[])[]>;
44
44
  if (headers instanceof Headers) {
45
45
  iter = headers.entries();
46
- } else if (isArray(headers)) {
46
+ } else if (isReadonlyArray(headers)) {
47
47
  iter = headers;
48
48
  } else {
49
49
  shouldClear = true;
@@ -52,7 +52,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
52
52
  for (let row of iter) {
53
53
  const name = row[0];
54
54
  if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
55
- const values = isArray(row[1]) ? row[1] : [row[1]];
55
+ const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
56
56
  let didClear = false;
57
57
  for (const value of values) {
58
58
  if (value === undefined) continue;
@@ -21,6 +21,7 @@ export type RequestOptions = {
21
21
  fetchOptions?: MergedRequestInit;
22
22
  signal?: AbortSignal | undefined | null;
23
23
  idempotencyKey?: string;
24
+ defaultBaseURL?: string | undefined;
24
25
 
25
26
  __binaryResponse?: boolean | undefined;
26
27
  __streamClass?: typeof Stream;