@liberseek/boft-cli 0.1.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.
- package/README.md +217 -0
- package/dist/api.d.ts +85 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +242 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +628 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex.d.ts +74 -0
- package/dist/codex.d.ts.map +1 -0
- package/dist/codex.js +567 -0
- package/dist/codex.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +11 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +87 -0
- package/dist/output.js.map +1 -0
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +49 -0
- package/dist/prompt.js.map +1 -0
- package/dist/redact.d.ts +3 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +23 -0
- package/dist/redact.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +6 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +47 -0
- package/dist/validate.js.map +1 -0
- package/docs/HTTP_CONTRACT.md +125 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# BOFT CLI
|
|
2
|
+
|
|
3
|
+
`@liberseek/boft-cli` configures supported Agent platforms to use BOFT and provides the secure command-line client for BOFT Agent accounts. It can configure Codex without replacing the user's Codex login, query balances, create self-service recharge payments, render payment QR codes, and manage user API Keys within the Agent Token scopes. It cannot perform administrative operations or directly debit an account.
|
|
4
|
+
|
|
5
|
+
## Requirements and installation
|
|
6
|
+
|
|
7
|
+
- Node.js 20 or later
|
|
8
|
+
- A dedicated BOFT Agent Token for account and recharge commands
|
|
9
|
+
|
|
10
|
+
Install the public npm package:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install --global @liberseek/boft-cli
|
|
14
|
+
boft --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Build and install from this repository:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm ci
|
|
21
|
+
npm run build
|
|
22
|
+
npm install --global .
|
|
23
|
+
boft --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
For local development without a global install:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm run build
|
|
30
|
+
node dist/index.js --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Authentication
|
|
34
|
+
|
|
35
|
+
Interactive login verifies the token against the account endpoint before saving it:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
boft auth login
|
|
39
|
+
boft auth status
|
|
40
|
+
boft auth logout
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The prompt does not echo the token. Saved credentials use `$XDG_CONFIG_HOME/boft/credentials.json`, or `~/.config/boft/credentials.json` when `XDG_CONFIG_HOME` is unset. The directory is mode `0700` and the file is mode `0600`.
|
|
44
|
+
|
|
45
|
+
For CI, Codex, MCP servers, and other Agents, inject the token without writing it to disk:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export BOFT_AGENT_TOKEN='your-dedicated-agent-token'
|
|
49
|
+
export BOFT_BASE_URL='https://api.boft.ai' # optional
|
|
50
|
+
boft --json balance
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`BOFT_AGENT_TOKEN` always takes precedence over saved credentials. The CLI never prints the complete token; `auth status` exposes only a short prefix/suffix hint. Avoid putting tokens in command arguments, prompts, logs, or source-controlled files.
|
|
54
|
+
|
|
55
|
+
## Commands
|
|
56
|
+
|
|
57
|
+
Global options must be placed before the command:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
--json Machine-readable JSON, with no QR or labels
|
|
61
|
+
--base-url <url> API base URL (default https://api.boft.ai)
|
|
62
|
+
--timeout <milliseconds> Request timeout, 1000-120000 (default 15000)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configure Codex
|
|
66
|
+
|
|
67
|
+
The BOFT website can create a short-lived, single-use setup code. Run the command shown by the website:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx --yes @liberseek/boft-cli@latest setup codex --code BOFT-SETUP-CODE
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The setup command:
|
|
74
|
+
|
|
75
|
+
- detects `CODEX_HOME` and otherwise uses `~/.codex`
|
|
76
|
+
- verifies the Codex CLI is installed before consuming the one-time setup code
|
|
77
|
+
- preserves the existing `auth.json` and ChatGPT login
|
|
78
|
+
- adds an isolated `boft` model provider to `config.toml`
|
|
79
|
+
- stores the BOFT API Key outside Codex configuration with owner-only permissions
|
|
80
|
+
- installs a local command-backed authentication helper
|
|
81
|
+
- preserves unrelated TOML settings and comments
|
|
82
|
+
- creates a backup before every change
|
|
83
|
+
|
|
84
|
+
Inspect, diagnose, roll back, or completely remove the integration:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
boft status codex
|
|
88
|
+
boft doctor codex
|
|
89
|
+
boft rollback codex
|
|
90
|
+
boft remove codex
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For local testing before the website setup-code endpoint is available, pass the API Key over stdin. Never place the key directly in a command argument:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
printf '%s\n' "$BOFT_API_KEY" | boft setup codex --api-key-stdin \
|
|
97
|
+
--endpoint https://supply.boft.ai/v1 \
|
|
98
|
+
--model gpt-5.4
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Add `--websocket` for the Codex Responses WebSocket v2 variant. `--dry-run` is available with `--api-key-stdin`; it validates the configuration without writing files. Dry-run intentionally rejects setup codes so it cannot consume a one-time code without applying it.
|
|
102
|
+
|
|
103
|
+
Codex credentials are stored below the BOFT configuration directory, normally `~/.config/boft/codex` on macOS/Linux and `%APPDATA%\\boft\\codex` on Windows. The CLI writes files atomically and uses mode `0700` for private directories/helpers and `0600` for credentials on POSIX systems. The complete API Key is never included in command output or Codex TOML.
|
|
104
|
+
|
|
105
|
+
Account and payment methods:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
boft balance
|
|
109
|
+
boft payment methods
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Create a recharge payment. Supplying your own idempotency key is recommended when an orchestration layer may retry the same intent:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
boft recharge create --amount 100.00 --method alipay --idempotency-key order-20260802-001
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
In a terminal, the create command prints the payment ID, status, scan-ready QR code, payment link when returned by BOFT, and a `Retry key`. In JSON mode the same key is returned as `idempotency_key` alongside the server payment object. Reuse that key with `--idempotency-key` if a timeout or network failure leaves the original request outcome uncertain.
|
|
119
|
+
|
|
120
|
+
Query, long-poll, or cancel a pending payment:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
boft recharge status pay_123
|
|
124
|
+
boft recharge status pay_123 --wait # wait_seconds=25
|
|
125
|
+
boft recharge status pay_123 --wait 25
|
|
126
|
+
boft recharge cancel pay_123
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`--wait` performs one server-side long-poll and returns the status received. It does not create an unbounded local polling loop.
|
|
130
|
+
|
|
131
|
+
Inspect key groups and user-specific multipliers:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
boft group available
|
|
135
|
+
boft group available --scope agent
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Create or move a regular API Key. Creation uses an idempotency key, and any returned key secret is sensitive:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
boft key list
|
|
142
|
+
boft key create --name "Production" --group-id 12 --idempotency-key key-20260803-001
|
|
143
|
+
boft key set-group 42 --group-id 18
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Create and tune AUTO Keys:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
boft auto-key list
|
|
150
|
+
boft auto-key create --name "AUTO Production" --model gpt-4.1 claude-sonnet-4 --strategy balanced --idempotency-key auto-20260803-001
|
|
151
|
+
boft auto-key set-routing 42 --strategy cost --disable-provider openai --fallback-enabled false
|
|
152
|
+
boft auto-key preview 42
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Provider group constraints are accepted as JSON so orchestration layers can pass exact server-shaped data:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
boft auto-key set-routing 42 \
|
|
159
|
+
--provider-groups '[{"provider":"openai","mode":"specific","group_ids":[12,18]}]'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Agent integration
|
|
163
|
+
|
|
164
|
+
An Agent can invoke the CLI as a subprocess and parse stdout:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
boft --json payment methods
|
|
168
|
+
boft --json recharge create --amount 50.00 --method wechat_pay --idempotency-key "$REQUEST_ID"
|
|
169
|
+
boft --json recharge status "$PAYMENT_ID" --wait 25
|
|
170
|
+
boft --json group available
|
|
171
|
+
boft --json auto-key set-routing "$AUTO_KEY_ID" --strategy efficiency
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Successful JSON output goes to stdout. Structured errors go to stderr and the process exits nonzero:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{"error":{"message":"Agent Token has expired","status":401,"code":"TOKEN_REVOKED"}}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Secrets in known error formats and the active token value are redacted before output.
|
|
181
|
+
|
|
182
|
+
## Base URL security
|
|
183
|
+
|
|
184
|
+
Remote endpoints must use HTTPS. Plain HTTP is accepted only for `localhost`, `127.0.0.1`, or `[::1]`, which supports local contract tests without allowing a production Agent Token to be sent over a plaintext remote connection. Base URLs containing user information, query parameters, or fragments are rejected.
|
|
185
|
+
|
|
186
|
+
## Development checks
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm run lint
|
|
190
|
+
npm run typecheck
|
|
191
|
+
npm test
|
|
192
|
+
npm run build
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Tests use injected mock HTTP transports. They do not initiate real payments or require a live BOFT account.
|
|
196
|
+
|
|
197
|
+
## Maintainer release
|
|
198
|
+
|
|
199
|
+
The package is published as the public scoped package `@liberseek/boft-cli`. The repository's `Publish npm package` workflow runs only for a pushed version tag such as `v0.1.1`.
|
|
200
|
+
|
|
201
|
+
Configure the repository secret `NPM_TOKEN` with an npm automation token that has publish permission for the `@liberseek` scope. Do not commit the token or place it in a workflow file. GitHub Actions injects it only into the publish step and also creates npm provenance metadata.
|
|
202
|
+
|
|
203
|
+
For a normal patch release:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npm version patch
|
|
207
|
+
git push origin main --follow-tags
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
`npm version` updates `package.json` and `package-lock.json`, creates the matching `v*` tag, and the tag push starts the release workflow. The workflow refuses to publish when the tag version and package version differ.
|
|
211
|
+
|
|
212
|
+
Before the first release, make sure the npm `liberseek` organization/scope exists and that the publishing account or automation token can publish public packages under `@liberseek`. The current package version is `0.1.0`; publish it with:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
git tag v0.1.0
|
|
216
|
+
git push origin v0.1.0
|
|
217
|
+
```
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Account, ApiKeyRecord, AutoKeyRoutePreview, AvailableGroupsResponse, CodexSetupGrant, PaginatedResponse, PaymentOption, PaymentOrder, ProviderGroupConstraint } from './types.js';
|
|
2
|
+
interface ApiClientOptions {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
fetchImpl?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
export declare class ApiError extends Error {
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
readonly code?: number | string;
|
|
11
|
+
readonly reason?: string;
|
|
12
|
+
constructor(message: string, options?: {
|
|
13
|
+
status?: number;
|
|
14
|
+
code?: number | string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare class BoftApiClient {
|
|
19
|
+
private readonly baseUrl;
|
|
20
|
+
private readonly token;
|
|
21
|
+
private readonly timeoutMs;
|
|
22
|
+
private readonly fetchImpl;
|
|
23
|
+
constructor(options: ApiClientOptions);
|
|
24
|
+
account(): Promise<Account>;
|
|
25
|
+
paymentOptions(): Promise<PaymentOption[]>;
|
|
26
|
+
createPayment(input: {
|
|
27
|
+
amount: string;
|
|
28
|
+
payment_method: string;
|
|
29
|
+
idempotency_key: string;
|
|
30
|
+
}): Promise<PaymentOrder>;
|
|
31
|
+
paymentStatus(id: string, waitSeconds?: number): Promise<PaymentOrder>;
|
|
32
|
+
cancelPayment(id: string): Promise<PaymentOrder>;
|
|
33
|
+
listApiKeys(input?: {
|
|
34
|
+
page?: number;
|
|
35
|
+
pageSize?: number;
|
|
36
|
+
scope?: string;
|
|
37
|
+
}): Promise<PaginatedResponse<ApiKeyRecord>>;
|
|
38
|
+
createApiKey(input: {
|
|
39
|
+
name: string;
|
|
40
|
+
group_id: number;
|
|
41
|
+
scope?: string;
|
|
42
|
+
idempotency_key: string;
|
|
43
|
+
quota?: number;
|
|
44
|
+
expires_at?: string;
|
|
45
|
+
}): Promise<ApiKeyRecord>;
|
|
46
|
+
updateApiKeyGroup(id: number, groupId: number): Promise<ApiKeyRecord>;
|
|
47
|
+
availableGroups(scope?: string): Promise<AvailableGroupsResponse>;
|
|
48
|
+
listAutoKeys(input?: {
|
|
49
|
+
page?: number;
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
scope?: string;
|
|
52
|
+
}): Promise<PaginatedResponse<ApiKeyRecord>>;
|
|
53
|
+
createAutoKey(input: {
|
|
54
|
+
name: string;
|
|
55
|
+
models: string[];
|
|
56
|
+
scope?: string;
|
|
57
|
+
strategy?: string;
|
|
58
|
+
include_byok?: boolean;
|
|
59
|
+
fallback_enabled?: boolean;
|
|
60
|
+
provider_group_constraints?: ProviderGroupConstraint[];
|
|
61
|
+
quota?: number;
|
|
62
|
+
expires_at?: string;
|
|
63
|
+
idempotency_key: string;
|
|
64
|
+
}): Promise<ApiKeyRecord>;
|
|
65
|
+
updateAutoKeyRouting(id: number, input: {
|
|
66
|
+
expected_config_version?: number;
|
|
67
|
+
strategy?: string;
|
|
68
|
+
disabled_providers?: string[];
|
|
69
|
+
provider_group_constraints?: ProviderGroupConstraint[];
|
|
70
|
+
models?: string[];
|
|
71
|
+
include_byok?: boolean;
|
|
72
|
+
fallback_enabled?: boolean;
|
|
73
|
+
}): Promise<ApiKeyRecord>;
|
|
74
|
+
autoKeyRoutePreview(id: number): Promise<AutoKeyRoutePreview>;
|
|
75
|
+
private request;
|
|
76
|
+
}
|
|
77
|
+
export declare function exchangeCodexSetupGrant(options: {
|
|
78
|
+
baseUrl: string;
|
|
79
|
+
code: string;
|
|
80
|
+
timeoutMs?: number;
|
|
81
|
+
fetchImpl?: typeof fetch;
|
|
82
|
+
machineName?: string;
|
|
83
|
+
}): Promise<CodexSetupGrant>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EAEZ,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,uBAAuB,EAC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BAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACtC,uBAAuB,CAAC,EAAE,MAAM,CAAA;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC7B,0BAA0B,CAAC,EAAE,uBAAuB,EAAE,CAAA;QACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;QACjB,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,GAAG,OAAO,CAAC,YAAY,CAAC;IAIzB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAI/C,OAAO;CAiCtB;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,eAAe,CAAC,CAoC3B"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { redactText } from './redact.js';
|
|
2
|
+
const CLI_USER_AGENT = '@liberseek/boft-cli/0.1.0';
|
|
3
|
+
export class ApiError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
reason;
|
|
7
|
+
constructor(message, options = {}) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'ApiError';
|
|
10
|
+
this.status = options.status;
|
|
11
|
+
this.code = options.code;
|
|
12
|
+
this.reason = options.reason;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class BoftApiClient {
|
|
16
|
+
baseUrl;
|
|
17
|
+
token;
|
|
18
|
+
timeoutMs;
|
|
19
|
+
fetchImpl;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.baseUrl = options.baseUrl;
|
|
22
|
+
this.token = options.token;
|
|
23
|
+
this.timeoutMs = options.timeoutMs ?? 15_000;
|
|
24
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
25
|
+
}
|
|
26
|
+
account() {
|
|
27
|
+
return this.request('GET', '/api/v1/ee/agent/account');
|
|
28
|
+
}
|
|
29
|
+
paymentOptions() {
|
|
30
|
+
return this.request('GET', '/api/v1/ee/agent/payment-options')
|
|
31
|
+
.then((result) => Array.isArray(result) ? result : result.methods);
|
|
32
|
+
}
|
|
33
|
+
createPayment(input) {
|
|
34
|
+
return this.request('POST', '/api/v1/ee/agent/payments', {
|
|
35
|
+
amount: input.amount,
|
|
36
|
+
payment_method: input.payment_method,
|
|
37
|
+
}, undefined, { 'Idempotency-Key': input.idempotency_key });
|
|
38
|
+
}
|
|
39
|
+
paymentStatus(id, waitSeconds) {
|
|
40
|
+
const query = waitSeconds === undefined ? '' : `?wait_seconds=${waitSeconds}`;
|
|
41
|
+
return this.request('GET', `/api/v1/ee/agent/payments/${encodeURIComponent(id)}${query}`, undefined, waitSeconds === undefined ? undefined : (waitSeconds + 5) * 1_000);
|
|
42
|
+
}
|
|
43
|
+
cancelPayment(id) {
|
|
44
|
+
return this.request('POST', `/api/v1/ee/agent/payments/${encodeURIComponent(id)}/cancel`);
|
|
45
|
+
}
|
|
46
|
+
listApiKeys(input = {}) {
|
|
47
|
+
return this.request('GET', `/api/v1/ee/agent/keys${queryString({ page: input.page, page_size: input.pageSize, scope: input.scope })}`);
|
|
48
|
+
}
|
|
49
|
+
createApiKey(input) {
|
|
50
|
+
return this.request('POST', '/api/v1/ee/agent/keys', {
|
|
51
|
+
name: input.name,
|
|
52
|
+
group_id: input.group_id,
|
|
53
|
+
...(input.scope ? { scope: input.scope } : {}),
|
|
54
|
+
...(input.quota !== undefined ? { quota: input.quota } : {}),
|
|
55
|
+
...(input.expires_at ? { expires_at: input.expires_at } : {}),
|
|
56
|
+
}, undefined, { 'Idempotency-Key': input.idempotency_key });
|
|
57
|
+
}
|
|
58
|
+
updateApiKeyGroup(id, groupId) {
|
|
59
|
+
return this.request('PUT', `/api/v1/ee/agent/keys/${id}`, {
|
|
60
|
+
group_id: groupId,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
availableGroups(scope) {
|
|
64
|
+
return Promise.all([
|
|
65
|
+
this.request('GET', `/api/v1/ee/agent/groups/available${queryString({ scope })}`),
|
|
66
|
+
this.request('GET', `/api/v1/ee/agent/groups/rates${queryString({ scope })}`),
|
|
67
|
+
]).then(([groups, user_rates]) => ({
|
|
68
|
+
groups,
|
|
69
|
+
user_rates,
|
|
70
|
+
...(scope ? { scope } : {}),
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
listAutoKeys(input = {}) {
|
|
74
|
+
return this.request('GET', `/api/v1/ee/agent/auto-keys${queryString({ page: input.page, page_size: input.pageSize, scope: input.scope })}`);
|
|
75
|
+
}
|
|
76
|
+
createAutoKey(input) {
|
|
77
|
+
return this.request('POST', '/api/v1/ee/agent/auto-keys', {
|
|
78
|
+
name: input.name,
|
|
79
|
+
models: input.models,
|
|
80
|
+
...(input.scope ? { scope: input.scope } : {}),
|
|
81
|
+
...(input.strategy ? { strategy: input.strategy } : {}),
|
|
82
|
+
...(input.include_byok !== undefined ? { include_byok: input.include_byok } : {}),
|
|
83
|
+
...(input.fallback_enabled !== undefined ? { fallback_enabled: input.fallback_enabled } : {}),
|
|
84
|
+
...(input.provider_group_constraints ? { provider_group_constraints: input.provider_group_constraints } : {}),
|
|
85
|
+
...(input.quota !== undefined ? { quota: input.quota } : {}),
|
|
86
|
+
...(input.expires_at ? { expires_at: input.expires_at } : {}),
|
|
87
|
+
}, undefined, { 'Idempotency-Key': input.idempotency_key });
|
|
88
|
+
}
|
|
89
|
+
updateAutoKeyRouting(id, input) {
|
|
90
|
+
return this.request('PUT', `/api/v1/ee/agent/auto-keys/${id}`, input);
|
|
91
|
+
}
|
|
92
|
+
autoKeyRoutePreview(id) {
|
|
93
|
+
return this.request('GET', `/api/v1/ee/agent/auto-keys/${id}/route-preview`);
|
|
94
|
+
}
|
|
95
|
+
async request(method, path, body, timeoutOverride, extraHeaders) {
|
|
96
|
+
const controller = new AbortController();
|
|
97
|
+
const timeoutMs = timeoutOverride ?? this.timeoutMs;
|
|
98
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
99
|
+
try {
|
|
100
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
101
|
+
method,
|
|
102
|
+
headers: {
|
|
103
|
+
Accept: 'application/json',
|
|
104
|
+
Authorization: `Bearer ${this.token}`,
|
|
105
|
+
'X-BOFT-Agent-Client': 'cli',
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
'User-Agent': CLI_USER_AGENT,
|
|
108
|
+
...extraHeaders,
|
|
109
|
+
},
|
|
110
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
111
|
+
signal: controller.signal,
|
|
112
|
+
});
|
|
113
|
+
const rawText = await response.text();
|
|
114
|
+
const payload = parsePayload(rawText, response.headers.get('content-type'));
|
|
115
|
+
if (!response.ok)
|
|
116
|
+
throw errorFromPayload(payload, response.status, response.statusText, this.token);
|
|
117
|
+
return unwrapEnvelope(payload, response.status);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (error instanceof ApiError)
|
|
121
|
+
throw error;
|
|
122
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
123
|
+
throw new ApiError(`Request timed out after ${timeoutMs}ms`);
|
|
124
|
+
}
|
|
125
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
126
|
+
throw new ApiError(`Network request failed: ${redactText(message, [this.token])}`);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export async function exchangeCodexSetupGrant(options) {
|
|
134
|
+
const timeoutMs = options.timeoutMs ?? 15_000;
|
|
135
|
+
const controller = new AbortController();
|
|
136
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
137
|
+
try {
|
|
138
|
+
const response = await (options.fetchImpl ?? fetch)(`${options.baseUrl}/api/v1/ee/agent/setup-grants/exchange`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
headers: {
|
|
141
|
+
Accept: 'application/json',
|
|
142
|
+
'Content-Type': 'application/json',
|
|
143
|
+
'User-Agent': CLI_USER_AGENT,
|
|
144
|
+
'X-BOFT-Agent-Client': 'cli',
|
|
145
|
+
},
|
|
146
|
+
body: JSON.stringify({
|
|
147
|
+
code: options.code,
|
|
148
|
+
target: 'codex',
|
|
149
|
+
...(options.machineName ? { machine_name: options.machineName } : {}),
|
|
150
|
+
}),
|
|
151
|
+
signal: controller.signal,
|
|
152
|
+
});
|
|
153
|
+
const rawText = await response.text();
|
|
154
|
+
const payload = parsePayload(rawText, response.headers.get('content-type'));
|
|
155
|
+
if (!response.ok)
|
|
156
|
+
throw errorFromPayload(payload, response.status, response.statusText, options.code);
|
|
157
|
+
const grant = unwrapEnvelope(payload, response.status);
|
|
158
|
+
if (!isCodexSetupGrant(grant))
|
|
159
|
+
throw new ApiError('BOFT setup service returned an invalid Codex configuration');
|
|
160
|
+
return grant;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error instanceof ApiError)
|
|
164
|
+
throw error;
|
|
165
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
166
|
+
throw new ApiError(`Request timed out after ${timeoutMs}ms`);
|
|
167
|
+
}
|
|
168
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
169
|
+
throw new ApiError(`Network request failed: ${redactText(message, [options.code])}`);
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function parsePayload(text, contentType) {
|
|
176
|
+
if (!text)
|
|
177
|
+
return undefined;
|
|
178
|
+
try {
|
|
179
|
+
return JSON.parse(text);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
if (contentType?.includes('application/json'))
|
|
183
|
+
throw new ApiError('Server returned malformed JSON');
|
|
184
|
+
return text;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function unwrapEnvelope(payload, status) {
|
|
188
|
+
if (isEnvelope(payload)) {
|
|
189
|
+
if (String(payload.code) !== '0') {
|
|
190
|
+
throw new ApiError(payload.message || 'BOFT API request failed', {
|
|
191
|
+
status,
|
|
192
|
+
code: payload.code,
|
|
193
|
+
reason: payload.reason,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return payload.data;
|
|
197
|
+
}
|
|
198
|
+
return payload;
|
|
199
|
+
}
|
|
200
|
+
function errorFromPayload(payload, status, fallback, token) {
|
|
201
|
+
const record = asRecord(payload);
|
|
202
|
+
const nested = asRecord(record?.error);
|
|
203
|
+
const message = firstString(record?.message, record?.detail, nested?.message, typeof payload === 'string' ? payload : undefined)
|
|
204
|
+
|| fallback || `HTTP ${status}`;
|
|
205
|
+
return new ApiError(redactText(message, [token]), {
|
|
206
|
+
status,
|
|
207
|
+
code: firstValue(record?.code, nested?.code),
|
|
208
|
+
reason: firstString(record?.reason, nested?.type),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function isEnvelope(value) {
|
|
212
|
+
const record = asRecord(value);
|
|
213
|
+
return record !== undefined && (typeof record.code === 'number' || typeof record.code === 'string') &&
|
|
214
|
+
('data' in record || 'message' in record);
|
|
215
|
+
}
|
|
216
|
+
function asRecord(value) {
|
|
217
|
+
return value !== null && typeof value === 'object' ? value : undefined;
|
|
218
|
+
}
|
|
219
|
+
function firstString(...values) {
|
|
220
|
+
return values.find((value) => typeof value === 'string' && value.trim().length > 0);
|
|
221
|
+
}
|
|
222
|
+
function firstValue(...values) {
|
|
223
|
+
return values.find((value) => typeof value === 'number' || typeof value === 'string');
|
|
224
|
+
}
|
|
225
|
+
function queryString(values) {
|
|
226
|
+
const params = new URLSearchParams();
|
|
227
|
+
for (const [key, value] of Object.entries(values)) {
|
|
228
|
+
if (value !== undefined && value !== '')
|
|
229
|
+
params.set(key, String(value));
|
|
230
|
+
}
|
|
231
|
+
const query = params.toString();
|
|
232
|
+
return query ? `?${query}` : '';
|
|
233
|
+
}
|
|
234
|
+
function isCodexSetupGrant(value) {
|
|
235
|
+
const record = asRecord(value);
|
|
236
|
+
return record !== undefined && record.target === 'codex' &&
|
|
237
|
+
typeof record.base_url === 'string' && record.base_url.trim().length > 0 &&
|
|
238
|
+
typeof record.model === 'string' && record.model.trim().length > 0 &&
|
|
239
|
+
typeof record.api_key === 'string' && record.api_key.trim().length > 0 &&
|
|
240
|
+
(record.variant === undefined || record.variant === 'responses' || record.variant === 'websocket');
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAcxC,MAAM,cAAc,GAAG,2BAA2B,CAAA;AAgBlD,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAS;IACf,IAAI,CAAkB;IACtB,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,UAAwE,EAAE;QACrG,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IACP,OAAO,CAAQ;IACf,KAAK,CAAQ;IACb,SAAS,CAAQ;IACjB,SAAS,CAAc;IAExC,YAA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QAAQ,EAAE,CAAA;IAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC9B,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO;QACtD,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACxE,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAClE,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACtE,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW,CAAC,CAAA;AACtG,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { CodexInstallation } from './codex.js';
|
|
3
|
+
import type { Credentials, OutputWriter } from './types.js';
|
|
4
|
+
interface CliDependencies {
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
fetchImpl?: typeof fetch;
|
|
7
|
+
writer?: OutputWriter;
|
|
8
|
+
promptToken?: () => Promise<string>;
|
|
9
|
+
promptApiKey?: () => Promise<string>;
|
|
10
|
+
promptSetupCode?: () => Promise<string>;
|
|
11
|
+
nodePath?: string;
|
|
12
|
+
codexProbe?: (env: NodeJS.ProcessEnv) => Promise<CodexInstallation>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createProgram(dependencies?: CliDependencies): Command;
|
|
15
|
+
export declare function run(argv?: string[], dependencies?: CliDependencies): Promise<number>;
|
|
16
|
+
export declare function credentialsForTest(token: string, baseUrl: string): Credentials;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAA;AAUnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAsBnD,OAAO,KAAK,EAAE,WAAW,EAAiB,YAAY,EAA2B,MAAM,YAAY,CAAA;AAGnG,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACpC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACpE;AAED,wBAAgB,aAAa,CAAC,YAAY,GAAE,eAAoB,GAAG,OAAO,CAmczE;AAED,wBAAsB,GAAG,CAAC,IAAI,WAAe,EAAE,YAAY,GAAE,eAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBlG;AAsBD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAE9E"}
|