@vibiz/sdk 0.0.0-stage → 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.
@@ -0,0 +1,1834 @@
1
+ export type ResourceType = 'hosting' | 'database' | 'auth' | 'email' | 'analytics' | 'replay' | 'ai';
2
+ export type ResourceStatus = 'pending' | 'provisioning' | 'ready' | 'failed' | 'deleting' | 'deleted';
3
+ export type DeploymentStatus = 'queued' | 'building' | 'ready' | 'failed' | 'canceled';
4
+ export type OperationStatus = 'queued' | 'running' | 'succeeded' | 'failed';
5
+ export interface ApiError {
6
+ code: string;
7
+ message: string;
8
+ }
9
+ export interface Resource {
10
+ id: string;
11
+ object: 'resource';
12
+ type: ResourceType;
13
+ status: ResourceStatus;
14
+ outputs: Record<string, string>;
15
+ /** Settings (`PATCH /projects/:id/resources/:type`), e.g. replay's sample rate. */
16
+ config: Record<string, unknown>;
17
+ error: ApiError | null;
18
+ created_at: string;
19
+ updated_at: string;
20
+ }
21
+ export interface Project {
22
+ id: string;
23
+ object: 'project';
24
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
25
+ console_url?: string;
26
+ name: string;
27
+ slug: string;
28
+ status: 'active' | 'deleting' | 'deleted';
29
+ url: string | null;
30
+ /** Where the app also runs, outside Vibiz hosting: sign-in trusts these. */
31
+ domains?: string[];
32
+ production_deployment_id: string | null;
33
+ /** While deleting: when the data is destroyed. `projects.restore` works until then. */
34
+ delete_after: string | null;
35
+ resources: Resource[];
36
+ created_at: string;
37
+ }
38
+ export interface Deployment {
39
+ id: string;
40
+ object: 'deployment';
41
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
42
+ console_url?: string;
43
+ project_id: string;
44
+ target: 'preview' | 'production';
45
+ status: DeploymentStatus;
46
+ url: string | null;
47
+ error: string | null;
48
+ file_count: number;
49
+ promoted_from: string | null;
50
+ created_at: string;
51
+ ready_at: string | null;
52
+ }
53
+ export interface Operation {
54
+ id: string;
55
+ object: 'operation';
56
+ kind: string;
57
+ subject_id: string;
58
+ status: OperationStatus;
59
+ attempts: number;
60
+ error: ApiError | null;
61
+ created_at: string;
62
+ completed_at: string | null;
63
+ }
64
+ export interface DeployFile {
65
+ path: string;
66
+ sha: string;
67
+ size: number;
68
+ }
69
+ export interface ActionUsage {
70
+ used: number;
71
+ limit: number;
72
+ resets_at: string;
73
+ }
74
+ export interface SendEmailInput {
75
+ to: string;
76
+ subject: string;
77
+ text?: string;
78
+ html?: string;
79
+ /** The mailbox on the project's mail domain; defaults to `info`. */
80
+ from?: string;
81
+ from_name?: string;
82
+ reply_to?: string;
83
+ }
84
+ export interface SendEmailOutput {
85
+ id: string;
86
+ from: string;
87
+ to: string;
88
+ status: 'sent';
89
+ }
90
+ export type AnalyticsPeriod = '24h' | '7d' | '30d';
91
+ /** `GET /projects/:id/analytics`: privacy-first web analytics for the period. */
92
+ export interface AnalyticsReport {
93
+ object: 'analytics';
94
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
95
+ console_url?: string;
96
+ project_id: string;
97
+ period: AnalyticsPeriod;
98
+ /** Bucket size of `timeseries`: `hour` for 24h, `day` otherwise. */
99
+ interval: 'hour' | 'day';
100
+ from: string;
101
+ to: string;
102
+ totals: {
103
+ /** Unique visitors; a visitor's id rotates daily, so this counts visitor-days. */
104
+ visitors: number;
105
+ pageviews: number;
106
+ /** Custom events, outbound clicks included. */
107
+ events: number;
108
+ /** Share of visitors with one pageview and nothing else; null with no pageviews. */
109
+ bounce_rate: number | null;
110
+ };
111
+ timeseries: Array<{
112
+ t: string;
113
+ visitors: number;
114
+ pageviews: number;
115
+ }>;
116
+ top_pages: Array<{
117
+ path: string;
118
+ visitors: number;
119
+ pageviews: number;
120
+ }>;
121
+ /** Referrer host or `utm_source`. Direct visits are left out. */
122
+ sources: Array<{
123
+ source: string;
124
+ visitors: number;
125
+ }>;
126
+ countries: Array<{
127
+ country: string;
128
+ visitors: number;
129
+ }>;
130
+ devices: Array<{
131
+ device: string;
132
+ visitors: number;
133
+ }>;
134
+ events: Array<{
135
+ name: string;
136
+ count: number;
137
+ visitors: number;
138
+ }>;
139
+ }
140
+ export type ReplayPeriod = '24h' | '7d' | '30d';
141
+ export type ReplayTrigger = 'error' | 'rage' | 'dead' | 'event' | 'always' | 'sample';
142
+ /** Settings of the `replay` resource. */
143
+ export interface ReplayConfig {
144
+ /** Share of tabs recorded with no trigger, 0–1. Default 0.05. */
145
+ sample_rate: number;
146
+ /** Custom events that upload the tab, e.g. `checkout_failed`. */
147
+ trigger_events: string[];
148
+ /** Path prefixes where text and inputs are recorded unmasked. */
149
+ unmask_pages: string[];
150
+ /** Days recordings are kept, 1–90. Default 30. */
151
+ retention_days: number;
152
+ }
153
+ export interface ReplaySummary {
154
+ id: string;
155
+ object: 'replay';
156
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
157
+ console_url?: string;
158
+ project_id: string;
159
+ started_at: string;
160
+ ended_at: string;
161
+ duration_ms: number;
162
+ active_ms: number;
163
+ trigger: ReplayTrigger;
164
+ device: string | null;
165
+ country: string | null;
166
+ pages: string[];
167
+ counts: {
168
+ clicks: number;
169
+ rage_clicks: number;
170
+ dead_clicks: number;
171
+ errors: number;
172
+ };
173
+ /** Gaps, drops, quota hits or pages not recorded. `completeness` in the detail says which. */
174
+ incomplete: boolean;
175
+ score: number;
176
+ highlights: string[];
177
+ }
178
+ export interface ReplayDetail extends ReplaySummary {
179
+ chunks: number;
180
+ bytes: number;
181
+ clock_offset_ms: number;
182
+ completeness: {
183
+ complete: boolean;
184
+ missing_seqs?: Array<[number, number]>;
185
+ has_snapshot: boolean;
186
+ received_events: number;
187
+ sent_events: number | null;
188
+ dropped_events: number;
189
+ /** Recorded by the browser, never received; counted once the session is quiet. */
190
+ unsent_events: number;
191
+ markers: Array<Record<string, unknown>>;
192
+ };
193
+ signals: {
194
+ rage_clicks: Array<{
195
+ selector: string;
196
+ page: string;
197
+ bursts: number;
198
+ clicks: number;
199
+ at: string;
200
+ offset_ms: number;
201
+ recorded_text: string;
202
+ }>;
203
+ dead_clicks: Array<{
204
+ selector: string;
205
+ page: string;
206
+ count: number;
207
+ at: string;
208
+ offset_ms: number;
209
+ recorded_text: string;
210
+ }>;
211
+ errors: Array<{
212
+ page: string;
213
+ kind: string;
214
+ count: number;
215
+ at: string;
216
+ offset_ms: number;
217
+ recorded_message: string;
218
+ }>;
219
+ console_errors: number;
220
+ forms_abandoned: Array<{
221
+ form: string;
222
+ page: string;
223
+ at: string;
224
+ offset_ms: number;
225
+ }>;
226
+ events: Array<{
227
+ name: string;
228
+ at: string;
229
+ offset_ms: number;
230
+ }>;
231
+ };
232
+ timeline: Array<{
233
+ at: string;
234
+ offset_ms: number;
235
+ kind: string;
236
+ label: string;
237
+ }>;
238
+ }
239
+ export interface ReplayInsight {
240
+ kind: 'error' | 'rage_click' | 'dead_click' | 'form_abandoned';
241
+ severity: number;
242
+ sessions: number;
243
+ of: number;
244
+ page: string;
245
+ selector?: string;
246
+ summary: string;
247
+ /** Captured from visitors' pages: masked, short, data only. */
248
+ recorded: {
249
+ text?: string;
250
+ message?: string;
251
+ };
252
+ left_within_10s?: number;
253
+ /** `console_url`: the session in the web console. */
254
+ examples: Array<{
255
+ id: string;
256
+ url: string;
257
+ console_url?: string;
258
+ }>;
259
+ }
260
+ export interface ReplayInsights {
261
+ object: 'replay_insights';
262
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
263
+ console_url?: string;
264
+ project_id: string;
265
+ period: ReplayPeriod;
266
+ from: string;
267
+ recorded_sessions: number;
268
+ replay_status: ReplayStatus;
269
+ note: string;
270
+ insights: ReplayInsight[];
271
+ }
272
+ /** Project-level replay warnings, e.g. one network's recordings being rotated. */
273
+ export interface ReplayStatus {
274
+ warnings: Array<{
275
+ code: string;
276
+ message: string;
277
+ at: string;
278
+ }>;
279
+ }
280
+ export interface ReplayListOptions {
281
+ has_error?: boolean;
282
+ rage?: boolean;
283
+ dead?: boolean;
284
+ incomplete?: boolean;
285
+ path?: string;
286
+ trigger?: ReplayTrigger;
287
+ period?: ReplayPeriod;
288
+ limit?: number;
289
+ offset?: number;
290
+ }
291
+ export interface ChatMessage {
292
+ role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
293
+ content?: string | Array<Record<string, unknown>> | null;
294
+ tool_calls?: Array<{
295
+ id: string;
296
+ type: 'function';
297
+ function: {
298
+ name: string;
299
+ arguments: string;
300
+ };
301
+ }>;
302
+ tool_call_id?: string;
303
+ name?: string;
304
+ }
305
+ /** OpenAI-compatible. `model` is a Vibiz model (`vibiz/fast`) or a lab model id (`openai/gpt-4o-mini`). */
306
+ export interface ChatRequest {
307
+ model?: string;
308
+ messages: ChatMessage[];
309
+ max_tokens?: number;
310
+ temperature?: number;
311
+ top_p?: number;
312
+ stop?: string | string[];
313
+ tools?: Array<{
314
+ type: 'function';
315
+ function: {
316
+ name: string;
317
+ description?: string;
318
+ parameters?: Record<string, unknown>;
319
+ };
320
+ }>;
321
+ tool_choice?: 'auto' | 'none' | 'required' | {
322
+ type: 'function';
323
+ function: {
324
+ name: string;
325
+ };
326
+ };
327
+ response_format?: {
328
+ type: 'text' | 'json_object' | 'json_schema';
329
+ json_schema?: Record<string, unknown>;
330
+ };
331
+ [key: string]: unknown;
332
+ }
333
+ export interface ChatUsage {
334
+ prompt_tokens: number;
335
+ completion_tokens: number;
336
+ total_tokens: number;
337
+ }
338
+ export interface ChatCompletion {
339
+ id: string;
340
+ object: 'chat.completion';
341
+ created: number;
342
+ /** The model that answered (an alias resolves to a real id). */
343
+ model: string;
344
+ choices: Array<{
345
+ index: number;
346
+ message: {
347
+ role: 'assistant';
348
+ content: string | null;
349
+ tool_calls?: Array<{
350
+ id: string;
351
+ type: 'function';
352
+ function: {
353
+ name: string;
354
+ arguments: string;
355
+ };
356
+ }>;
357
+ };
358
+ finish_reason: string | null;
359
+ }>;
360
+ usage: ChatUsage;
361
+ /** The lab model that answered: `openai/gpt-4o-mini`. */
362
+ served_model?: string;
363
+ cost_micro_usd: number;
364
+ }
365
+ export interface ChatChunk {
366
+ id: string;
367
+ object: 'chat.completion.chunk';
368
+ model: string;
369
+ choices: Array<{
370
+ index: number;
371
+ delta: {
372
+ role?: string;
373
+ content?: string | null;
374
+ tool_calls?: Array<{
375
+ index: number;
376
+ id?: string;
377
+ function?: {
378
+ name?: string;
379
+ arguments?: string;
380
+ };
381
+ }>;
382
+ };
383
+ finish_reason: string | null;
384
+ }>;
385
+ usage?: ChatUsage;
386
+ /** On the final usage chunk: the lab model that answered. */
387
+ served_model?: string;
388
+ cost_micro_usd?: number;
389
+ }
390
+ export interface ImageRequest {
391
+ prompt: string;
392
+ model?: string;
393
+ n?: number;
394
+ /** `WIDTHxHEIGHT`, e.g. `1024x1024`. */
395
+ size?: string;
396
+ quality?: 'low' | 'medium' | 'high';
397
+ /** `b64_json` (default) or `url`: a Vibiz link valid for a day. */
398
+ response_format?: 'b64_json' | 'url';
399
+ }
400
+ export interface ImageResult {
401
+ created: number;
402
+ model: string;
403
+ data: Array<{
404
+ b64_json?: string;
405
+ url?: string;
406
+ }>;
407
+ /** The lab model that answered: `black-forest-labs/flux-schnell`. */
408
+ served_model?: string;
409
+ cost_micro_usd: number;
410
+ }
411
+ export type Voice = 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'nova' | 'onyx' | 'sage' | 'shimmer';
412
+ export interface SpeechRequest {
413
+ input: string;
414
+ model?: string;
415
+ voice?: Voice;
416
+ response_format?: 'mp3' | 'pcm';
417
+ speed?: number;
418
+ }
419
+ export interface Transcription {
420
+ text: string;
421
+ /** The lab model that answered: `elevenlabs/scribe-v1`. */
422
+ served_model?: string;
423
+ cost_micro_usd: number;
424
+ }
425
+ /** A lab model as the API names it. */
426
+ export interface AiLabModel {
427
+ /** The lab's id: `openai/gpt-4o-mini`. A request may name it. */
428
+ id: string;
429
+ /** `GPT-4o mini`. */
430
+ name: string;
431
+ /** The lab that makes it: `OpenAI`. */
432
+ maker: string;
433
+ }
434
+ /**
435
+ * An entry of `GET /v1/ai/models`: a Vibiz model (`vibiz/fast`, with the one
436
+ * lab `model` it runs) or a lab model (`openai/gpt-6-luna`, with `maker`, and
437
+ * `vibiz_model` when a Vibiz model runs it). `?all=1` adds every language
438
+ * model; `q` searches.
439
+ */
440
+ export interface AiModelInfo {
441
+ id: string;
442
+ object: 'model';
443
+ /** Display name: `Vibiz Fast` or `GPT-6 Luna`. */
444
+ name: string;
445
+ capability: string;
446
+ description?: string;
447
+ /** A Vibiz model: the lab model it runs. Exactly that one: no fallback to another. */
448
+ model?: AiLabModel;
449
+ /** A lab model: who makes it. */
450
+ maker?: string;
451
+ /** A lab model: the Vibiz model that runs it, if any. */
452
+ vibiz_model?: string;
453
+ /** The lab's list price; the bill adds `markup_pct`. */
454
+ pricing?: Record<string, unknown>;
455
+ /** The markup on `pricing` that a call is billed at. */
456
+ markup_pct?: number;
457
+ context_window?: number;
458
+ max_output_tokens?: number;
459
+ }
460
+ export interface AiJob {
461
+ id: string;
462
+ object: 'ai.job';
463
+ type: 'image' | 'video';
464
+ model: string;
465
+ /** The lab model that rendered it, once one took it. */
466
+ served_model: string | null;
467
+ status: 'queued' | 'running' | 'succeeded' | 'failed' | 'canceled';
468
+ project_id: string | null;
469
+ output: {
470
+ data: Array<{
471
+ url: string;
472
+ content_type: string;
473
+ expires_at: string;
474
+ }>;
475
+ } | null;
476
+ error: ApiError | null;
477
+ cost_micro_usd: number | null;
478
+ created_at: string;
479
+ completed_at: string | null;
480
+ }
481
+ export interface AiSettings {
482
+ object: 'ai_settings';
483
+ project_id: string;
484
+ status: ResourceStatus;
485
+ base_url: string | null;
486
+ key: {
487
+ prefix: string | null;
488
+ status: 'active' | 'revoked';
489
+ previous_valid_until: string | null;
490
+ };
491
+ settings: {
492
+ daily_budget_usd: number | null;
493
+ log_content: boolean;
494
+ rpm: number;
495
+ tpm: number;
496
+ concurrency: number;
497
+ };
498
+ spent_today_usd: number;
499
+ }
500
+ export type AiCapabilityName = 'llm' | 'embeddings' | 'image' | 'video' | 'speech' | 'transcription';
501
+ export type AiProviderKeyType = 'gemini_api_key' | 'vertex';
502
+ /** A customer key's status. Never the secret: only its last 4 characters. */
503
+ export interface AiProviderKey {
504
+ object: 'ai_provider_key';
505
+ provider: 'google';
506
+ scope: 'account' | 'project';
507
+ project_id: string | null;
508
+ has_key: boolean;
509
+ type?: AiProviderKeyType;
510
+ last4?: string;
511
+ vertex?: {
512
+ project_id: string | null;
513
+ region: string | null;
514
+ client_email: string | null;
515
+ };
516
+ use_for?: AiCapabilityName[];
517
+ /** What this kind of key can serve. */
518
+ covers?: Record<AiCapabilityName, boolean>;
519
+ /** Per Vibiz model: served (and paid) by `your_key`, or by `vibiz` and billed normally. */
520
+ models?: Array<{
521
+ model: string;
522
+ capability: AiCapabilityName;
523
+ paid_by: 'your_key' | 'vibiz';
524
+ note?: string;
525
+ }>;
526
+ /** With no key: what each type would cover. */
527
+ types?: Array<{
528
+ type: AiProviderKeyType;
529
+ covers: Record<AiCapabilityName, boolean>;
530
+ default_use_for: AiCapabilityName[];
531
+ }>;
532
+ added_at?: string | null;
533
+ updated_at?: string | null;
534
+ last_used_at?: string | null;
535
+ last_checked_at?: string | null;
536
+ last_error?: {
537
+ code: string;
538
+ message: string | null;
539
+ at: string | null;
540
+ } | null;
541
+ billing?: string;
542
+ /** A project with no override of its own. */
543
+ inherits_account_key?: boolean;
544
+ account_key?: AiProviderKey;
545
+ /** `test()` only. */
546
+ test?: {
547
+ ok: boolean;
548
+ reason?: string;
549
+ status?: number;
550
+ google_status?: string;
551
+ google_reason?: string;
552
+ };
553
+ deleted?: boolean;
554
+ }
555
+ export type AiProviderKeyInput = {
556
+ type: 'gemini_api_key';
557
+ api_key: string;
558
+ use_for?: AiCapabilityName[];
559
+ } | {
560
+ type: 'vertex';
561
+ /** The service account key file: its JSON text or the parsed object. */
562
+ service_account: string | Record<string, unknown>;
563
+ /** Default: the key file's project. */
564
+ project_id?: string;
565
+ /** A Vertex location. Default `global`. */
566
+ region?: string;
567
+ use_for?: AiCapabilityName[];
568
+ };
569
+ export interface AiProviderKeyList {
570
+ object: 'list';
571
+ data: AiProviderKey[];
572
+ /** Calls your own keys served in the last 30 days, and what they would have cost on Vibiz. */
573
+ usage_30d: {
574
+ calls: number;
575
+ would_have_cost_usd: number;
576
+ };
577
+ }
578
+ export type UsagePeriod = '24h' | '7d' | '30d' | 'month';
579
+ export type UsageGroup = 'capability' | 'tool' | 'model' | 'alias' | 'project' | 'api_key' | 'end_user' | 'day' | 'outcome';
580
+ export interface UsageOptions {
581
+ period?: UsagePeriod;
582
+ /** One dimension, or up to three (`['project', 'tool']`). */
583
+ group_by?: UsageGroup | UsageGroup[];
584
+ project?: string;
585
+ model?: string;
586
+ tool?: string;
587
+ capability?: string;
588
+ /** An end user id, or `unattributed`. */
589
+ end_user?: string;
590
+ api_key?: string;
591
+ /** `failed`: partner runs that failed but still cost money. */
592
+ outcome?: 'succeeded' | 'failed';
593
+ limit?: number;
594
+ }
595
+ export interface UsageRow {
596
+ capability?: string | null;
597
+ tool?: string | null;
598
+ model?: string | null;
599
+ alias?: string | null;
600
+ project?: string | null;
601
+ project_name?: string;
602
+ api_key?: string | null;
603
+ api_key_name?: string;
604
+ end_user?: string | null;
605
+ day?: string | null;
606
+ /** Quantity per unit: `{ input_tokens: 1200, output_tokens: 300 }`. */
607
+ units: Record<string, number>;
608
+ cost_micro_usd: number;
609
+ billed_micro_usd: number;
610
+ cost_usd: number;
611
+ billed_usd: number;
612
+ records: number;
613
+ [dimension: string]: unknown;
614
+ }
615
+ export interface UsageLimits {
616
+ resets_at: string;
617
+ projects: {
618
+ used: number;
619
+ limit: number;
620
+ };
621
+ daily_spend: {
622
+ spent_usd: number;
623
+ held_usd: number;
624
+ limit_usd: number;
625
+ remaining_usd: number;
626
+ used_pct: number;
627
+ };
628
+ builds_today: Array<{
629
+ project_id: string;
630
+ project_name: string;
631
+ used: number;
632
+ limit: number;
633
+ }>;
634
+ ai_budgets: Array<{
635
+ project_id: string;
636
+ spent_today_usd: number;
637
+ daily_budget_usd: number | null;
638
+ end_user_daily_budget_usd: number | null;
639
+ }>;
640
+ email_today: Array<{
641
+ project_id: string;
642
+ used: number;
643
+ limit: number;
644
+ }>;
645
+ /** Prepaid accounts only (docs/BILLING.md): what is left to spend. */
646
+ credits?: {
647
+ balance_cents: number;
648
+ status: BillingStatus;
649
+ };
650
+ }
651
+ export interface UsageReport {
652
+ object: 'usage';
653
+ period: UsagePeriod;
654
+ from: string;
655
+ to: string;
656
+ group_by: UsageGroup[];
657
+ totals: {
658
+ cost_micro_usd: number;
659
+ billed_micro_usd: number;
660
+ cost_usd: number;
661
+ billed_usd: number;
662
+ margin_usd: number;
663
+ records: number;
664
+ units: Record<string, number>;
665
+ };
666
+ data: UsageRow[];
667
+ limits?: UsageLimits;
668
+ }
669
+ export interface LatencyRow {
670
+ requests: number;
671
+ errors_5xx: number;
672
+ errors_4xx: number;
673
+ error_rate: number;
674
+ p50_ms: number | null;
675
+ p95_ms: number | null;
676
+ p99_ms: number | null;
677
+ [dimension: string]: unknown;
678
+ }
679
+ export interface MetricsReport {
680
+ object: 'metrics';
681
+ period: UsagePeriod;
682
+ from: string;
683
+ to: string;
684
+ totals: LatencyRow;
685
+ data: Array<LatencyRow & {
686
+ capability: string;
687
+ }>;
688
+ }
689
+ /** `owner`: everything. `agent`: builds and runs, never reads production secrets. */
690
+ export type KeyAccess = 'owner' | 'agent';
691
+ export interface ApiKey {
692
+ object: 'api_key';
693
+ id: string;
694
+ name: string;
695
+ prefix: string;
696
+ kind?: 'key' | 'console';
697
+ access?: KeyAccess;
698
+ created_at: string;
699
+ revoked_at: string | null;
700
+ }
701
+ export interface AppKeyInfo {
702
+ object: 'app_key';
703
+ environment: 'production' | 'development';
704
+ prefix: string | null;
705
+ created_at: string | null;
706
+ rotated_at: string | null;
707
+ last_used_at: string | null;
708
+ previous_valid_until: string | null;
709
+ }
710
+ export interface HostKind {
711
+ kind: string;
712
+ label: string;
713
+ token_help: string;
714
+ fields: {
715
+ name: string;
716
+ label: string;
717
+ placeholder: string;
718
+ required: boolean;
719
+ help?: string;
720
+ }[];
721
+ environments: Array<'production' | 'development'>;
722
+ applies: string;
723
+ /** Run against the real host; the rest are beta. */
724
+ verified: boolean;
725
+ }
726
+ export interface EnvTargetInfo {
727
+ object: 'env_target';
728
+ id: string;
729
+ kind: string;
730
+ name: string;
731
+ config: Record<string, string>;
732
+ environments: Array<'production' | 'development'>;
733
+ status: 'pending' | 'synced' | 'failed';
734
+ error: string | null;
735
+ /** Variable names written there, per environment. Never values. */
736
+ pushed: Record<string, string[]>;
737
+ last_synced_at: string | null;
738
+ created_at: string;
739
+ }
740
+ export interface DevEnvironment {
741
+ object: 'dev_environment';
742
+ project_id: string;
743
+ status: 'none' | 'provisioning' | 'ready' | 'failed' | 'deleting';
744
+ resources: {
745
+ type: string;
746
+ status: string;
747
+ error: string | null;
748
+ }[];
749
+ }
750
+ /** Sign-in settings (docs/SIGN-IN.md). */
751
+ export type AuthEnvironment = 'production' | 'development';
752
+ export type AuthProviderId = 'google' | 'github' | 'vercel';
753
+ export interface AuthSettings {
754
+ object: 'auth_settings';
755
+ environment: AuthEnvironment;
756
+ /** The sign-in service's address for this environment. */
757
+ base_url: string;
758
+ app_name: string | null;
759
+ email_password: {
760
+ enabled: boolean;
761
+ require_email_verification: boolean;
762
+ email_verification_method: 'otp' | 'link';
763
+ disable_sign_up: boolean;
764
+ auto_sign_in_after_verification: boolean;
765
+ };
766
+ magic_link: {
767
+ enabled: boolean;
768
+ expires_in_minutes: number;
769
+ };
770
+ providers: Array<{
771
+ id: AuthProviderId;
772
+ credentials: 'shared' | 'own';
773
+ /** Own credentials: the client id (public). The secret is never returned. */
774
+ client_id: string | null;
775
+ has_client_secret: boolean;
776
+ /** Register this at the provider (per environment). */
777
+ callback_url: string;
778
+ }>;
779
+ /** Every provider, enabled or not, with what it needs. */
780
+ available_providers: Array<{
781
+ id: AuthProviderId;
782
+ label: string;
783
+ shared_available: boolean;
784
+ console_url: string;
785
+ callback_url: string;
786
+ steps: string[];
787
+ }>;
788
+ allow_localhost: boolean;
789
+ /** From "Where it runs" (hosting URL + project domains), or localhost for development. */
790
+ trusted_origins: string[];
791
+ /** Empty: anyone may sign up. */
792
+ allowed_email_domains: string[];
793
+ email_sender: {
794
+ type: 'shared' | 'smtp';
795
+ sender_email: string | null;
796
+ sender_name: string | null;
797
+ host: string | null;
798
+ port: number | null;
799
+ username: string | null;
800
+ has_password: boolean;
801
+ };
802
+ not_available: string[];
803
+ }
804
+ export interface AuthSettingsPatch {
805
+ app_name?: string;
806
+ email_password?: Partial<AuthSettings['email_password']>;
807
+ magic_link?: Partial<AuthSettings['magic_link']>;
808
+ allow_localhost?: boolean;
809
+ /** Host names (`bakery.com`), at most 50. Empty: anyone may sign up. */
810
+ allowed_email_domains?: string[];
811
+ email_sender?: {
812
+ type: 'shared';
813
+ sender_email?: string;
814
+ sender_name?: string;
815
+ } | {
816
+ type: 'smtp';
817
+ host: string;
818
+ port: number;
819
+ username: string;
820
+ /** Write-only. Omitted: keep the one already set. */
821
+ password?: string;
822
+ sender_email: string;
823
+ sender_name?: string;
824
+ };
825
+ }
826
+ export type AuthProviderInput = {
827
+ credentials: 'shared';
828
+ } | {
829
+ credentials: 'own';
830
+ client_id: string;
831
+ /** Write-only. Omitted: keep the one already set for the same client id. */
832
+ client_secret?: string;
833
+ };
834
+ /** Company formation (docs/COMPANY.md). */
835
+ export type CompanyEnvironment = 'production' | 'development';
836
+ export type CompanyEntityType = 'llc' | 'c_corp';
837
+ export type CompanyStatus = 'draft' | 'submitted' | 'filing' | 'formed' | 'completed' | 'failed' | 'cancelled';
838
+ export type CompanyRole = 'president' | 'secretary' | 'treasurer' | 'director';
839
+ export interface CompanyAddressFields {
840
+ line1: string;
841
+ line2?: string | null;
842
+ city: string;
843
+ /** State or province. */
844
+ state: string;
845
+ postal_code: string;
846
+ /** ISO 3166-1 alpha-3 (`USA`). */
847
+ country: string;
848
+ /** E.164. Required on a person's address. */
849
+ phone?: string | null;
850
+ }
851
+ export type CompanyAddress = {
852
+ use: 'registered_agent';
853
+ } | {
854
+ use: 'own';
855
+ address: CompanyAddressFields;
856
+ };
857
+ export interface CompanyPerson {
858
+ id: string;
859
+ first_name: string;
860
+ last_name: string;
861
+ email: string | null;
862
+ address: CompanyAddressFields;
863
+ ownership_percent: number | null;
864
+ roles: CompanyRole[];
865
+ responsible_party: boolean;
866
+ has_tax_id: boolean;
867
+ /** Owner keys only; null for agents. */
868
+ tax_id_last4: string | null;
869
+ }
870
+ export interface CompanyPrice {
871
+ state_fee_cents: number;
872
+ service_fee_cents: number;
873
+ total_cents: number;
874
+ }
875
+ export interface Company {
876
+ object: 'company';
877
+ id: string;
878
+ project_id: string;
879
+ environment: CompanyEnvironment;
880
+ status: CompanyStatus;
881
+ entity_type: CompanyEntityType;
882
+ state: string;
883
+ names: Array<{
884
+ name: string;
885
+ ending: string;
886
+ }>;
887
+ legal_name: string | null;
888
+ industry: string | null;
889
+ description: string | null;
890
+ business_address: CompanyAddress;
891
+ mailing_address: CompanyAddress;
892
+ people: CompanyPerson[];
893
+ shares: {
894
+ authorized: number;
895
+ par_value_usd: number;
896
+ } | null;
897
+ ein: {
898
+ expedite: boolean;
899
+ };
900
+ filing_number: string | null;
901
+ formed_on: string | null;
902
+ /** Masked for agents on production. */
903
+ ein_number: string | null;
904
+ services: Array<{
905
+ name: 'formation' | 'ein' | 'registered_agent';
906
+ status: 'not_started' | 'in_progress' | 'completed' | 'active' | 'canceled';
907
+ }>;
908
+ actions: Array<{
909
+ id: string;
910
+ code: 'names_rejected' | 'founder_address_required' | 'signature_reset' | 'signature_required';
911
+ reason: string;
912
+ open: boolean;
913
+ /** Answered and still open: the partner is acting on it, nothing to send again. */
914
+ waiting: boolean;
915
+ resolvable: boolean;
916
+ }>;
917
+ signatures: Array<{
918
+ document: 'ss4' | 'form_8821';
919
+ status: 'pending' | 'completed';
920
+ }>;
921
+ documents: Array<{
922
+ id: string;
923
+ type: 'articles' | 'ein_letter' | 'operating_agreement' | 'bylaws' | 'signed_ss4' | 'signed_form_8821' | 'mail' | 'other';
924
+ name: string;
925
+ created_at: string | null;
926
+ }>;
927
+ /** Fixed at submit. */
928
+ price: CompanyPrice | null;
929
+ /** Drafts only: what submitting would cost now (null when the fee is unknown). */
930
+ quote?: CompanyPrice | null;
931
+ /** Drafts only: what blocks submit. Empty = ready. */
932
+ problems: Array<{
933
+ path: string;
934
+ message: string;
935
+ }>;
936
+ submitted_at: string | null;
937
+ updated_at: string;
938
+ created_at: string;
939
+ }
940
+ export interface CompanyDraft {
941
+ entity_type: CompanyEntityType;
942
+ state: string;
943
+ /** Endings default to `LLC` / `Inc.`. */
944
+ names: Array<{
945
+ name: string;
946
+ ending?: string;
947
+ }>;
948
+ industry?: string | null;
949
+ description?: string | null;
950
+ business_address?: CompanyAddress | null;
951
+ mailing_address?: CompanyAddress | null;
952
+ people: Array<Omit<CompanyPerson, 'id' | 'has_tax_id' | 'tax_id_last4' | 'email' | 'ownership_percent' | 'roles' | 'responsible_party'> & {
953
+ email?: string | null;
954
+ ownership_percent?: number | null;
955
+ roles?: CompanyRole[];
956
+ responsible_party?: boolean;
957
+ /** SSN or ITIN. Owner keys only. Write-only. */
958
+ tax_id?: string | null;
959
+ /** Keep the stored tax id of the person with this id. */
960
+ id?: string;
961
+ }>;
962
+ shares?: {
963
+ authorized: number;
964
+ par_value_usd: number;
965
+ } | null;
966
+ ein?: {
967
+ expedite?: boolean;
968
+ } | null;
969
+ }
970
+ export interface CompanyCatalog {
971
+ object: 'company_catalog';
972
+ environment: CompanyEnvironment;
973
+ entity_types: Array<{
974
+ id: CompanyEntityType;
975
+ label: string;
976
+ endings: string[];
977
+ }>;
978
+ jurisdictions: Array<{
979
+ country: string;
980
+ state: string;
981
+ name: string;
982
+ fees: {
983
+ llc: number | null;
984
+ c_corp: number | null;
985
+ };
986
+ }>;
987
+ industries: string[];
988
+ service_fee_cents: number;
989
+ expedite_fee_cents: number;
990
+ coming_soon: Array<{
991
+ country: string;
992
+ entity: string;
993
+ why: string;
994
+ }>;
995
+ disclaimer: string;
996
+ }
997
+ export interface CompanyLink {
998
+ url: string;
999
+ expires_at: string;
1000
+ }
1001
+ export interface DashboardLink {
1002
+ object: 'dashboard_link';
1003
+ scope: 'tenant' | 'admin';
1004
+ url: string;
1005
+ expires_at: string;
1006
+ }
1007
+ /** The platform view (admin keys). Partner names appear only here. */
1008
+ export interface AdminMetrics {
1009
+ object: 'admin_metrics';
1010
+ period: UsagePeriod;
1011
+ from: string;
1012
+ to: string;
1013
+ tenants: {
1014
+ total: number;
1015
+ active: number;
1016
+ };
1017
+ /** The markup in effect (0 and no rules: pricing not set). */
1018
+ pricing: {
1019
+ default_markup_pct: number;
1020
+ rules: number;
1021
+ };
1022
+ revenue: {
1023
+ billed_usd: number;
1024
+ cost_usd: number;
1025
+ margin_usd: number;
1026
+ margin_pct: number | null;
1027
+ by_capability: UsageRow[];
1028
+ };
1029
+ spend: {
1030
+ by_provider: UsageRow[];
1031
+ by_tool: UsageRow[];
1032
+ by_model: UsageRow[];
1033
+ by_day: UsageRow[];
1034
+ };
1035
+ top_tenants: UsageRow[];
1036
+ requests: {
1037
+ totals: LatencyRow;
1038
+ rows: Array<LatencyRow & {
1039
+ route: string;
1040
+ method: string;
1041
+ }>;
1042
+ };
1043
+ providers: Array<{
1044
+ provider: string;
1045
+ calls: number;
1046
+ errors: number;
1047
+ error_rate: number;
1048
+ p50_ms: number | null;
1049
+ p95_ms: number | null;
1050
+ }>;
1051
+ breakers: Array<{
1052
+ name: string;
1053
+ state: string;
1054
+ }>;
1055
+ queue: {
1056
+ queued: number;
1057
+ running: number;
1058
+ oldest_queued_age_seconds: number;
1059
+ ai_jobs_queued: number;
1060
+ failed_24h: number;
1061
+ };
1062
+ worker_failures: {
1063
+ operations: Array<{
1064
+ kind: string;
1065
+ error_code: string | null;
1066
+ count: number;
1067
+ }>;
1068
+ ai_jobs: Record<string, number>;
1069
+ };
1070
+ north_star: {
1071
+ definition: string;
1072
+ value: number;
1073
+ history: Array<{
1074
+ day: string;
1075
+ value: number;
1076
+ }>;
1077
+ };
1078
+ }
1079
+ /** Payments (docs/PAYMENTS.md): Vibiz is the merchant; each project a balance. */
1080
+ export type PaymentsEnvironment = 'production' | 'development';
1081
+ export type WebhookEventType = 'payment.succeeded' | 'payment.refunded' | 'payment.failed' | 'subscription.created' | 'subscription.updated' | 'subscription.canceled' | 'invoice.paid' | 'invoice.payment_failed' | 'dispute.created' | 'dispute.closed' | 'withdrawal.paid' | 'withdrawal.failed';
1082
+ export interface PaymentsAccount {
1083
+ object: 'payments_account';
1084
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
1085
+ console_url?: string;
1086
+ project_id: string;
1087
+ environment: PaymentsEnvironment;
1088
+ status: 'active' | 'frozen';
1089
+ currency: 'usd';
1090
+ balance: {
1091
+ available_cents: number;
1092
+ pending_cents: number;
1093
+ negative_cents: number;
1094
+ in_transit_cents: number;
1095
+ withdrawn_cents: number;
1096
+ next_available_at: string | null;
1097
+ };
1098
+ payouts: {
1099
+ status: 'not_started' | 'needs_info' | 'verifying' | 'ready' | 'restricted';
1100
+ requirements: string[];
1101
+ bank: {
1102
+ last4: string;
1103
+ bank_name: string | null;
1104
+ } | null;
1105
+ due_by: string | null;
1106
+ };
1107
+ statement_descriptor: string;
1108
+ fees: {
1109
+ platform_bps: number;
1110
+ /** The card fee for most US cards: card_fee_bps / 100 % + card_fee_fixed_cents. */
1111
+ card_fee_bps: number;
1112
+ card_fee_fixed_cents: number;
1113
+ dispute_fee_cents: number;
1114
+ /** Days a payment is pending before it can be withdrawn (0 in development). */
1115
+ hold_days: number;
1116
+ /** What a $100 payment leaves the project, for a typical card. */
1117
+ example: {
1118
+ amount_cents: number;
1119
+ card_fee_cents: number;
1120
+ platform_fee_cents: number;
1121
+ net_cents: number;
1122
+ };
1123
+ note: string;
1124
+ };
1125
+ webhook: {
1126
+ url: string | null;
1127
+ has_secret: boolean;
1128
+ events: WebhookEventType[];
1129
+ };
1130
+ created_at: string;
1131
+ updated_at: string;
1132
+ }
1133
+ export interface PaymentPrice {
1134
+ object: 'price';
1135
+ id: string;
1136
+ product_id: string;
1137
+ active: boolean;
1138
+ unit_amount_cents: number;
1139
+ currency: 'usd';
1140
+ type: 'one_time' | 'recurring';
1141
+ interval: 'day' | 'week' | 'month' | 'year' | null;
1142
+ interval_count: number | null;
1143
+ lookup_key: string | null;
1144
+ }
1145
+ export interface PaymentPriceInput {
1146
+ unit_amount_cents: number;
1147
+ type: 'one_time' | 'recurring';
1148
+ interval?: 'day' | 'week' | 'month' | 'year';
1149
+ interval_count?: number;
1150
+ lookup_key?: string;
1151
+ }
1152
+ export interface PaymentProduct {
1153
+ object: 'product';
1154
+ id: string;
1155
+ name: string;
1156
+ description: string | null;
1157
+ active: boolean;
1158
+ prices: PaymentPrice[];
1159
+ created_at: string;
1160
+ }
1161
+ export interface CheckoutInput {
1162
+ price_id?: string;
1163
+ lookup_key?: string;
1164
+ amount_cents?: number;
1165
+ name?: string;
1166
+ quantity?: number;
1167
+ user?: string;
1168
+ customer_email?: string;
1169
+ success_url: string;
1170
+ cancel_url: string;
1171
+ metadata?: Record<string, string>;
1172
+ }
1173
+ export interface Checkout {
1174
+ object: 'checkout';
1175
+ id: string;
1176
+ url: string;
1177
+ expires_at: string;
1178
+ }
1179
+ export interface Payment {
1180
+ object: 'payment';
1181
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
1182
+ console_url?: string;
1183
+ id: string;
1184
+ status: 'succeeded' | 'refunded' | 'partially_refunded' | 'disputed' | 'failed';
1185
+ amount_cents: number;
1186
+ refunded_cents: number;
1187
+ fee_cents: number;
1188
+ net_cents: number;
1189
+ currency: 'usd';
1190
+ description: string | null;
1191
+ user: string | null;
1192
+ customer_email: string | null;
1193
+ price_id: string | null;
1194
+ subscription_id: string | null;
1195
+ metadata: Record<string, string>;
1196
+ card: {
1197
+ brand: string;
1198
+ last4: string;
1199
+ } | null;
1200
+ dispute: {
1201
+ status: 'needs_response' | 'under_review' | 'won' | 'lost';
1202
+ amount_cents: number;
1203
+ reason: string;
1204
+ } | null;
1205
+ available_at: string;
1206
+ created_at: string;
1207
+ }
1208
+ export interface PaymentSubscription {
1209
+ object: 'subscription';
1210
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
1211
+ console_url?: string;
1212
+ id: string;
1213
+ status: 'active' | 'trialing' | 'past_due' | 'canceled' | 'incomplete' | 'unpaid';
1214
+ user: string | null;
1215
+ customer_email: string | null;
1216
+ price_id: string | null;
1217
+ current_period_end: string | null;
1218
+ cancel_at_period_end: boolean;
1219
+ created_at: string;
1220
+ }
1221
+ export interface Withdrawal {
1222
+ object: 'withdrawal';
1223
+ id: string;
1224
+ amount_cents: number;
1225
+ status: 'pending' | 'in_transit' | 'paid' | 'failed';
1226
+ arrival_date: string | null;
1227
+ estimated_arrival: string | null;
1228
+ bank: {
1229
+ last4: string;
1230
+ bank_name: string | null;
1231
+ } | null;
1232
+ failure_message: string | null;
1233
+ created_at: string;
1234
+ }
1235
+ export interface LedgerEntry {
1236
+ object: 'ledger_entry';
1237
+ id: string;
1238
+ kind: 'charge' | 'processing_fee' | 'platform_fee' | 'refund' | 'dispute' | 'dispute_fee' | 'dispute_reversal' | 'withdrawal' | 'withdrawal_reversal' | 'adjustment';
1239
+ amount_cents: number;
1240
+ available_at: string | null;
1241
+ payment_id: string | null;
1242
+ withdrawal_id: string | null;
1243
+ note: string | null;
1244
+ created_at: string;
1245
+ }
1246
+ export interface WebhookDelivery {
1247
+ object: 'webhook_delivery';
1248
+ id: string;
1249
+ event_id: string;
1250
+ type: WebhookEventType;
1251
+ url: string;
1252
+ status: 'pending' | 'succeeded' | 'failed';
1253
+ attempts: number;
1254
+ last_status_code: number | null;
1255
+ next_attempt_at: string | null;
1256
+ created_at: string;
1257
+ }
1258
+ /** Every payments list. */
1259
+ export interface PaymentsList<T> {
1260
+ object: 'list';
1261
+ /** The same list in the web console, with the same filters (docs: console-urls). */
1262
+ console_url?: string;
1263
+ data: T[];
1264
+ has_more: boolean;
1265
+ next_cursor: string | null;
1266
+ }
1267
+ export type PaymentsSimulation = {
1268
+ event: 'payment';
1269
+ amount_cents?: number;
1270
+ price_id?: string;
1271
+ user?: string;
1272
+ } | {
1273
+ event: 'dispute';
1274
+ amount_cents?: number;
1275
+ } | {
1276
+ event: 'refund';
1277
+ payment_id: string;
1278
+ } | {
1279
+ event: 'release_hold';
1280
+ };
1281
+ export type ConnectorEnvironment = 'production' | 'development';
1282
+ export type ConnectorRisk = 'read' | 'write' | 'dangerous';
1283
+ export type ConnectorMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1284
+ export type JsonSchema = Record<string, unknown>;
1285
+ export type ConnectorAuth = {
1286
+ type: 'none';
1287
+ } | {
1288
+ type: 'header';
1289
+ header: string;
1290
+ env: string;
1291
+ prefix?: string;
1292
+ } | {
1293
+ type: 'query';
1294
+ param: string;
1295
+ env: string;
1296
+ } | {
1297
+ type: 'bearer';
1298
+ env: string;
1299
+ } | {
1300
+ type: 'basic';
1301
+ username_env: string;
1302
+ password_env?: string;
1303
+ };
1304
+ export interface ConnectorOperation {
1305
+ id: string;
1306
+ method: ConnectorMethod;
1307
+ /** Relative to base_url, with `{name}` placeholders. */
1308
+ path: string;
1309
+ description: string;
1310
+ risk: ConnectorRisk;
1311
+ enabled: boolean;
1312
+ /** JSON Schema of the parameters; each property has `in: 'path' | 'query' | 'header'`. */
1313
+ params: JsonSchema;
1314
+ body: JsonSchema | null;
1315
+ }
1316
+ export interface ConnectorManifest {
1317
+ name: string;
1318
+ label: string;
1319
+ description: string | null;
1320
+ docs_url: string | null;
1321
+ base_url: string;
1322
+ development_base_url: string | null;
1323
+ auth: ConnectorAuth;
1324
+ env: Array<{
1325
+ name: string;
1326
+ secret: boolean;
1327
+ required: boolean;
1328
+ description: string | null;
1329
+ }>;
1330
+ check: {
1331
+ method: 'GET' | 'HEAD';
1332
+ path: string;
1333
+ query?: Record<string, string>;
1334
+ expect_status?: number[];
1335
+ } | null;
1336
+ operations: ConnectorOperation[];
1337
+ /** Who bills for calls. Vibiz never invents a price. */
1338
+ pricing: {
1339
+ billed_by: string;
1340
+ url: string | null;
1341
+ };
1342
+ timeout_ms: number;
1343
+ }
1344
+ /** What `create` takes: the manifest, with defaults; operations may be `"GET /path/{id}?q"`. */
1345
+ export type ConnectorInput = Partial<Omit<ConnectorManifest, 'operations' | 'env'>> & {
1346
+ name: string;
1347
+ base_url: string;
1348
+ env?: Array<{
1349
+ name: string;
1350
+ secret?: boolean;
1351
+ required?: boolean;
1352
+ description?: string | null;
1353
+ }>;
1354
+ operations?: Array<string | (Partial<ConnectorOperation> & {
1355
+ method: string;
1356
+ path: string;
1357
+ })>;
1358
+ };
1359
+ export interface ConnectorSecretState {
1360
+ set: boolean;
1361
+ updated_at: string | null;
1362
+ /** Only for a variable marked `secret: false`. */
1363
+ value?: string;
1364
+ }
1365
+ export interface Connector extends ConnectorManifest {
1366
+ object: 'connector';
1367
+ /** This object's page in the web console, absolute: give it to the person (docs: console-urls). */
1368
+ console_url?: string;
1369
+ id: string;
1370
+ project_id: string;
1371
+ app_dangerous: boolean;
1372
+ /** Never a secret value. */
1373
+ secrets: Array<{
1374
+ name: string;
1375
+ secret: boolean;
1376
+ required: boolean;
1377
+ production: ConnectorSecretState;
1378
+ development: ConnectorSecretState;
1379
+ }>;
1380
+ ready: {
1381
+ production: boolean;
1382
+ development: boolean;
1383
+ };
1384
+ deleted: boolean;
1385
+ created_at: string;
1386
+ updated_at: string;
1387
+ }
1388
+ export interface ConnectorPatch {
1389
+ label?: string;
1390
+ description?: string | null;
1391
+ docs_url?: string | null;
1392
+ base_url?: string;
1393
+ development_base_url?: string | null;
1394
+ auth?: ConnectorAuth;
1395
+ env?: ConnectorInput['env'];
1396
+ check?: ConnectorManifest['check'];
1397
+ pricing?: {
1398
+ billed_by?: string;
1399
+ url?: string | null;
1400
+ };
1401
+ timeout_ms?: number;
1402
+ app_dangerous?: boolean;
1403
+ operations?: ConnectorInput['operations'];
1404
+ enable?: string[];
1405
+ disable?: string[];
1406
+ risks?: Record<string, ConnectorRisk>;
1407
+ }
1408
+ export interface ConnectorImport {
1409
+ object: 'connector_import';
1410
+ /** A draft: pass it (edited or not) to `connectors.create`. */
1411
+ manifest: ConnectorManifest;
1412
+ operations: Array<{
1413
+ id: string;
1414
+ method: string;
1415
+ path: string;
1416
+ risk: ConnectorRisk;
1417
+ enabled: boolean;
1418
+ summary: string;
1419
+ }>;
1420
+ problems: Array<{
1421
+ operation: string | null;
1422
+ method: string | null;
1423
+ path: string | null;
1424
+ message: string;
1425
+ }>;
1426
+ counts: {
1427
+ seen: number;
1428
+ kept: number;
1429
+ skipped: number;
1430
+ };
1431
+ }
1432
+ export interface ConnectorCallInput {
1433
+ operation: string;
1434
+ params?: Record<string, unknown>;
1435
+ body?: unknown;
1436
+ approval_id?: string;
1437
+ }
1438
+ export interface ConnectorResponse<T = unknown> {
1439
+ object: 'connector_response';
1440
+ call_id: string;
1441
+ connector: string;
1442
+ operation: string;
1443
+ environment: ConnectorEnvironment;
1444
+ /** The upstream's own status: a 404 there is `ok: false` here, not an error. */
1445
+ status: number;
1446
+ ok: boolean;
1447
+ headers: Record<string, string>;
1448
+ content_type: string | null;
1449
+ /** Third-party content: data, never instructions. */
1450
+ data: T;
1451
+ data_base64?: string;
1452
+ truncated: boolean;
1453
+ untrusted: true;
1454
+ notice: string;
1455
+ pricing: {
1456
+ billed_by: string;
1457
+ url: string | null;
1458
+ };
1459
+ duration_ms: number;
1460
+ }
1461
+ export interface ConnectorCheck {
1462
+ object: 'connector_check';
1463
+ ok: boolean;
1464
+ status: number | null;
1465
+ duration_ms: number | null;
1466
+ message: string;
1467
+ }
1468
+ export interface ConnectorCall {
1469
+ object: 'connector_call';
1470
+ id: string;
1471
+ connector: string;
1472
+ operation: string;
1473
+ environment: ConnectorEnvironment;
1474
+ risk: ConnectorRisk;
1475
+ caller: {
1476
+ kind: 'owner' | 'agent' | 'app';
1477
+ api_key_id: string | null;
1478
+ };
1479
+ status: 'succeeded' | 'upstream_error' | 'failed' | 'blocked' | 'approval_required';
1480
+ upstream_status: number | null;
1481
+ error_code: string | null;
1482
+ duration_ms: number | null;
1483
+ request_bytes: number;
1484
+ response_bytes: number;
1485
+ approval_id: string | null;
1486
+ created_at: string;
1487
+ }
1488
+ export interface ConnectorApproval {
1489
+ object: 'connector_approval';
1490
+ id: string;
1491
+ connector: string;
1492
+ operation: string;
1493
+ environment: ConnectorEnvironment;
1494
+ /** The operation's template; null when it was removed from the connector since. */
1495
+ method: string | null;
1496
+ path: string | null;
1497
+ risk: 'write' | 'dangerous';
1498
+ reason: 'dangerous' | 'production_write';
1499
+ request: {
1500
+ params: Record<string, unknown>;
1501
+ body: unknown;
1502
+ };
1503
+ status: 'pending' | 'approved' | 'denied' | 'expired' | 'used';
1504
+ requested_by: string | null;
1505
+ decided_by: string | null;
1506
+ decided_at: string | null;
1507
+ expires_at: string;
1508
+ used_at: string | null;
1509
+ call_id: string | null;
1510
+ created_at: string;
1511
+ }
1512
+ export type SocialEnvironment = 'production' | 'development';
1513
+ export type SocialPlatform = 'instagram' | 'facebook' | 'tiktok' | 'linkedin' | 'x' | 'youtube' | 'pinterest' | 'threads' | 'bluesky' | 'reddit' | 'google_business' | 'telegram';
1514
+ export type SocialAdPlatform = 'meta' | 'google' | 'tiktok' | 'linkedin' | 'pinterest' | 'x';
1515
+ export type SocialPostStatus = 'draft' | 'pending_approval' | 'scheduled' | 'publishing' | 'published' | 'partial' | 'failed' | 'cancelled';
1516
+ export interface SocialMetrics {
1517
+ impressions: number | null;
1518
+ reach: number | null;
1519
+ likes: number | null;
1520
+ comments: number | null;
1521
+ shares: number | null;
1522
+ saves: number | null;
1523
+ clicks: number | null;
1524
+ views: number | null;
1525
+ engagement_rate: number | null;
1526
+ }
1527
+ export interface SocialOverview {
1528
+ object: 'social';
1529
+ project_id: string;
1530
+ environment: SocialEnvironment;
1531
+ available: boolean;
1532
+ sandbox: boolean;
1533
+ platforms: Array<{
1534
+ id: SocialPlatform;
1535
+ label: string;
1536
+ text_limit: number;
1537
+ needs_media: boolean;
1538
+ }>;
1539
+ ad_platforms: Array<{
1540
+ id: SocialAdPlatform;
1541
+ label: string;
1542
+ }>;
1543
+ accounts: {
1544
+ connected: number;
1545
+ needs_reconnect: number;
1546
+ ads: number;
1547
+ };
1548
+ posts: {
1549
+ scheduled: number;
1550
+ pending_approval: number;
1551
+ failed_7d: number;
1552
+ published_30d: number;
1553
+ };
1554
+ ad_changes_pending: number;
1555
+ console_url?: string;
1556
+ }
1557
+ export interface SocialAccount {
1558
+ object: 'social_account';
1559
+ id: string;
1560
+ project_id: string;
1561
+ environment: SocialEnvironment;
1562
+ platform: SocialPlatform | SocialAdPlatform;
1563
+ kind: 'social' | 'ads';
1564
+ status: 'connected' | 'needs_reconnect' | 'disconnected';
1565
+ username: string | null;
1566
+ display_name: string | null;
1567
+ avatar_url: string | null;
1568
+ profile_url: string | null;
1569
+ details: {
1570
+ followers?: number;
1571
+ ad_accounts?: Array<{
1572
+ id: string;
1573
+ name: string;
1574
+ currency: string | null;
1575
+ usable: boolean;
1576
+ }>;
1577
+ sandbox?: boolean;
1578
+ };
1579
+ connected_at: string;
1580
+ console_url?: string;
1581
+ }
1582
+ export interface SocialConnectLink {
1583
+ object: 'social_connect_link';
1584
+ platform: string;
1585
+ ads: boolean;
1586
+ environment: SocialEnvironment;
1587
+ url: string;
1588
+ expires_at: string;
1589
+ }
1590
+ export interface SocialMedia {
1591
+ object: 'social_media';
1592
+ url: string;
1593
+ type: 'image' | 'video' | 'gif' | 'document';
1594
+ content_type: string;
1595
+ size: number;
1596
+ environment: SocialEnvironment;
1597
+ }
1598
+ export interface SocialPostInput {
1599
+ text: string;
1600
+ media?: Array<{
1601
+ url: string;
1602
+ type?: 'image' | 'video' | 'gif' | 'document';
1603
+ }>;
1604
+ targets: Array<{
1605
+ account_id: string;
1606
+ options?: Record<string, unknown>;
1607
+ }>;
1608
+ /** ISO time; leave out to publish now. */
1609
+ schedule_at?: string | null;
1610
+ timezone?: string | null;
1611
+ draft?: boolean;
1612
+ /** Production, owners: the post was reviewed. */
1613
+ confirm?: boolean;
1614
+ }
1615
+ export interface SocialPost {
1616
+ object: 'social_post';
1617
+ id: string;
1618
+ project_id: string;
1619
+ environment: SocialEnvironment;
1620
+ status: SocialPostStatus;
1621
+ text: string;
1622
+ media: Array<{
1623
+ type: 'image' | 'video' | 'gif' | 'document';
1624
+ url: string;
1625
+ }>;
1626
+ targets: Array<{
1627
+ account_id: string;
1628
+ platform: SocialPlatform;
1629
+ username: string | null;
1630
+ status: 'pending' | 'publishing' | 'published' | 'failed' | 'cancelled';
1631
+ url: string | null;
1632
+ error: string | null;
1633
+ published_at: string | null;
1634
+ options: Record<string, unknown>;
1635
+ }>;
1636
+ scheduled_for: string | null;
1637
+ timezone: string | null;
1638
+ published_at: string | null;
1639
+ approval: null | {
1640
+ status: 'pending' | 'approved' | 'rejected';
1641
+ requested_by: string | null;
1642
+ decided_by: string | null;
1643
+ decided_at: string | null;
1644
+ next_step: string | null;
1645
+ };
1646
+ created_at: string;
1647
+ updated_at: string;
1648
+ console_url?: string;
1649
+ }
1650
+ export interface SocialPostAnalytics {
1651
+ object: 'social_post_analytics';
1652
+ post_id: string;
1653
+ targets: Array<{
1654
+ account_id: string;
1655
+ platform: string;
1656
+ metrics: SocialMetrics;
1657
+ }>;
1658
+ totals: SocialMetrics;
1659
+ updated_at: string | null;
1660
+ }
1661
+ export interface SocialAccountAnalytics {
1662
+ object: 'social_account_analytics';
1663
+ account_id: string;
1664
+ platform: string;
1665
+ from: string;
1666
+ to: string;
1667
+ followers: number | null;
1668
+ totals: SocialMetrics;
1669
+ daily: Array<{
1670
+ day: string;
1671
+ metrics: SocialMetrics;
1672
+ }>;
1673
+ }
1674
+ export interface SocialAdCampaign {
1675
+ object: 'ad_campaign';
1676
+ id: string;
1677
+ account_id: string;
1678
+ ad_account_id: string;
1679
+ platform: SocialAdPlatform;
1680
+ name: string;
1681
+ status: 'active' | 'paused' | 'pending_review' | 'rejected' | 'completed' | 'cancelled' | 'error';
1682
+ daily_budget_cents: number | null;
1683
+ lifetime_budget_cents: number | null;
1684
+ currency: string | null;
1685
+ spend_cents: number | null;
1686
+ impressions: number | null;
1687
+ clicks: number | null;
1688
+ conversions: number | null;
1689
+ }
1690
+ export interface SocialAdChangeInput {
1691
+ account_id: string;
1692
+ ad_account_id: string;
1693
+ kind: 'boost' | 'pause' | 'resume' | 'budget';
1694
+ campaign_id?: string;
1695
+ daily_budget_cents?: number;
1696
+ post_id?: string;
1697
+ days?: number;
1698
+ goal?: 'engagement' | 'traffic' | 'awareness';
1699
+ url?: string | null;
1700
+ countries?: string[];
1701
+ age_min?: number;
1702
+ age_max?: number;
1703
+ name?: string;
1704
+ confirm?: boolean;
1705
+ }
1706
+ export interface SocialAdChange {
1707
+ object: 'social_ad_change';
1708
+ id: string;
1709
+ project_id: string;
1710
+ environment: SocialEnvironment;
1711
+ account_id: string;
1712
+ ad_account_id: string;
1713
+ kind: 'boost' | 'pause' | 'resume' | 'budget';
1714
+ request: Record<string, unknown>;
1715
+ status: 'pending_approval' | 'applying' | 'applied' | 'rejected' | 'failed';
1716
+ result: {
1717
+ campaign_id: string | null;
1718
+ } | null;
1719
+ error: string | null;
1720
+ requested_by: string | null;
1721
+ decided_by: string | null;
1722
+ decided_at: string | null;
1723
+ next_step: string | null;
1724
+ created_at: string;
1725
+ console_url?: string;
1726
+ }
1727
+ export type BillingStatus = 'active' | 'low' | 'payment_required' | 'past_due' | 'exempt';
1728
+ export interface Billing {
1729
+ object: 'billing';
1730
+ /** `credits`: prepaid. `exempt`: Vibiz covers the account's usage. */
1731
+ mode: 'credits' | 'exempt';
1732
+ currency: 'usd';
1733
+ /** Can be negative. Today's usage is already in it. */
1734
+ balance_cents: number;
1735
+ open_usage_cents: number;
1736
+ status: BillingStatus;
1737
+ negative_since: string | null;
1738
+ /** When deploys and new resources pause, while the balance is at or below zero. */
1739
+ pauses_at: string | null;
1740
+ trial: {
1741
+ amount_cents: number;
1742
+ granted_at: string;
1743
+ } | null;
1744
+ card: {
1745
+ brand: string;
1746
+ last4: string;
1747
+ exp_month: number | null;
1748
+ exp_year: number | null;
1749
+ } | null;
1750
+ auto_recharge: {
1751
+ enabled: boolean;
1752
+ threshold_cents: number;
1753
+ amount_cents: number;
1754
+ failures: number;
1755
+ disabled_reason: string | null;
1756
+ last_attempt_at: string | null;
1757
+ };
1758
+ daily_spend_limit_usd: number;
1759
+ limits: {
1760
+ top_up_amounts_cents: number[];
1761
+ min_top_up_cents: number;
1762
+ max_top_up_cents: number;
1763
+ grace_cents: number;
1764
+ grace_days: number;
1765
+ low_balance_cents: number;
1766
+ min_auto_recharge_threshold_cents: number;
1767
+ min_auto_recharge_amount_cents: number;
1768
+ max_auto_recharge_amount_cents: number;
1769
+ max_daily_spend_limit_usd: number;
1770
+ };
1771
+ /** What to tell the person when the status is not active. */
1772
+ next_step: string | null;
1773
+ console_url: string;
1774
+ }
1775
+ export interface BillingUpdate {
1776
+ auto_recharge?: {
1777
+ enabled?: boolean;
1778
+ threshold_cents?: number;
1779
+ amount_cents?: number;
1780
+ };
1781
+ daily_spend_limit_usd?: number;
1782
+ }
1783
+ export type BillingChargeStatus = 'open' | 'pending' | 'succeeded' | 'failed' | 'expired' | 'refunded' | 'partially_refunded';
1784
+ export interface BillingCheckout {
1785
+ object: 'billing_checkout';
1786
+ id: string;
1787
+ kind: 'topup' | 'card' | 'company';
1788
+ status: BillingChargeStatus;
1789
+ amount_cents: number;
1790
+ /** The hosted payment page a person opens; null once it is no longer open. */
1791
+ url: string | null;
1792
+ expires_at: string | null;
1793
+ company_id: string | null;
1794
+ failure_message: string | null;
1795
+ console_url: string;
1796
+ }
1797
+ export interface BillingCharge {
1798
+ object: 'billing_charge';
1799
+ id: string;
1800
+ kind: 'topup' | 'auto_recharge' | 'company' | 'card';
1801
+ status: BillingChargeStatus;
1802
+ amount_cents: number;
1803
+ refunded_cents: number;
1804
+ card: {
1805
+ brand: string;
1806
+ last4: string;
1807
+ } | null;
1808
+ receipt_url: string | null;
1809
+ failure_message: string | null;
1810
+ company_id: string | null;
1811
+ created_at: string;
1812
+ console_url: string;
1813
+ }
1814
+ export type BillingEntryKind = 'trial' | 'topup' | 'company_payment' | 'usage' | 'refund' | 'dispute' | 'dispute_reversal' | 'adjustment';
1815
+ export interface BillingEntry {
1816
+ object: 'billing_entry';
1817
+ id: string;
1818
+ kind: BillingEntryKind;
1819
+ amount_cents: number;
1820
+ amount_micro_usd: number;
1821
+ /** Usage rows: the UTC day closed. */
1822
+ day: string | null;
1823
+ charge_id: string | null;
1824
+ note: string | null;
1825
+ created_at: string;
1826
+ console_url: string;
1827
+ }
1828
+ export interface BillingList<T> {
1829
+ object: 'list';
1830
+ data: T[];
1831
+ has_more: boolean;
1832
+ next_cursor: string | null;
1833
+ console_url: string;
1834
+ }