@bctrl/cli 0.1.3 → 0.1.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.
- package/README.md +95 -95
- package/dist/api/auth.d.ts +5 -6
- package/dist/api/auth.js +4 -5
- package/dist/api/client.d.ts +1 -0
- package/dist/api/client.js +3 -0
- package/dist/api/errors.js +2 -2
- package/dist/bin/bctrl.js +0 -0
- package/dist/commands/ai/index.js +71 -106
- package/dist/commands/{browser → api-key}/index.d.ts +1 -1
- package/dist/commands/api-key/index.js +47 -0
- package/dist/commands/auth/login.js +2 -1
- package/dist/commands/auth/status.js +5 -0
- package/dist/commands/browser-extension/index.d.ts +3 -0
- package/dist/commands/browser-extension/index.js +85 -0
- package/dist/commands/file/index.js +26 -21
- package/dist/commands/{invocation → help}/index.d.ts +1 -1
- package/dist/commands/help/index.js +17 -0
- package/dist/commands/proxy/index.d.ts +3 -0
- package/dist/commands/proxy/index.js +72 -0
- package/dist/commands/run/index.js +227 -160
- package/dist/commands/runtime/index.js +343 -118
- package/dist/commands/shared/help.d.ts +1 -0
- package/dist/commands/shared/help.js +10 -6
- package/dist/commands/shared/operation.d.ts +83 -0
- package/dist/commands/shared/{rest.js → operation.js} +81 -32
- package/dist/commands/space/index.js +62 -68
- package/dist/commands/space/list.d.ts +1 -11
- package/dist/commands/space/list.js +12 -20
- package/dist/commands/subaccount/index.js +56 -125
- package/dist/commands/tool/index.js +28 -22
- package/dist/commands/tool-call/index.js +11 -6
- package/dist/commands/toolset/index.js +16 -15
- package/dist/commands/usage/index.d.ts +3 -0
- package/dist/commands/usage/index.js +13 -0
- package/dist/commands/vault/index.js +115 -34
- package/dist/config/auth-store.d.ts +10 -12
- package/dist/config/auth-store.js +4 -5
- package/dist/generated/help.d.ts +5992 -71
- package/dist/generated/help.js +7918 -123
- package/dist/generated/openapi-routes.d.ts +391 -0
- package/dist/generated/openapi-routes.js +100 -0
- package/dist/generated/openapi-types.d.ts +13755 -0
- package/dist/generated/openapi-types.js +5 -0
- package/dist/openapi.d.ts +20 -0
- package/dist/openapi.js +1 -0
- package/dist/root.js +10 -4
- package/package.json +47 -45
- package/dist/commands/browser/index.js +0 -53
- package/dist/commands/invocation/index.js +0 -36
- package/dist/commands/shared/rest.d.ts +0 -54
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CLI_OPENAPI_ROUTES } from './generated/openapi-routes.js';
|
|
2
|
+
import type { operations } from './generated/openapi-types.js';
|
|
3
|
+
export type CliOperationId = keyof typeof CLI_OPENAPI_ROUTES & keyof operations;
|
|
4
|
+
export type CliOperationQuery<OperationId extends CliOperationId> = operations[OperationId] extends {
|
|
5
|
+
parameters: {
|
|
6
|
+
query?: infer Query;
|
|
7
|
+
};
|
|
8
|
+
} ? NonNullable<Query> : never;
|
|
9
|
+
export type CliOperationPathParams<OperationId extends CliOperationId> = operations[OperationId] extends {
|
|
10
|
+
parameters: {
|
|
11
|
+
path?: infer PathParams;
|
|
12
|
+
};
|
|
13
|
+
} ? NonNullable<PathParams> : never;
|
|
14
|
+
export type CliOperationJsonBody<OperationId extends CliOperationId> = operations[OperationId] extends {
|
|
15
|
+
requestBody?: infer RequestBody;
|
|
16
|
+
} ? NonNullable<RequestBody> extends {
|
|
17
|
+
content: {
|
|
18
|
+
'application/json': infer Body;
|
|
19
|
+
};
|
|
20
|
+
} ? Body : never : never;
|
package/dist/openapi.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/root.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { createAiCommand } from './commands/ai/index.js';
|
|
3
|
+
import { createApiKeyCommand } from './commands/api-key/index.js';
|
|
3
4
|
import { createAuthCommand } from './commands/auth/index.js';
|
|
4
|
-
import {
|
|
5
|
+
import { createBrowserExtensionCommand } from './commands/browser-extension/index.js';
|
|
5
6
|
import { createFileCommand } from './commands/file/index.js';
|
|
6
|
-
import {
|
|
7
|
+
import { createHelpCommand } from './commands/help/index.js';
|
|
8
|
+
import { createProxyCommand } from './commands/proxy/index.js';
|
|
7
9
|
import { createRunCommand } from './commands/run/index.js';
|
|
8
10
|
import { createRuntimeCommand } from './commands/runtime/index.js';
|
|
9
11
|
import { createSpaceCommand } from './commands/space/index.js';
|
|
@@ -11,6 +13,7 @@ import { createSubaccountCommand } from './commands/subaccount/index.js';
|
|
|
11
13
|
import { createToolCommand } from './commands/tool/index.js';
|
|
12
14
|
import { createToolCallCommand } from './commands/tool-call/index.js';
|
|
13
15
|
import { createToolsetCommand } from './commands/toolset/index.js';
|
|
16
|
+
import { createUsageCommand } from './commands/usage/index.js';
|
|
14
17
|
import { createVaultCommand } from './commands/vault/index.js';
|
|
15
18
|
import { createVersionCommand } from './commands/version/version.js';
|
|
16
19
|
export function createRootCommand(factory) {
|
|
@@ -25,16 +28,19 @@ export function createRootCommand(factory) {
|
|
|
25
28
|
command.addCommand(createVersionCommand(factory));
|
|
26
29
|
command.addCommand(createAuthCommand(factory));
|
|
27
30
|
command.addCommand(createAiCommand(factory));
|
|
28
|
-
command.addCommand(
|
|
31
|
+
command.addCommand(createApiKeyCommand(factory));
|
|
32
|
+
command.addCommand(createBrowserExtensionCommand(factory));
|
|
29
33
|
command.addCommand(createFileCommand(factory));
|
|
30
|
-
command.addCommand(
|
|
34
|
+
command.addCommand(createHelpCommand(factory));
|
|
31
35
|
command.addCommand(createRunCommand(factory));
|
|
32
36
|
command.addCommand(createRuntimeCommand(factory));
|
|
37
|
+
command.addCommand(createProxyCommand(factory));
|
|
33
38
|
command.addCommand(createSpaceCommand(factory));
|
|
34
39
|
command.addCommand(createSubaccountCommand(factory));
|
|
35
40
|
command.addCommand(createToolCommand(factory));
|
|
36
41
|
command.addCommand(createToolsetCommand(factory));
|
|
37
42
|
command.addCommand(createToolCallCommand(factory));
|
|
43
|
+
command.addCommand(createUsageCommand(factory));
|
|
38
44
|
command.addCommand(createVaultCommand(factory));
|
|
39
45
|
return command;
|
|
40
46
|
}
|
package/package.json
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bctrl/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "BCTRL command-line interface",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"bctrl": "./dist/bin/bctrl.js"
|
|
8
|
-
},
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@bctrl/cli",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "BCTRL command-line interface",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bctrl": "./dist/bin/bctrl.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
20
|
+
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
21
|
+
"dev": "tsx src/bin/bctrl.ts",
|
|
22
|
+
"prepack": "pnpm run build",
|
|
23
|
+
"test": "tsx --test \"tests/**/*.test.ts\"",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"typecheck:tests": "tsc --noEmit -p tests/tsconfig.json"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"bctrl",
|
|
29
|
+
"cli",
|
|
30
|
+
"browser-automation",
|
|
31
|
+
"agents"
|
|
32
|
+
],
|
|
33
|
+
"author": "",
|
|
34
|
+
"license": "ISC",
|
|
35
|
+
"packageManager": "pnpm@10.12.4",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"commander": "^14.0.3",
|
|
38
|
+
"handlebars": "^4.7.9",
|
|
39
|
+
"jq-web": "^0.6.2",
|
|
40
|
+
"zod": "^4.4.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.7.0",
|
|
44
|
+
"tsx": "^4.21.0",
|
|
45
|
+
"typescript": "^6.0.3"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { readBlob, readJsonFile } from '../shared/io.js';
|
|
3
|
-
import { addOutputFlags, outputData } from '../shared/output.js';
|
|
4
|
-
import { createDeleteCommand, createJsonBodyCommand, createListCommand, createViewCommand, } from '../shared/rest.js';
|
|
5
|
-
export function createBrowserCommand(factory) {
|
|
6
|
-
const command = new Command('browser').description('Manage browser resources');
|
|
7
|
-
command.addCommand(createBrowserExtensionCommand(factory));
|
|
8
|
-
return command;
|
|
9
|
-
}
|
|
10
|
-
function createBrowserExtensionCommand(factory) {
|
|
11
|
-
const command = new Command('extension').description('Manage browser extensions');
|
|
12
|
-
command.addCommand(createListCommand(factory, {
|
|
13
|
-
description: 'List browser extensions',
|
|
14
|
-
path: '/browser-extensions',
|
|
15
|
-
configure: (cmd) => cmd,
|
|
16
|
-
}));
|
|
17
|
-
command.addCommand(createViewCommand(factory, {
|
|
18
|
-
description: 'View a browser extension',
|
|
19
|
-
path: '/browser-extensions/{id}',
|
|
20
|
-
}));
|
|
21
|
-
command.addCommand(addOutputFlags(new Command('upload')
|
|
22
|
-
.description('Upload a browser extension package')
|
|
23
|
-
.argument('<path>'))
|
|
24
|
-
.action(async (path, options) => {
|
|
25
|
-
const client = await factory.apiClient();
|
|
26
|
-
const file = await readBlob(path);
|
|
27
|
-
const result = await client.uploadFile('/browser-extensions/upload', {
|
|
28
|
-
file: file.blob,
|
|
29
|
-
fileName: file.fileName,
|
|
30
|
-
});
|
|
31
|
-
await outputData(factory.io, result, options);
|
|
32
|
-
}));
|
|
33
|
-
command.addCommand(createJsonBodyCommand(factory, {
|
|
34
|
-
name: 'import',
|
|
35
|
-
description: 'Import a browser extension from a URL',
|
|
36
|
-
method: 'post',
|
|
37
|
-
path: '/browser-extensions/import',
|
|
38
|
-
configure: (cmd) => cmd
|
|
39
|
-
.option('--url <url>', 'Extension URL')
|
|
40
|
-
.option('--input <path>', 'Read full JSON request body from file, or - for stdin'),
|
|
41
|
-
body: async (_args, options) => {
|
|
42
|
-
if (typeof options.input === 'string') {
|
|
43
|
-
return readJsonFile(options.input);
|
|
44
|
-
}
|
|
45
|
-
return { source: { type: 'url', url: options.url } };
|
|
46
|
-
},
|
|
47
|
-
}));
|
|
48
|
-
command.addCommand(createDeleteCommand(factory, {
|
|
49
|
-
description: 'Delete a browser extension',
|
|
50
|
-
path: '/browser-extensions/{id}',
|
|
51
|
-
}));
|
|
52
|
-
return command;
|
|
53
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { readJsonFile } from '../shared/io.js';
|
|
3
|
-
import { addOutputFlags } from '../shared/output.js';
|
|
4
|
-
import { createJsonBodyCommand, createViewCommand, requestAndPrint } from '../shared/rest.js';
|
|
5
|
-
export function createInvocationCommand(factory) {
|
|
6
|
-
const command = new Command('invocation')
|
|
7
|
-
.description('Inspect and control BCTRL invocations');
|
|
8
|
-
command.addCommand(createViewCommand(factory, {
|
|
9
|
-
description: 'View an invocation',
|
|
10
|
-
path: '/invocations/{id}',
|
|
11
|
-
}));
|
|
12
|
-
command.addCommand(createJsonBodyCommand(factory, {
|
|
13
|
-
name: 'wait',
|
|
14
|
-
description: 'Wait for an invocation',
|
|
15
|
-
method: 'post',
|
|
16
|
-
path: '/invocations/{id}/wait',
|
|
17
|
-
argNames: ['id'],
|
|
18
|
-
configure: (cmd) => cmd
|
|
19
|
-
.option('--timeout-ms <ms>', 'Timeout in milliseconds')
|
|
20
|
-
.option('--input <path>', 'Read JSON request body from file, or - for stdin'),
|
|
21
|
-
body: async (_args, options) => {
|
|
22
|
-
if (typeof options.input === 'string')
|
|
23
|
-
return readJsonFile(options.input);
|
|
24
|
-
return { timeoutMs: options.timeoutMs ? Number(options.timeoutMs) : undefined };
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
command.addCommand(addOutputFlags(new Command('cancel')
|
|
28
|
-
.description('Cancel an invocation')
|
|
29
|
-
.argument('<id>'))
|
|
30
|
-
.action(async (id, options) => {
|
|
31
|
-
await requestAndPrint(factory, 'post', `/invocations/${encodeURIComponent(id)}/cancel`, {
|
|
32
|
-
output: options,
|
|
33
|
-
});
|
|
34
|
-
}));
|
|
35
|
-
return command;
|
|
36
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import type { BctrlApiClient } from '../../api/client.js';
|
|
3
|
-
import type { Factory } from '../../factory.js';
|
|
4
|
-
import type { IOStreams } from '../../io/streams.js';
|
|
5
|
-
import { type OutputFlags } from './output.js';
|
|
6
|
-
type ClientMethod = 'get' | 'post' | 'patch' | 'put' | 'delete';
|
|
7
|
-
export type ApiDeps = {
|
|
8
|
-
io: IOStreams;
|
|
9
|
-
apiClient: () => Promise<BctrlApiClient>;
|
|
10
|
-
};
|
|
11
|
-
export declare function pathTemplate(template: string, params: Record<string, string>): string;
|
|
12
|
-
export declare function addPaginationFlags(command: Command): Command;
|
|
13
|
-
export declare function addJsonBodyFlag(command: Command): Command;
|
|
14
|
-
export declare function requestAndPrint(deps: ApiDeps, method: ClientMethod, path: string, options?: {
|
|
15
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
16
|
-
body?: unknown;
|
|
17
|
-
output?: OutputFlags;
|
|
18
|
-
}): Promise<void>;
|
|
19
|
-
export declare function bodyFromInputOption(path: string | undefined): Promise<unknown>;
|
|
20
|
-
export declare function createListCommand(factory: Factory, config: {
|
|
21
|
-
name?: string;
|
|
22
|
-
description: string;
|
|
23
|
-
path: string;
|
|
24
|
-
query?: (options: Record<string, unknown>) => Record<string, string | number | boolean | undefined>;
|
|
25
|
-
configure?: (command: Command) => Command;
|
|
26
|
-
}): Command;
|
|
27
|
-
export declare function createViewCommand(factory: Factory, config: {
|
|
28
|
-
name?: string;
|
|
29
|
-
description: string;
|
|
30
|
-
path: string;
|
|
31
|
-
argName?: string;
|
|
32
|
-
configure?: (command: Command) => Command;
|
|
33
|
-
query?: (id: string, options: Record<string, unknown>) => Record<string, string | number | boolean | undefined>;
|
|
34
|
-
}): Command;
|
|
35
|
-
export declare function createDeleteCommand(factory: Factory, config: {
|
|
36
|
-
name?: string;
|
|
37
|
-
description: string;
|
|
38
|
-
path: string;
|
|
39
|
-
argNames?: string[];
|
|
40
|
-
configure?: (command: Command) => Command;
|
|
41
|
-
query?: (args: Record<string, string>, options: Record<string, unknown>) => Record<string, string | number | boolean | undefined>;
|
|
42
|
-
}): Command;
|
|
43
|
-
export declare function createJsonBodyCommand(factory: Factory, config: {
|
|
44
|
-
name: string;
|
|
45
|
-
description: string;
|
|
46
|
-
method: Exclude<ClientMethod, 'get' | 'delete'>;
|
|
47
|
-
path: string;
|
|
48
|
-
argNames?: string[];
|
|
49
|
-
configure?: (command: Command) => Command;
|
|
50
|
-
body?: (args: Record<string, string>, options: Record<string, unknown>) => Promise<unknown>;
|
|
51
|
-
query?: (args: Record<string, string>, options: Record<string, unknown>) => Record<string, string | number | boolean | undefined>;
|
|
52
|
-
}): Command;
|
|
53
|
-
export declare function outputFlags(options: Record<string, unknown>): OutputFlags;
|
|
54
|
-
export {};
|