@bctrl/sdk 1.0.10 → 1.0.11

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 (45) hide show
  1. package/README.md +24 -97
  2. package/dist/account.d.ts +4 -1
  3. package/dist/account.js +12 -0
  4. package/dist/aiTypes.d.ts +0 -3
  5. package/dist/bctrl.d.ts +9 -3
  6. package/dist/bctrl.js +18 -6
  7. package/dist/browserExtensionTypes.d.ts +2 -2
  8. package/dist/browserExtensions.js +6 -6
  9. package/dist/conversations.d.ts +27 -0
  10. package/dist/conversations.js +63 -0
  11. package/dist/generated/openapi-types.d.ts +7404 -6023
  12. package/dist/generated/tool-types.d.ts +60 -0
  13. package/dist/http.d.ts +5 -0
  14. package/dist/http.js +44 -0
  15. package/dist/index.d.ts +8 -7
  16. package/dist/index.js +7 -6
  17. package/dist/node.d.ts +43 -101
  18. package/dist/node.js +6 -8
  19. package/dist/proxies.d.ts +15 -1
  20. package/dist/proxies.js +28 -0
  21. package/dist/proxyTypes.d.ts +8 -2
  22. package/dist/runs.d.ts +13 -102
  23. package/dist/runs.js +21 -114
  24. package/dist/runtimes.d.ts +11 -53
  25. package/dist/runtimes.js +18 -221
  26. package/dist/spaces.d.ts +1 -17
  27. package/dist/spaces.js +0 -75
  28. package/dist/toolCallTypes.d.ts +2 -2
  29. package/dist/toolCalls.d.ts +4 -1
  30. package/dist/toolCalls.js +14 -0
  31. package/dist/tools.d.ts +13 -15
  32. package/dist/tools.js +24 -19
  33. package/dist/toolsetTypes.d.ts +1 -1
  34. package/dist/types.d.ts +64 -183
  35. package/dist/views.d.ts +12 -0
  36. package/dist/views.js +34 -0
  37. package/dist/webhooks.d.ts +30 -0
  38. package/dist/webhooks.js +71 -0
  39. package/package.json +53 -53
  40. package/dist/invocations.d.ts +0 -125
  41. package/dist/invocations.js +0 -199
  42. package/dist/vault.d.ts +0 -14
  43. package/dist/vault.js +0 -37
  44. package/dist/vaultTypes.d.ts +0 -9
  45. /package/dist/{vaultTypes.js → generated/tool-types.js} +0 -0
package/README.md CHANGED
@@ -1,116 +1,43 @@
1
- # @bctrl/sdk
2
-
3
- TypeScript and JavaScript SDK for BCTRL cloud browser automation. Create browser runtimes, start live sessions, run hosted browser agents, inspect runs, and manage platform resources from Node.js.
4
-
5
- ## Install
1
+ # BCTRL JavaScript SDK
6
2
 
7
3
  ```bash
8
- npm install @bctrl/sdk
4
+ pnpm add @bctrl/sdk
9
5
  ```
10
6
 
11
- Requires Node.js 22.14 or newer.
12
-
13
- ## Quick Start
14
-
15
7
  ```ts
16
8
  import { Bctrl } from '@bctrl/sdk';
17
9
 
18
- const bctrl = new Bctrl({
19
- apiKey: process.env.BCTRL_API_KEY!,
20
- });
21
-
22
- const runtime = await bctrl.runtimes.create({
23
- type: 'browser',
24
- name: 'browser-task',
25
- });
26
-
27
- const started = await bctrl.runtimes.start(runtime.id);
28
- console.log(started.runId, started.connectUrl);
29
-
30
- await bctrl.runtimes.targets.create(started.runtimeId, {
31
- uri: 'https://example.com',
32
- activate: true,
33
- });
10
+ const bctrl = new Bctrl({ apiKey: process.env.BCTRL_API_KEY });
11
+ const started = await bctrl.runtimes.start('rt_...');
34
12
 
35
- await bctrl.runtimes.stop(started.runtimeId);
36
- ```
37
-
38
- ## Hosted Invocations
39
-
40
- Use invocations when you want BCTRL to drive the browser for you.
41
-
42
- ```ts
43
- import { Bctrl } from '@bctrl/sdk';
44
- import { z } from 'zod';
45
-
46
- const bctrl = new Bctrl();
47
-
48
- const invocation = await bctrl.runtimes.invocations.createAndWait(
49
- '<runtime-id>',
50
- {
51
- action: 'extract',
52
- instruction: 'Extract the product name and price.',
53
- schema: z.object({
54
- name: z.string(),
55
- price: z.string(),
56
- }),
13
+ const result = await bctrl.tools.call('stagehand.extract', {
14
+ runtimeId: started.runtimeId,
15
+ instruction: 'Extract the products',
16
+ schema: {
17
+ type: 'object',
18
+ properties: { products: { type: 'array' } },
57
19
  },
58
- { timeoutSeconds: 60 }
59
- );
60
-
61
- console.log(invocation.status, invocation.output);
62
- ```
63
-
64
- The SDK accepts Zod schemas or plain JSON Schema for structured extraction. On the wire, they are sent as `outputSchema`.
65
-
66
- ## Configuration
67
-
68
- The client reads `BCTRL_API_KEY` by default:
20
+ });
69
21
 
70
- ```ts
71
- const bctrl = new Bctrl();
22
+ const call = await bctrl.tools.start('captcha.solve', { runtimeId: started.runtimeId });
23
+ const solved = await bctrl.toolCalls.result(call.id, { waitSeconds: 60 });
72
24
  ```
73
25
 
74
- You can also pass configuration explicitly:
26
+ Agents are persistent conversations attached to an active runtime:
75
27
 
76
28
  ```ts
77
- const bctrl = new Bctrl({
78
- apiKey: 'bctrl_...',
79
- timeoutMs: 30_000,
80
- maxRetries: 2,
29
+ const conversation = await bctrl.conversations.create({
30
+ agent: 'browser-use',
31
+ runtimeId: started.runtimeId,
81
32
  });
82
- ```
83
-
84
- For subaccount-scoped calls:
85
33
 
86
- ```ts
87
- const scoped = bctrl.withSubaccount('<subaccount-id>');
88
- ```
89
-
90
- ## Errors
91
-
92
- API failures throw typed errors with status, code, request id, and response body context:
93
-
94
- ```ts
95
- import { BctrlApiError } from '@bctrl/sdk';
34
+ await bctrl.conversations.messages.create(conversation.id, {
35
+ text: 'Find the lowest refundable price',
36
+ });
96
37
 
97
- try {
98
- await bctrl.runtimes.get('<runtime-id>');
99
- } catch (error) {
100
- if (error instanceof BctrlApiError) {
101
- console.error(error.status, error.code, error.requestId);
102
- }
103
- }
38
+ const streamUrl = bctrl.conversations.events.streamUrl(conversation.id);
104
39
  ```
105
40
 
106
- The client retries retryable GET requests by default. Mutating requests are retried only when you provide an idempotency key.
107
-
108
- ## Documentation
109
-
110
- - SDK guide: https://platform.bctrl.ai/sdk
111
- - API reference: https://platform.bctrl.ai/api-reference
112
- - Product: https://bctrl.ai
113
-
114
- ## Telemetry
115
-
116
- The SDK does not include vendor-owned telemetry or usage analytics. Instrument your application directly if you want request logging or tracing.
41
+ Every automation path writes into the runtime's Run. Inspect structured spans and
42
+ events with `bctrl.runs.trace`, `bctrl.runs.events`, or the unified Run stream URL.
43
+ Create a View when a browser-safe, expiring embed URL is needed.
package/dist/account.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { V1HttpClient } from './http.js';
2
2
  import { V1NotificationRecipientsClient } from './notificationRecipients.js';
3
- import type { V1AccountUsage, V1ApiKey, V1ApiKeyCreateRequest, V1ApiKeyCreateResponse, V1ApiKeyDeleteResponse, V1ApiKeyListQuery, V1AuthWhoamiResponse, V1ListEnvelope, V1Subaccount, V1SubaccountArchiveResponse, V1SubaccountCreateRequest, V1SubaccountGetQuery, V1SubaccountListQuery, V1SubaccountUpdateRequest, V1SubaccountUsage, V1SubaccountUsageListQuery } from './types.js';
3
+ import type { V1Account, V1AccountPatchRequest, V1AccountUpdateQuery, V1AccountUsage, V1ApiKey, V1ApiKeyCreateRequest, V1ApiKeyCreateResponse, V1ApiKeyDeleteResponse, V1ApiKeyListQuery, V1AuthWhoamiResponse, V1ListEnvelope, V1Subaccount, V1SubaccountArchiveResponse, V1SubaccountCreateRequest, V1SubaccountGetQuery, V1SubaccountListQuery, V1SubaccountUpdateRequest, V1SubaccountUsage, V1SubaccountUsageListQuery } from './types.js';
4
4
  export declare class V1AuthClient {
5
5
  private readonly http;
6
6
  constructor(http: V1HttpClient);
@@ -37,9 +37,12 @@ export declare class V1UsageClient {
37
37
  get(): Promise<V1AccountUsage>;
38
38
  }
39
39
  export declare class V1AccountClient {
40
+ private readonly http;
40
41
  readonly apiKeys: V1ApiKeysClient;
41
42
  readonly notificationRecipients: V1NotificationRecipientsClient;
42
43
  readonly subaccounts: V1SubaccountsClient;
43
44
  readonly usage: V1UsageClient;
44
45
  constructor(http: V1HttpClient);
46
+ get(): Promise<V1Account>;
47
+ update(request: V1AccountPatchRequest, query?: V1AccountUpdateQuery): Promise<V1Account>;
45
48
  }
package/dist/account.js CHANGED
@@ -90,14 +90,26 @@ export class V1UsageClient {
90
90
  }
91
91
  }
92
92
  export class V1AccountClient {
93
+ http;
93
94
  apiKeys;
94
95
  notificationRecipients;
95
96
  subaccounts;
96
97
  usage;
97
98
  constructor(http) {
99
+ this.http = http;
98
100
  this.apiKeys = new V1ApiKeysClient(http);
99
101
  this.notificationRecipients = new V1NotificationRecipientsClient(http);
100
102
  this.subaccounts = new V1SubaccountsClient(http);
101
103
  this.usage = new V1UsageClient(http);
102
104
  }
105
+ get() {
106
+ return this.http.request('/account');
107
+ }
108
+ update(request, query = {}) {
109
+ return this.http.request('/account', {
110
+ method: 'PATCH',
111
+ query,
112
+ body: request,
113
+ });
114
+ }
103
115
  }
package/dist/aiTypes.d.ts CHANGED
@@ -12,8 +12,5 @@ export type V1AiCredentialCreateRequest = OpenApiSchemas['AiCredentialCreateRequ
12
12
  export type V1AiCredentialUpdateRequest = OpenApiSchemas['AiCredentialUpdateRequest'];
13
13
  export type V1AiCredentialDeleteResponse = OpenApiSchemas['AiCredentialDeleteResponse'];
14
14
  export type V1AiCredentialTestResponse = OpenApiSchemas['AiCredentialTestResponse'];
15
- export type V1AiModelSelectionAuth = OpenApiSchemas['AiModelSelectionAuth'];
16
- export type V1AiModelSelectionObject = OpenApiSchemas['AiModelSelection'];
17
- export type V1AiModelSelection = string | V1AiModelSelectionObject;
18
15
  export type V1AiStoredModelSelectionAuth = OpenApiSchemas['AiStoredModelSelectionAuth'];
19
16
  export type V1AiStoredModelSelection = string | OpenApiSchemas['AiStoredModelSelection'];
package/dist/bctrl.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { V1AccountClient, V1ApiKeysClient, V1AuthClient, V1SubaccountsClient, V1UsageClient } from './account.js';
2
2
  import { V1AiClient } from './ai.js';
3
3
  import { V1BrowserExtensionsClient } from './browserExtensions.js';
4
+ import { V1ConversationsClient } from './conversations.js';
4
5
  import { V1FilesClient } from './files.js';
5
6
  import { V1HelpClient } from './help.js';
6
7
  import { type V1ClientOptions } from './http.js';
@@ -12,7 +13,8 @@ import { V1SpacesClient } from './spaces.js';
12
13
  import { V1ToolCallsClient } from './toolCalls.js';
13
14
  import { V1ToolsClient } from './tools.js';
14
15
  import { V1ToolsetsClient } from './toolsets.js';
15
- import { V1VaultClient } from './vault.js';
16
+ import { V1ViewsClient } from './views.js';
17
+ import { V1WebhooksClient } from './webhooks.js';
16
18
  export type BctrlV1Options = V1ClientOptions;
17
19
  export declare class BctrlV1 {
18
20
  private readonly options;
@@ -20,12 +22,12 @@ export declare class BctrlV1 {
20
22
  private _spaces;
21
23
  private _runtimes;
22
24
  private _runs;
25
+ private _conversations;
23
26
  private _files;
24
27
  private _help;
25
28
  private _tools;
26
29
  private _toolsets;
27
30
  private _toolCalls;
28
- private _vault;
29
31
  private _proxies;
30
32
  private _browserExtensions;
31
33
  private _ai;
@@ -35,18 +37,20 @@ export declare class BctrlV1 {
35
37
  private _subaccounts;
36
38
  private _usage;
37
39
  private _notificationRecipients;
40
+ private _views;
41
+ private _webhooks;
38
42
  static isControllerBusy(error: unknown): boolean;
39
43
  constructor(options?: BctrlV1Options);
40
44
  withSubaccount(subaccountId: string): BctrlV1;
41
45
  get spaces(): V1SpacesClient;
42
46
  get runtimes(): V1RuntimesClient;
43
47
  get runs(): V1RunsClient;
48
+ get conversations(): V1ConversationsClient;
44
49
  get files(): V1FilesClient;
45
50
  get help(): V1HelpClient;
46
51
  get tools(): V1ToolsClient;
47
52
  get toolsets(): V1ToolsetsClient;
48
53
  get toolCalls(): V1ToolCallsClient;
49
- get vault(): V1VaultClient;
50
54
  get proxies(): V1ProxiesClient;
51
55
  get browserExtensions(): V1BrowserExtensionsClient;
52
56
  get ai(): V1AiClient;
@@ -56,5 +60,7 @@ export declare class BctrlV1 {
56
60
  get subaccounts(): V1SubaccountsClient;
57
61
  get usage(): V1UsageClient;
58
62
  get notificationRecipients(): V1NotificationRecipientsClient;
63
+ get views(): V1ViewsClient;
64
+ get webhooks(): V1WebhooksClient;
59
65
  }
60
66
  export { BctrlV1 as Bctrl };
package/dist/bctrl.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { V1AccountClient, V1ApiKeysClient, V1AuthClient, V1SubaccountsClient, V1UsageClient, } from './account.js';
2
2
  import { V1AiClient } from './ai.js';
3
3
  import { V1BrowserExtensionsClient } from './browserExtensions.js';
4
+ import { V1ConversationsClient } from './conversations.js';
4
5
  import { isControllerBusy } from './errors.js';
5
6
  import { V1FilesClient } from './files.js';
6
7
  import { V1HelpClient } from './help.js';
@@ -13,19 +14,20 @@ import { V1SpacesClient } from './spaces.js';
13
14
  import { V1ToolCallsClient } from './toolCalls.js';
14
15
  import { V1ToolsClient } from './tools.js';
15
16
  import { V1ToolsetsClient } from './toolsets.js';
16
- import { V1VaultClient } from './vault.js';
17
+ import { V1ViewsClient } from './views.js';
18
+ import { V1WebhooksClient } from './webhooks.js';
17
19
  export class BctrlV1 {
18
20
  options;
19
21
  http;
20
22
  _spaces = null;
21
23
  _runtimes = null;
22
24
  _runs = null;
25
+ _conversations = null;
23
26
  _files = null;
24
27
  _help = null;
25
28
  _tools = null;
26
29
  _toolsets = null;
27
30
  _toolCalls = null;
28
- _vault = null;
29
31
  _proxies = null;
30
32
  _browserExtensions = null;
31
33
  _ai = null;
@@ -35,6 +37,8 @@ export class BctrlV1 {
35
37
  _subaccounts = null;
36
38
  _usage = null;
37
39
  _notificationRecipients = null;
40
+ _views = null;
41
+ _webhooks = null;
38
42
  static isControllerBusy(error) {
39
43
  return isControllerBusy(error);
40
44
  }
@@ -57,6 +61,10 @@ export class BctrlV1 {
57
61
  this._runs ??= new V1RunsClient(this.http);
58
62
  return this._runs;
59
63
  }
64
+ get conversations() {
65
+ this._conversations ??= new V1ConversationsClient(this.http);
66
+ return this._conversations;
67
+ }
60
68
  get files() {
61
69
  this._files ??= new V1FilesClient(this.http);
62
70
  return this._files;
@@ -77,10 +85,6 @@ export class BctrlV1 {
77
85
  this._toolCalls ??= new V1ToolCallsClient(this.http);
78
86
  return this._toolCalls;
79
87
  }
80
- get vault() {
81
- this._vault ??= new V1VaultClient(this.http);
82
- return this._vault;
83
- }
84
88
  get proxies() {
85
89
  this._proxies ??= new V1ProxiesClient(this.http);
86
90
  return this._proxies;
@@ -117,5 +121,13 @@ export class BctrlV1 {
117
121
  this._notificationRecipients ??= new V1NotificationRecipientsClient(this.http);
118
122
  return this._notificationRecipients;
119
123
  }
124
+ get views() {
125
+ this._views ??= new V1ViewsClient(this.http);
126
+ return this._views;
127
+ }
128
+ get webhooks() {
129
+ this._webhooks ??= new V1WebhooksClient(this.http);
130
+ return this._webhooks;
131
+ }
120
132
  }
121
133
  export { BctrlV1 as Bctrl };
@@ -2,13 +2,13 @@ import type { OpenApiQuery, OpenApiSchemas } from './openapi.js';
2
2
  export type V1BrowserExtensionFormat = OpenApiSchemas['BrowserExtension']['format'];
3
3
  export type V1BrowserExtensionSource = 'upload' | 'url';
4
4
  export type V1BrowserExtension = OpenApiSchemas['BrowserExtension'];
5
- export type V1BrowserExtensionListQuery = OpenApiQuery<'browser-extensions.list'>;
5
+ export type V1BrowserExtensionListQuery = OpenApiQuery<'browser.extensions.list'>;
6
6
  export interface V1BrowserExtensionUploadRequest {
7
7
  /** Packed Chromium extension package. Only .crx is supported today. */
8
8
  file: Blob;
9
9
  /** Optional display name. Defaults to manifest.name. */
10
10
  name?: string;
11
11
  }
12
- export type V1BrowserExtensionImportRequest = OpenApiSchemas['BrowserExtensionImportRequest'];
12
+ export type V1BrowserExtensionImportRequest = OpenApiSchemas['BrowserExtensionCreateRequest'];
13
13
  export type V1BrowserExtensionUpdateRequest = OpenApiSchemas['BrowserExtensionUpdateRequest'];
14
14
  export type V1BrowserExtensionDeleteResponse = OpenApiSchemas['BrowserExtensionDeleteResponse'];
@@ -9,7 +9,7 @@ export class V1BrowserExtensionsClient {
9
9
  this.http = http;
10
10
  }
11
11
  list(query = {}) {
12
- return this.http.request('/browser-extensions', {
12
+ return this.http.request('/browser/extensions', {
13
13
  query,
14
14
  });
15
15
  }
@@ -17,7 +17,7 @@ export class V1BrowserExtensionsClient {
17
17
  return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
18
18
  }
19
19
  get(extensionId) {
20
- return this.http.request(`/browser-extensions/${encodeURIComponent(extensionId)}`);
20
+ return this.http.request(`/browser/extensions/${encodeURIComponent(extensionId)}`);
21
21
  }
22
22
  upload(request) {
23
23
  const form = new FormData();
@@ -25,25 +25,25 @@ export class V1BrowserExtensionsClient {
25
25
  if (request.name) {
26
26
  form.set('name', request.name);
27
27
  }
28
- return this.http.request('/browser-extensions/upload', {
28
+ return this.http.request('/browser/extensions', {
29
29
  method: 'POST',
30
30
  body: form,
31
31
  });
32
32
  }
33
33
  import(request) {
34
- return this.http.request('/browser-extensions/import', {
34
+ return this.http.request('/browser/extensions', {
35
35
  method: 'POST',
36
36
  body: request,
37
37
  });
38
38
  }
39
39
  update(extensionId, request) {
40
- return this.http.request(`/browser-extensions/${encodeURIComponent(extensionId)}`, {
40
+ return this.http.request(`/browser/extensions/${encodeURIComponent(extensionId)}`, {
41
41
  method: 'PATCH',
42
42
  body: request,
43
43
  });
44
44
  }
45
45
  delete(extensionId) {
46
- return this.http.request(`/browser-extensions/${encodeURIComponent(extensionId)}`, {
46
+ return this.http.request(`/browser/extensions/${encodeURIComponent(extensionId)}`, {
47
47
  method: 'DELETE',
48
48
  });
49
49
  }
@@ -0,0 +1,27 @@
1
+ import { type V1HttpClient, type V1IdempotencyOptions } from './http.js';
2
+ import type { V1Conversation, V1ConversationCancelResponse, V1ConversationCreateRequest, V1ConversationDetail, V1ConversationListQuery, V1ConversationMessageCreateRequest, V1ConversationStreamQuery, V1ConversationStreamEvent, V1ConversationUpdateRequest, V1ConversationTurn, V1ListEnvelope } from './types.js';
3
+ export declare class V1ConversationsClient {
4
+ private readonly http;
5
+ readonly messages: V1ConversationMessagesClient;
6
+ readonly events: V1ConversationEventsClient;
7
+ constructor(http: V1HttpClient);
8
+ list(query?: V1ConversationListQuery): Promise<V1ListEnvelope<V1Conversation>>;
9
+ iter(query?: V1ConversationListQuery): AsyncGenerator<V1Conversation, void, undefined>;
10
+ create(request: V1ConversationCreateRequest): Promise<V1Conversation>;
11
+ get(conversationId: string): Promise<V1ConversationDetail>;
12
+ update(conversationId: string, request: V1ConversationUpdateRequest): Promise<V1Conversation>;
13
+ cancel(conversationId: string): Promise<V1ConversationCancelResponse>;
14
+ }
15
+ export declare class V1ConversationMessagesClient {
16
+ private readonly http;
17
+ constructor(http: V1HttpClient);
18
+ create(conversationId: string, request: V1ConversationMessageCreateRequest, options?: V1IdempotencyOptions): Promise<V1ConversationTurn>;
19
+ }
20
+ export declare class V1ConversationEventsClient {
21
+ private readonly http;
22
+ constructor(http: V1HttpClient);
23
+ streamUrl(conversationId: string, query?: V1ConversationStreamQuery): string;
24
+ stream(conversationId: string, query?: V1ConversationStreamQuery, options?: {
25
+ signal?: AbortSignal;
26
+ }): AsyncGenerator<V1ConversationStreamEvent, void, undefined>;
27
+ }
@@ -0,0 +1,63 @@
1
+ import { v1IdempotencyHeaders } from './http.js';
2
+ import { iterateV1Pages } from './pagination.js';
3
+ export class V1ConversationsClient {
4
+ http;
5
+ messages;
6
+ events;
7
+ constructor(http) {
8
+ this.http = http;
9
+ this.messages = new V1ConversationMessagesClient(http);
10
+ this.events = new V1ConversationEventsClient(http);
11
+ }
12
+ list(query = {}) {
13
+ return this.http.request('/conversations', { query });
14
+ }
15
+ iter(query = {}) {
16
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
17
+ }
18
+ create(request) {
19
+ return this.http.request('/conversations', { method: 'POST', body: request });
20
+ }
21
+ get(conversationId) {
22
+ return this.http.request(`/conversations/${encodeURIComponent(conversationId)}`);
23
+ }
24
+ update(conversationId, request) {
25
+ return this.http.request(`/conversations/${encodeURIComponent(conversationId)}`, {
26
+ method: 'PATCH',
27
+ body: request,
28
+ });
29
+ }
30
+ cancel(conversationId) {
31
+ return this.http.request(`/conversations/${encodeURIComponent(conversationId)}/cancel`, {
32
+ method: 'POST',
33
+ });
34
+ }
35
+ }
36
+ export class V1ConversationMessagesClient {
37
+ http;
38
+ constructor(http) {
39
+ this.http = http;
40
+ }
41
+ create(conversationId, request, options) {
42
+ return this.http.request(`/conversations/${encodeURIComponent(conversationId)}/messages`, {
43
+ method: 'POST',
44
+ body: request,
45
+ headers: v1IdempotencyHeaders(options),
46
+ });
47
+ }
48
+ }
49
+ export class V1ConversationEventsClient {
50
+ http;
51
+ constructor(http) {
52
+ this.http = http;
53
+ }
54
+ streamUrl(conversationId, query = {}) {
55
+ const url = new URL(`${this.http.baseUrl}/conversations/${encodeURIComponent(conversationId)}/stream`);
56
+ if (query.after !== undefined)
57
+ url.searchParams.set('after', query.after);
58
+ return url.toString();
59
+ }
60
+ stream(conversationId, query = {}, options = {}) {
61
+ return this.http.streamSse(`/conversations/${encodeURIComponent(conversationId)}/stream`, { query, signal: options.signal });
62
+ }
63
+ }