brigent-sdk 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 +184 -0
- package/dist/client.d.ts +81 -0
- package/dist/client.js +190 -0
- package/dist/cost.d.ts +13 -0
- package/dist/cost.js +106 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +18 -0
- package/dist/events.d.ts +29 -0
- package/dist/events.js +145 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.js +93 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +7 -0
- package/dist/monitor.d.ts +15 -0
- package/dist/monitor.js +58 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.js +3 -0
- package/dist/webhooks.d.ts +10 -0
- package/dist/webhooks.js +17 -0
- package/package.json +48 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
export type DeploymentType = "api" | "fullstack" | "frontend" | "worker" | "static_site" | "database_only" | "cron";
|
|
2
|
+
export type SourceMethod = "code" | "docker_image" | "git_repo";
|
|
3
|
+
export type Runtime = "node" | "python" | "go" | "rust" | "deno" | "bun";
|
|
4
|
+
export type DurationMode = "ephemeral" | "persistent";
|
|
5
|
+
export type BudgetAction = "pause" | "terminate" | "notify";
|
|
6
|
+
export type DeploymentStatus = "pending" | "provisioning" | "building" | "deploying" | "health_checking" | "live" | "paused" | "terminating" | "terminated" | "failed";
|
|
7
|
+
export type Region = "us-west" | "us-east" | "eu-west" | "ap-southeast";
|
|
8
|
+
export interface DeployRequest {
|
|
9
|
+
type: DeploymentType;
|
|
10
|
+
name: string;
|
|
11
|
+
source: {
|
|
12
|
+
method: SourceMethod;
|
|
13
|
+
runtime?: Runtime;
|
|
14
|
+
entry_point?: string;
|
|
15
|
+
code?: string;
|
|
16
|
+
image?: string;
|
|
17
|
+
repo_url?: string;
|
|
18
|
+
branch?: string;
|
|
19
|
+
build_command?: string;
|
|
20
|
+
};
|
|
21
|
+
resources?: {
|
|
22
|
+
database?: boolean | {
|
|
23
|
+
engine: "postgres";
|
|
24
|
+
extensions?: string[];
|
|
25
|
+
};
|
|
26
|
+
cache?: boolean | {
|
|
27
|
+
max_memory_mb: number;
|
|
28
|
+
};
|
|
29
|
+
storage?: boolean | {
|
|
30
|
+
max_gb: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
duration_mode?: DurationMode;
|
|
34
|
+
budget_cap_usdc?: string;
|
|
35
|
+
on_budget_exhausted?: BudgetAction;
|
|
36
|
+
health_check_path?: string;
|
|
37
|
+
env_vars?: Record<string, string>;
|
|
38
|
+
idempotency_key?: string;
|
|
39
|
+
region?: Region;
|
|
40
|
+
}
|
|
41
|
+
export interface DeployResponse {
|
|
42
|
+
deployment_id: string;
|
|
43
|
+
status: "provisioning";
|
|
44
|
+
estimated_ready_seconds: number;
|
|
45
|
+
status_url: string;
|
|
46
|
+
cost_estimate: {
|
|
47
|
+
setup_usdc: string;
|
|
48
|
+
hourly_usdc: string;
|
|
49
|
+
monthly_estimate_usdc: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface ResourceStatus {
|
|
53
|
+
status: string;
|
|
54
|
+
provider_class?: string;
|
|
55
|
+
engine?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface DeploymentDetail {
|
|
58
|
+
deployment_id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
type: DeploymentType;
|
|
61
|
+
status: DeploymentStatus;
|
|
62
|
+
url?: string;
|
|
63
|
+
resources: {
|
|
64
|
+
compute: ResourceStatus;
|
|
65
|
+
database?: ResourceStatus;
|
|
66
|
+
cache?: ResourceStatus;
|
|
67
|
+
storage?: ResourceStatus;
|
|
68
|
+
domain: ResourceStatus;
|
|
69
|
+
};
|
|
70
|
+
budget: {
|
|
71
|
+
cap_usdc: string;
|
|
72
|
+
spent_usdc: string;
|
|
73
|
+
remaining_usdc: string;
|
|
74
|
+
};
|
|
75
|
+
created_at: string;
|
|
76
|
+
live_at?: string;
|
|
77
|
+
terminated_at?: string;
|
|
78
|
+
failure_reason?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface DeploymentListItem {
|
|
81
|
+
deployment_id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
type: DeploymentType;
|
|
84
|
+
status: DeploymentStatus;
|
|
85
|
+
url?: string;
|
|
86
|
+
created_at: string;
|
|
87
|
+
}
|
|
88
|
+
export interface PaginatedResponse<T> {
|
|
89
|
+
data: T[];
|
|
90
|
+
total: number;
|
|
91
|
+
page: number;
|
|
92
|
+
per_page: number;
|
|
93
|
+
}
|
|
94
|
+
export interface CostEstimate {
|
|
95
|
+
setup_usdc: string;
|
|
96
|
+
hourly_usdc: string;
|
|
97
|
+
monthly_estimate_usdc: string;
|
|
98
|
+
breakdown: CostLineItem[];
|
|
99
|
+
}
|
|
100
|
+
export interface CostLineItem {
|
|
101
|
+
resource: string;
|
|
102
|
+
unit: string;
|
|
103
|
+
unit_price_usdc: string;
|
|
104
|
+
quantity: number;
|
|
105
|
+
subtotal_usdc: string;
|
|
106
|
+
}
|
|
107
|
+
export interface BudgetStatus {
|
|
108
|
+
cap_usdc: string;
|
|
109
|
+
spent_usdc: string;
|
|
110
|
+
remaining_usdc: string;
|
|
111
|
+
percent_used: number;
|
|
112
|
+
}
|
|
113
|
+
export interface CostResponse {
|
|
114
|
+
deployment_id: string;
|
|
115
|
+
budget: BudgetStatus;
|
|
116
|
+
billing_events: BillingEvent[];
|
|
117
|
+
current_rates: CostEstimate | null;
|
|
118
|
+
}
|
|
119
|
+
export interface BillingEvent {
|
|
120
|
+
id: string;
|
|
121
|
+
event_type: string;
|
|
122
|
+
amount_usdc: string;
|
|
123
|
+
created_at: string;
|
|
124
|
+
}
|
|
125
|
+
export interface LogEntry {
|
|
126
|
+
timestamp: string;
|
|
127
|
+
message: string;
|
|
128
|
+
level?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface ScaleConfig {
|
|
131
|
+
replicas?: number;
|
|
132
|
+
cpu?: number;
|
|
133
|
+
memory_mb?: number;
|
|
134
|
+
}
|
|
135
|
+
export interface ApiKeyCreateParams {
|
|
136
|
+
name: string;
|
|
137
|
+
scopes?: string[];
|
|
138
|
+
budget_limit?: number;
|
|
139
|
+
expires_in_days?: number;
|
|
140
|
+
rate_limit_tier?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface ApiKeyResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
key: string;
|
|
145
|
+
name: string;
|
|
146
|
+
scopes: string[];
|
|
147
|
+
rate_limit_tier: string;
|
|
148
|
+
created_at: string;
|
|
149
|
+
expires_at?: string;
|
|
150
|
+
budget_limit: number | null;
|
|
151
|
+
}
|
|
152
|
+
export interface ApiKeyListItem {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
scopes: string[];
|
|
156
|
+
rate_limit_tier: string;
|
|
157
|
+
created_at: string;
|
|
158
|
+
expires_at?: string;
|
|
159
|
+
budget_limit: number | null;
|
|
160
|
+
revoked_at: string | null;
|
|
161
|
+
active: boolean;
|
|
162
|
+
}
|
|
163
|
+
export interface WebhookCreateParams {
|
|
164
|
+
url: string;
|
|
165
|
+
events: string[];
|
|
166
|
+
}
|
|
167
|
+
export interface WebhookUpdateParams {
|
|
168
|
+
url?: string;
|
|
169
|
+
events?: string[];
|
|
170
|
+
active?: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface WebhookResponse {
|
|
173
|
+
id: string;
|
|
174
|
+
url: string;
|
|
175
|
+
events: string[];
|
|
176
|
+
secret: string;
|
|
177
|
+
active: boolean;
|
|
178
|
+
created_at: string;
|
|
179
|
+
}
|
|
180
|
+
export interface WebhookListItem {
|
|
181
|
+
id: string;
|
|
182
|
+
url: string;
|
|
183
|
+
events: string[];
|
|
184
|
+
active: boolean;
|
|
185
|
+
created_at: string;
|
|
186
|
+
}
|
|
187
|
+
export interface HealthResponse {
|
|
188
|
+
status: string;
|
|
189
|
+
service: string;
|
|
190
|
+
version: string;
|
|
191
|
+
timestamp: string;
|
|
192
|
+
}
|
|
193
|
+
export interface ReadinessResponse {
|
|
194
|
+
status: "ok" | "degraded";
|
|
195
|
+
service: string;
|
|
196
|
+
version: string;
|
|
197
|
+
components: Record<string, {
|
|
198
|
+
status: string;
|
|
199
|
+
}>;
|
|
200
|
+
timestamp: string;
|
|
201
|
+
}
|
|
202
|
+
export interface BrigentClientOptions {
|
|
203
|
+
apiKey: string;
|
|
204
|
+
baseUrl?: string;
|
|
205
|
+
timeout?: number;
|
|
206
|
+
maxRetries?: number;
|
|
207
|
+
}
|
|
208
|
+
/** Error codes returned by the Brigent server API */
|
|
209
|
+
export type ServerErrorCode = "INVALID_REQUEST" | "INVALID_SOURCE" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "DEPLOYMENT_NOT_FOUND" | "NOT_FOUND" | "CONFLICT" | "IDEMPOTENCY_CONFLICT" | "BUDGET_TOO_LOW" | "RATE_LIMITED" | "INTERNAL_ERROR" | "PROVIDER_UNAVAILABLE" | "CAPACITY_EXHAUSTED";
|
|
210
|
+
/** Error codes generated by the SDK client (not from server) */
|
|
211
|
+
export type SdkErrorCode = "UNKNOWN" | "SSE_CONNECTION_FAILED" | "SSE_NO_BODY" | "DEPLOYMENT_FAILED" | "DEPLOYMENT_TERMINATED" | "MONITOR_TIMEOUT";
|
|
212
|
+
/** All possible error codes (server + SDK client) */
|
|
213
|
+
export type ErrorCode = ServerErrorCode | SdkErrorCode;
|
|
214
|
+
export interface BrigentErrorBody {
|
|
215
|
+
error: {
|
|
216
|
+
code: ErrorCode;
|
|
217
|
+
message: string;
|
|
218
|
+
suggested_action: string;
|
|
219
|
+
documentation_url: string;
|
|
220
|
+
retry_after_seconds?: number;
|
|
221
|
+
details?: Record<string, unknown>;
|
|
222
|
+
};
|
|
223
|
+
request_id: string;
|
|
224
|
+
}
|
|
225
|
+
export interface AnalyticsOverview {
|
|
226
|
+
total_deployments: number;
|
|
227
|
+
active_deployments: number;
|
|
228
|
+
total_spend_usdc: string;
|
|
229
|
+
deployment_type_breakdown: Array<{
|
|
230
|
+
type: DeploymentType;
|
|
231
|
+
count: number;
|
|
232
|
+
}>;
|
|
233
|
+
generated_at: string;
|
|
234
|
+
}
|
|
235
|
+
export interface MetricsSnapshot {
|
|
236
|
+
timestamp: string;
|
|
237
|
+
cpu_percent: number;
|
|
238
|
+
memory_mb: number;
|
|
239
|
+
memory_limit_mb: number;
|
|
240
|
+
network_rx_bytes: number;
|
|
241
|
+
network_tx_bytes: number;
|
|
242
|
+
}
|
|
243
|
+
export interface UsageMetrics {
|
|
244
|
+
cpu_percent?: number;
|
|
245
|
+
memory_mb?: number;
|
|
246
|
+
storage_gb?: number;
|
|
247
|
+
requests?: number;
|
|
248
|
+
egress_gb?: number;
|
|
249
|
+
}
|
|
250
|
+
export interface DeploymentMetrics {
|
|
251
|
+
deployment_id: string;
|
|
252
|
+
metrics: MetricsSnapshot;
|
|
253
|
+
usage: UsageMetrics;
|
|
254
|
+
retrieved_at: string;
|
|
255
|
+
}
|
|
256
|
+
export interface AuditLogEntry {
|
|
257
|
+
id: string;
|
|
258
|
+
action: string;
|
|
259
|
+
deployment_id: string | null;
|
|
260
|
+
request_summary: string;
|
|
261
|
+
response_status: number;
|
|
262
|
+
ip_address: string | null;
|
|
263
|
+
created_at: string;
|
|
264
|
+
}
|
|
265
|
+
export interface AuditLogOptions {
|
|
266
|
+
action?: string;
|
|
267
|
+
since?: string;
|
|
268
|
+
page?: number;
|
|
269
|
+
per_page?: number;
|
|
270
|
+
}
|
|
271
|
+
export interface BillingSummary {
|
|
272
|
+
period: {
|
|
273
|
+
start: string | null;
|
|
274
|
+
end: string | null;
|
|
275
|
+
};
|
|
276
|
+
total_usdc: string;
|
|
277
|
+
billed_deployments: number;
|
|
278
|
+
top_deployments: Array<{
|
|
279
|
+
deployment_id: string;
|
|
280
|
+
name: string;
|
|
281
|
+
type: DeploymentType;
|
|
282
|
+
status: DeploymentStatus;
|
|
283
|
+
total_usdc: string;
|
|
284
|
+
}>;
|
|
285
|
+
}
|
|
286
|
+
export interface BillingSummaryOptions {
|
|
287
|
+
since?: string;
|
|
288
|
+
until?: string;
|
|
289
|
+
}
|
|
290
|
+
export interface TemplateCreateParams {
|
|
291
|
+
name: string;
|
|
292
|
+
description?: string;
|
|
293
|
+
deployment_type: DeploymentType;
|
|
294
|
+
config: Record<string, unknown>;
|
|
295
|
+
is_public?: boolean;
|
|
296
|
+
}
|
|
297
|
+
export interface TemplateResponse {
|
|
298
|
+
id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
description: string | null;
|
|
301
|
+
deployment_type: DeploymentType;
|
|
302
|
+
config: Record<string, unknown>;
|
|
303
|
+
is_public: boolean;
|
|
304
|
+
is_own: boolean;
|
|
305
|
+
created_at: string;
|
|
306
|
+
}
|
|
307
|
+
export interface CustomDomainResponse {
|
|
308
|
+
deployment_id: string;
|
|
309
|
+
fqdn: string;
|
|
310
|
+
domain: string;
|
|
311
|
+
status: "assigned";
|
|
312
|
+
}
|
|
313
|
+
export interface WebhookDeliveryItem {
|
|
314
|
+
id: string;
|
|
315
|
+
event_type: string;
|
|
316
|
+
event_id: string;
|
|
317
|
+
status: string;
|
|
318
|
+
attempts: number;
|
|
319
|
+
last_error: string | null;
|
|
320
|
+
created_at: string;
|
|
321
|
+
delivered_at: string | null;
|
|
322
|
+
}
|
|
323
|
+
export interface PricingTier {
|
|
324
|
+
name: string;
|
|
325
|
+
display_name: string;
|
|
326
|
+
price_multiplier: number;
|
|
327
|
+
monthly_base_usdc: string;
|
|
328
|
+
features: Record<string, boolean>;
|
|
329
|
+
limits: Record<string, number>;
|
|
330
|
+
rate_limits: {
|
|
331
|
+
deploys_per_hour: number;
|
|
332
|
+
gets_per_minute: number;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
export interface PricingResponse {
|
|
336
|
+
tiers: PricingTier[];
|
|
337
|
+
}
|
|
338
|
+
export interface TierResponse {
|
|
339
|
+
tier: string;
|
|
340
|
+
display_name: string;
|
|
341
|
+
price_multiplier: number;
|
|
342
|
+
monthly_base_usdc: string;
|
|
343
|
+
features: Record<string, boolean>;
|
|
344
|
+
limits: Record<string, number>;
|
|
345
|
+
rate_limits: {
|
|
346
|
+
deploys_per_hour: number;
|
|
347
|
+
gets_per_minute: number;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
export interface DeploymentEvent {
|
|
351
|
+
deployment_id: string;
|
|
352
|
+
status: string;
|
|
353
|
+
previous_status?: string;
|
|
354
|
+
timestamp: string;
|
|
355
|
+
failure_reason?: string;
|
|
356
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify a webhook signature from Brigent.
|
|
3
|
+
* The signature is sent in the X-Brigent-Signature header.
|
|
4
|
+
*
|
|
5
|
+
* @param payload - The raw request body as a string
|
|
6
|
+
* @param signature - The X-Brigent-Signature header value
|
|
7
|
+
* @param secret - The webhook secret (whsec_...)
|
|
8
|
+
* @returns true if the signature is valid
|
|
9
|
+
*/
|
|
10
|
+
export declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Verify a webhook signature from Brigent.
|
|
4
|
+
* The signature is sent in the X-Brigent-Signature header.
|
|
5
|
+
*
|
|
6
|
+
* @param payload - The raw request body as a string
|
|
7
|
+
* @param signature - The X-Brigent-Signature header value
|
|
8
|
+
* @param secret - The webhook secret (whsec_...)
|
|
9
|
+
* @returns true if the signature is valid
|
|
10
|
+
*/
|
|
11
|
+
export function verifyWebhookSignature(payload, signature, secret) {
|
|
12
|
+
const expected = createHmac("sha256", secret).update(payload).digest("hex");
|
|
13
|
+
// Use timing-safe comparison to prevent timing attacks
|
|
14
|
+
if (expected.length !== signature.length)
|
|
15
|
+
return false;
|
|
16
|
+
return timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(signature, "hex"));
|
|
17
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "brigent-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Brigent Agent-Native Infrastructure Platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"brigent",
|
|
26
|
+
"ai-agent",
|
|
27
|
+
"infrastructure",
|
|
28
|
+
"deployment",
|
|
29
|
+
"paas",
|
|
30
|
+
"sdk",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/balflee/brigent.git",
|
|
36
|
+
"directory": "sdk"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/balflee/brigent/tree/main/sdk#readme",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.3.2",
|
|
45
|
+
"typescript": "^5.7.0",
|
|
46
|
+
"vitest": "^3.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|