@bctrl/sdk 1.0.4 → 1.0.5

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 (57) hide show
  1. package/README.md +0 -1
  2. package/dist/account.d.ts +43 -0
  3. package/dist/account.js +100 -0
  4. package/dist/accountTypes.d.ts +126 -0
  5. package/dist/accountTypes.js +1 -0
  6. package/dist/aiProviderTypes.d.ts +58 -0
  7. package/dist/aiProviderTypes.js +1 -0
  8. package/dist/aiProviders.d.ts +13 -0
  9. package/dist/aiProviders.js +36 -0
  10. package/dist/bctrl.d.ts +35 -3
  11. package/dist/bctrl.js +74 -6
  12. package/dist/browserExtensionTypes.d.ts +45 -0
  13. package/dist/browserExtensionTypes.js +1 -0
  14. package/dist/browserExtensions.d.ts +14 -0
  15. package/dist/browserExtensions.js +53 -0
  16. package/dist/files.d.ts +6 -24
  17. package/dist/files.js +9 -56
  18. package/dist/help.d.ts +7 -0
  19. package/dist/help.js +9 -0
  20. package/dist/http.d.ts +12 -1
  21. package/dist/http.js +73 -10
  22. package/dist/index.d.ts +17 -6
  23. package/dist/index.js +15 -5
  24. package/dist/invocations.d.ts +85 -47
  25. package/dist/invocations.js +144 -102
  26. package/dist/node.d.ts +12 -0
  27. package/dist/node.js +11 -0
  28. package/dist/proxies.d.ts +21 -0
  29. package/dist/proxies.js +55 -0
  30. package/dist/proxyTypes.d.ts +114 -0
  31. package/dist/proxyTypes.js +1 -0
  32. package/dist/runs.d.ts +35 -31
  33. package/dist/runs.js +95 -38
  34. package/dist/runtimes.d.ts +26 -42
  35. package/dist/runtimes.js +64 -65
  36. package/dist/schemas.d.ts +7 -0
  37. package/dist/schemas.js +36 -0
  38. package/dist/spaces.d.ts +20 -32
  39. package/dist/spaces.js +48 -36
  40. package/dist/toolCallTypes.d.ts +41 -0
  41. package/dist/toolCallTypes.js +1 -0
  42. package/dist/toolCalls.d.ts +9 -0
  43. package/dist/toolCalls.js +16 -0
  44. package/dist/tools.d.ts +23 -0
  45. package/dist/tools.js +49 -0
  46. package/dist/toolsetTypes.d.ts +32 -0
  47. package/dist/toolsetTypes.js +1 -0
  48. package/dist/toolsets.d.ts +12 -0
  49. package/dist/toolsets.js +31 -0
  50. package/dist/types.d.ts +499 -155
  51. package/dist/utils.d.ts +2 -1
  52. package/dist/utils.js +28 -3
  53. package/dist/vault.d.ts +14 -0
  54. package/dist/vault.js +37 -0
  55. package/dist/vaultTypes.d.ts +73 -0
  56. package/dist/vaultTypes.js +1 -0
  57. package/package.json +21 -12
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const BCTRL_PRODUCTION_ORIGIN = "https://api.bctrl.ai";
2
2
  export declare function stripTrailingSlash(value: string): string;
3
3
  export declare function resolveApiKey(apiKey: string): string;
4
- export declare function fetchWithTimeout(input: RequestInfo | URL, init?: RequestInit, timeoutMs?: number): Promise<Response>;
4
+ export declare function fetchWithTimeout(input: RequestInfo | URL, init?: RequestInit, timeoutMs?: number, fetchImpl?: typeof fetch): Promise<Response>;
5
+ export declare function abortableSleep(ms: number, signal?: AbortSignal): Promise<void>;
package/dist/utils.js CHANGED
@@ -9,14 +9,14 @@ export function resolveApiKey(apiKey) {
9
9
  }
10
10
  return trimmed;
11
11
  }
12
- export async function fetchWithTimeout(input, init = {}, timeoutMs) {
12
+ export async function fetchWithTimeout(input, init = {}, timeoutMs, fetchImpl = fetch) {
13
13
  if (!timeoutMs) {
14
- return fetch(input, init);
14
+ return fetchImpl(input, init);
15
15
  }
16
16
  const controller = new AbortController();
17
17
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
18
18
  try {
19
- return await fetch(input, {
19
+ return await fetchImpl(input, {
20
20
  ...init,
21
21
  signal: init.signal ?? controller.signal,
22
22
  });
@@ -25,3 +25,28 @@ export async function fetchWithTimeout(input, init = {}, timeoutMs) {
25
25
  clearTimeout(timeout);
26
26
  }
27
27
  }
28
+ export function abortableSleep(ms, signal) {
29
+ if (ms <= 0)
30
+ return Promise.resolve();
31
+ return new Promise((resolve, reject) => {
32
+ if (signal?.aborted) {
33
+ reject(createAbortError());
34
+ return;
35
+ }
36
+ const timeout = setTimeout(cleanup, ms);
37
+ const onAbort = () => {
38
+ clearTimeout(timeout);
39
+ reject(createAbortError());
40
+ };
41
+ function cleanup() {
42
+ signal?.removeEventListener('abort', onAbort);
43
+ resolve();
44
+ }
45
+ signal?.addEventListener('abort', onAbort, { once: true });
46
+ });
47
+ }
48
+ function createAbortError() {
49
+ const error = new Error('The operation was aborted.');
50
+ error.name = 'AbortError';
51
+ return error;
52
+ }
@@ -0,0 +1,14 @@
1
+ import type { V1HttpClient } from './http.js';
2
+ import type { V1ListEnvelope, V1VaultSecret, V1VaultSecretDeleteResponse, V1VaultSecretListQuery, V1VaultSecretPatchRequest, V1VaultSecretUpsertRequest, V1VaultSecretValue, V1VaultTotpResponse } from './types.js';
3
+ export declare class V1VaultClient {
4
+ private readonly http;
5
+ constructor(http: V1HttpClient);
6
+ list(query?: V1VaultSecretListQuery): Promise<V1ListEnvelope<V1VaultSecret>>;
7
+ iter(query?: V1VaultSecretListQuery): AsyncGenerator<V1VaultSecret, void, undefined>;
8
+ get(key: string): Promise<V1VaultSecret>;
9
+ value(key: string): Promise<V1VaultSecretValue>;
10
+ upsert(key: string, request: V1VaultSecretUpsertRequest): Promise<V1VaultSecret>;
11
+ update(key: string, request: V1VaultSecretPatchRequest): Promise<V1VaultSecret>;
12
+ totp(key: string): Promise<V1VaultTotpResponse>;
13
+ delete(key: string): Promise<V1VaultSecretDeleteResponse>;
14
+ }
package/dist/vault.js ADDED
@@ -0,0 +1,37 @@
1
+ import { iterateV1Pages } from './pagination.js';
2
+ export class V1VaultClient {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ list(query = {}) {
8
+ return this.http.request('/vault/secrets', { query });
9
+ }
10
+ iter(query = {}) {
11
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
12
+ }
13
+ get(key) {
14
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}`);
15
+ }
16
+ value(key) {
17
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}/value`);
18
+ }
19
+ upsert(key, request) {
20
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}`, {
21
+ method: 'PUT',
22
+ body: request,
23
+ });
24
+ }
25
+ update(key, request) {
26
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}`, {
27
+ method: 'PATCH',
28
+ body: request,
29
+ });
30
+ }
31
+ totp(key) {
32
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}/totp`);
33
+ }
34
+ delete(key) {
35
+ return this.http.request(`/vault/secrets/${encodeURIComponent(key)}`, { method: 'DELETE' });
36
+ }
37
+ }
@@ -0,0 +1,73 @@
1
+ type V1VaultPageQuery = {
2
+ cursor?: string;
3
+ limit?: number;
4
+ };
5
+ export type V1VaultSecretType = 'login' | 'value';
6
+ export interface V1VaultSecret {
7
+ key: string;
8
+ type: V1VaultSecretType;
9
+ label?: string;
10
+ origins?: string[];
11
+ originPatterns?: string[];
12
+ hasTotp: boolean;
13
+ createdAt?: string;
14
+ updatedAt?: string;
15
+ }
16
+ export interface V1VaultSecretListQuery extends V1VaultPageQuery {
17
+ prefix?: string;
18
+ origin?: string;
19
+ hasTotp?: boolean;
20
+ }
21
+ export type V1VaultSecretUpsertRequest = {
22
+ type: 'login';
23
+ username: string;
24
+ password: string;
25
+ totpSecret?: string;
26
+ label?: string;
27
+ origins?: string[];
28
+ originPatterns?: string[];
29
+ notes?: string;
30
+ } | {
31
+ type: 'value';
32
+ value: string;
33
+ label?: string;
34
+ origins?: string[];
35
+ originPatterns?: string[];
36
+ notes?: string;
37
+ };
38
+ export interface V1VaultSecretPatchRequest {
39
+ username?: string;
40
+ password?: string;
41
+ value?: string;
42
+ totpSecret?: string | null;
43
+ label?: string | null;
44
+ origins?: string[] | null;
45
+ originPatterns?: string[] | null;
46
+ notes?: string | null;
47
+ }
48
+ export type V1VaultSecretValue = {
49
+ key: string;
50
+ type: 'login';
51
+ username: string;
52
+ password: string;
53
+ label?: string;
54
+ origins?: string[];
55
+ originPatterns?: string[];
56
+ notes?: string;
57
+ } | {
58
+ key: string;
59
+ type: 'value';
60
+ value: string;
61
+ label?: string;
62
+ origins?: string[];
63
+ originPatterns?: string[];
64
+ notes?: string;
65
+ };
66
+ export interface V1VaultTotpResponse {
67
+ code: string;
68
+ }
69
+ export interface V1VaultSecretDeleteResponse {
70
+ key: string;
71
+ deleted: true;
72
+ }
73
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bctrl/sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "BCTRL SDK - Remote browser automation",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -9,11 +9,29 @@
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js"
12
+ },
13
+ "./node": {
14
+ "types": "./dist/node.d.ts",
15
+ "import": "./dist/node.js"
12
16
  }
13
17
  },
18
+ "scripts": {
19
+ "clean": "rm -rf dist",
20
+ "build": "pnpm run clean && tsc -p tsconfig.json",
21
+ "prepack": "pnpm run build",
22
+ "dev": "tsc --watch",
23
+ "test": "tsx --test tests/v1/*.test.ts tests/v1/e2e/*.test.ts",
24
+ "test:v1": "tsx --test tests/v1/*.test.ts tests/v1/e2e/*.test.ts",
25
+ "test:v1:e2e": "BCTRL_E2E=1 tsx --test tests/v1/e2e/**/*.test.ts",
26
+ "typecheck": "tsc --noEmit"
27
+ },
14
28
  "keywords": [],
15
29
  "author": "",
16
30
  "license": "ISC",
31
+ "dependencies": {
32
+ "zod": "^4.3.6"
33
+ },
34
+ "packageManager": "pnpm@10.12.4",
17
35
  "devDependencies": {
18
36
  "@types/node": "^25.0.3",
19
37
  "@typescript-eslint/eslint-plugin": "^8.56.0",
@@ -24,14 +42,5 @@
24
42
  },
25
43
  "files": [
26
44
  "dist"
27
- ],
28
- "scripts": {
29
- "clean": "rm -rf dist",
30
- "build": "pnpm run clean && tsc -p tsconfig.json",
31
- "dev": "tsc --watch",
32
- "test": "tsx --test tests/v1/*.test.ts tests/v1/e2e/*.test.ts",
33
- "test:v1": "tsx --test tests/v1/*.test.ts tests/v1/e2e/*.test.ts",
34
- "test:v1:e2e": "BCTRL_E2E=1 tsx --test tests/v1/e2e/**/*.test.ts",
35
- "typecheck": "tsc --noEmit"
36
- }
37
- }
45
+ ]
46
+ }