@ai2aim.ai/hivemind-sdk 1.0.15 → 2.0.1

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/dist/types.d.ts CHANGED
@@ -1,253 +1,104 @@
1
- /**
2
- * Every JSON response from the backend is wrapped in this envelope by
3
- * the `ResponseEnvelopeMiddleware`. The SDK's REST client unwraps it
4
- * automatically — use {@link ApiEnvelope} when you need access to
5
- * `message` or `statusCode` directly.
6
- */
7
1
  export interface ApiEnvelope<T = unknown> {
8
2
  success: boolean;
9
3
  statusCode: number;
10
4
  data: T;
11
5
  message: string;
12
6
  }
13
- /** Shape of the envelope when the request failed (4xx / 5xx). */
14
7
  export interface ApiErrorBody {
15
8
  success: false;
16
9
  statusCode: number;
17
10
  data: Record<string, unknown> | null;
18
11
  message: string;
19
12
  }
20
- /**
21
- * Optional per-request overrides. Use this to pass an API key from your
22
- * own database/cache instead of storing it in client config.
23
- */
24
13
  export interface RequestOptions {
25
- /** Organization API key for this request (e.g. from your DB/cache). */
26
14
  apiKey?: string;
27
15
  }
28
- /**
29
- * Resolved config (baseUrl always set). Used internally.
30
- */
31
16
  export interface HivemindClientConfig {
32
17
  baseUrl: string;
33
18
  apiPrefix?: string;
34
19
  apiKey?: string;
35
20
  adminKey?: string;
36
21
  webhookSecret?: string;
37
- employeeId?: string;
38
22
  timeoutMs?: number;
39
23
  insecure?: boolean;
40
24
  }
41
- /**
42
- * Config when creating a client. baseUrl is optional:
43
- * if omitted, it is read from env (HIVEMIND_BASE_URL or HIVEMIND_API_URL).
44
- * Set it once in the environment and only pass overrides (e.g. adminKey, apiKey)
45
- * when creating the client.
46
- */
47
- export interface HivemindClientConfigInput {
48
- /** Base URL; defaults to HIVEMIND_BASE_URL or HIVEMIND_API_URL */
25
+ export interface HivemindClientConfigInput extends Partial<HivemindClientConfig> {
49
26
  baseUrl?: string;
50
- /** API prefix, defaults to "/v1" */
51
- apiPrefix?: string;
52
- /** Organization API key (vtx_…); or pass per-request via RequestOptions */
53
- apiKey?: string;
54
- /** Admin bootstrap key for admin-only endpoints */
55
- adminKey?: string;
56
- /** Webhook secret for webhook endpoints */
57
- webhookSecret?: string;
58
- /** Employee ID header */
59
- employeeId?: string;
60
- /** Request timeout in ms (default 30 000) */
61
- timeoutMs?: number;
62
- /** Skip TLS verification (self-signed certs) */
63
- insecure?: boolean;
64
27
  }
65
- /** Organization tier determining quotas, rate limits, and available features. */
66
- export type OrgTier = "free" | "standard" | "premium" | "enterprise";
67
- /** Organization lifecycle status. */
68
- export type OrgStatus = "active" | "suspended";
69
- /**
70
- * Parameters for creating a new organization.
71
- *
72
- * **Auth:** Requires `adminKey` in client config.
73
- * **Endpoint:** `POST /v1/organizations`
74
- */
75
- export interface OrgCreateParams {
76
- /** Unique organization identifier (2–64 characters, alphanumeric + hyphens). */
77
- org_id: string;
78
- /** Human-readable display name (2–128 characters). */
79
- name: string;
80
- /** Organization tier. Determines quotas and rate limits. @default "standard" */
81
- tier?: OrgTier;
82
- /** Custom key-value settings for the organization. @default {} */
28
+ export type ApiKeyScopeStatus = "active" | "suspended";
29
+ export interface ApiKeyIssueParams {
30
+ name?: string;
83
31
  settings?: Record<string, unknown>;
84
32
  }
85
- /** Options for organization creation helpers. */
86
- export interface CreateOrganizationOptions {
87
- /**
88
- * Controls duplicate-organization handling.
89
- * Defaults to `true`, which makes org creation idempotent.
90
- */
91
- allowExisting?: boolean;
92
- }
93
- /** Full organization entity as returned by the API. */
94
- export interface Organization {
95
- /** Unique organization identifier. */
96
- org_id: string;
97
- /** Display name. */
33
+ export interface ApiKeyScope {
98
34
  name: string;
99
- /** Current tier (free, standard, premium, enterprise). */
100
- tier: OrgTier;
101
- /** Lifecycle status (active or suspended). */
102
- status: OrgStatus;
103
- /** ISO 8601 creation timestamp. */
35
+ status: ApiKeyScopeStatus;
104
36
  created_at: string;
105
- /** ISO 8601 last-update timestamp. */
106
37
  updated_at: string;
107
- /** Custom organization settings. */
108
38
  settings: Record<string, unknown>;
109
39
  }
110
- /**
111
- * Response from creating an organization.
112
- * Contains the full organization entity and the generated API key.
113
- */
114
- export interface OrgBootstrapResponse {
115
- /** The created organization. */
116
- organization: Organization;
117
- /** Generated API key (prefix `vxk_`). Store securely — shown only once. */
40
+ export interface ApiKeyBootstrapResponse {
41
+ scope: ApiKeyScope;
118
42
  api_key: string;
119
43
  }
120
- /** Successful response when an organization was newly created. */
121
- export interface OrgCreatedResponse extends OrgBootstrapResponse {
122
- /** Indicates the organization was created by this call. */
123
- created: true;
124
- }
125
- /** Successful response when the organization already existed. */
126
- export interface OrgExistingResponse {
127
- /** Indicates the organization already existed before this call. */
128
- created: false;
129
- /** Current organization details fetched via the admin API. */
130
- organization: Organization;
131
- /** Existing orgs do not expose the original API key again. */
132
- api_key: null;
133
- }
134
- /** Result from an idempotent organization provisioning flow. */
135
- export type OrgEnsureResponse = OrgCreatedResponse | OrgExistingResponse;
136
- /**
137
- * Response from rotating an organization's API key.
138
- * The previous key remains valid during a 24-hour grace period.
139
- */
140
- export interface RotateApiKeyResponse {
141
- /** Organization identifier. */
142
- org_id: string;
143
- /** Newly generated API key. */
44
+ export interface ApiKeyRotateResponse {
144
45
  new_api_key: string;
145
- /** ISO 8601 timestamp when the previous key expires. */
146
46
  previous_key_grace_expires_at: string;
147
47
  }
148
- /** Response from suspending or reactivating an organization. */
149
- export interface ChangeOrgStatusResponse {
150
- /** Organization identifier. */
151
- org_id: string;
152
- /** New status after the operation. */
153
- status: OrgStatus;
154
- /** ISO 8601 timestamp of the status change. */
155
- updated_at: string;
156
- }
157
- /**
158
- * Parameters for exchanging the bootstrap admin key for a signed session token.
159
- *
160
- * **Auth:** None (this is the login endpoint).
161
- * **Endpoint:** `POST /v1/admin/login`
162
- */
163
48
  export interface AdminLoginParams {
164
- /** The bootstrap admin key (min 1 character). */
165
49
  admin_key: string;
166
50
  }
167
- /** Response containing a signed admin session token. */
168
51
  export interface AdminLoginResponse {
169
- /** Signed JWT session token. Use as `Authorization: Bearer <token>`. */
170
52
  access_token: string;
171
- /** Token type — always `"bearer"`. */
172
53
  token_type: string;
173
- /** Token validity in seconds (default 28800 = 8 hours). */
174
54
  expires_in_seconds: number;
175
55
  }
176
- /**
177
- * Response from uploading and ingesting a document.
178
- * The document is stored in GCS, split into chunks, and embedded for RAG retrieval.
179
- */
56
+ export interface RootResponse {
57
+ service: string;
58
+ status: string;
59
+ health: string;
60
+ docs: string;
61
+ }
62
+ export interface HealthResponse {
63
+ service: string;
64
+ version: string;
65
+ status: string;
66
+ stats: Record<string, unknown>;
67
+ }
180
68
  export interface DocumentUploadResponse {
181
- /** Unique document identifier. */
182
69
  document_id: string;
183
- /** Organization the document belongs to. */
184
- org_id: string;
185
- /** Original filename. */
186
70
  filename: string;
187
- /** Number of text chunks created from the document. */
188
71
  chunks: number;
189
- /** Processing status (e.g. `"processed"`). */
190
72
  status: string;
191
73
  }
192
- /**
193
- * Parameters for a RAG (Retrieval-Augmented Generation) query.
194
- *
195
- * **Auth:** Requires org-scoped API key.
196
- * **Endpoint:** `POST /v1/organizations/{orgId}/query`
197
- */
198
74
  export interface QueryParams {
199
- /** The query text (min 1 character). */
200
75
  query: string;
201
- /** Optional user identifier for tracking and audit. */
202
76
  user_id?: string;
203
- /** Optional content-project context for project-scoped memory. */
204
77
  project_id?: string;
205
- /** Gemini model to use for generation. @default "gemini-pro" */
206
78
  model_type?: string;
207
- /** Sampling temperature (0.0–1.0). Lower = more deterministic. @default 0.2 */
208
79
  temperature?: number;
209
- /** Retrieval strategy: `"hybrid"`, `"dense"`, or `"sparse"`. @default "hybrid" */
210
80
  retrieval_strategy?: string;
211
81
  }
212
- /** A single citation returned inside a RAG query response. */
213
82
  export interface Citation {
214
83
  doc_id: string;
215
84
  chunk_id: string;
216
85
  score: number;
217
86
  snippet: string;
218
87
  }
219
- /** Response from a RAG query, including the generated answer and source citations. */
220
88
  export interface QueryResponse {
221
- /** Generated answer text. */
222
89
  answer: string;
223
- /** Source document chunks used to generate the answer, with scores and snippets. */
224
90
  sources: Citation[];
225
- /** Backward-compatible answer field used by older API consumers. */
226
91
  response: string;
227
- /** Backward-compatible citations field used by older API consumers. */
228
92
  citations: Citation[];
229
- /** Confidence score returned by the answering pipeline. */
230
93
  confidence: number;
231
- /** Approximate processing time in seconds. */
232
94
  processing_time: number;
233
- /** Model used for generation. */
234
95
  model_type?: string | null;
235
96
  }
236
- /**
237
- * Parameters for source discovery search.
238
- *
239
- * **Auth:** Requires org-scoped API key.
240
- * **Endpoint:** `POST /v1/organizations/{orgId}/search`
241
- */
242
97
  export interface SearchParams {
243
- /** Search query text (min 1 character). */
244
98
  query: string;
245
- /** Optional search type hint. */
246
99
  type?: string;
247
- /** Maximum number of results to return (1-25). @default 10 */
248
100
  num?: number;
249
101
  }
250
- /** A single organic search result. */
251
102
  export interface SearchOrganicResult {
252
103
  url: string;
253
104
  title: string;
@@ -255,14 +106,12 @@ export interface SearchOrganicResult {
255
106
  date?: string | null;
256
107
  order?: number | null;
257
108
  }
258
- /** A single "people also ask" result. */
259
109
  export interface SearchPeopleAlsoAskResult {
260
110
  question: string;
261
111
  snippet: string;
262
112
  title: string;
263
113
  link: string;
264
114
  }
265
- /** Source discovery search response. */
266
115
  export interface SearchResponse {
267
116
  organic: SearchOrganicResult[];
268
117
  peopleAlsoAsk: SearchPeopleAlsoAskResult[];
@@ -286,14 +135,13 @@ export interface ProjectUpdateParams {
286
135
  }
287
136
  export interface ContentProject {
288
137
  project_id: string;
289
- org_id: string;
290
138
  name: string;
291
139
  description: string;
292
140
  created_at: string;
293
141
  updated_at: string;
294
142
  created_by: string;
295
143
  status: ProjectStatus;
296
- metadata: Record<string, unknown>;
144
+ metadata?: Record<string, unknown>;
297
145
  }
298
146
  export interface ContentProjectListResponse {
299
147
  projects: ContentProject[];
@@ -307,12 +155,11 @@ export interface ProjectChatParams {
307
155
  retrieval_strategy?: string;
308
156
  }
309
157
  export interface ConversationMessage {
310
- org_id: string;
311
158
  user_id: string;
312
159
  role: string;
313
160
  content: string;
314
161
  created_at: string;
315
- metadata: Record<string, unknown>;
162
+ metadata?: Record<string, unknown>;
316
163
  }
317
164
  export interface ProjectChatHistoryResponse {
318
165
  messages: ConversationMessage[];
@@ -335,7 +182,6 @@ export interface ContentItemUpdateParams {
335
182
  }
336
183
  export interface ContentItemResponse {
337
184
  content_id: string;
338
- org_id: string;
339
185
  project_id: string;
340
186
  item_type: ContentItemType;
341
187
  title: string;
@@ -345,7 +191,7 @@ export interface ContentItemResponse {
345
191
  created_by: string;
346
192
  status: ContentItemStatus;
347
193
  asset_url?: string | null;
348
- metadata: Record<string, unknown>;
194
+ metadata?: Record<string, unknown>;
349
195
  }
350
196
  export interface ContentItemListResponse {
351
197
  items: ContentItemResponse[];
@@ -360,15 +206,7 @@ export interface ProjectSourceCreateParams {
360
206
  status?: SourceStatus;
361
207
  metadata?: Record<string, unknown>;
362
208
  }
363
- /**
364
- * Parameters for scraping one or more URLs and persisting the normalized
365
- * results as project sources.
366
- *
367
- * **Auth:** Requires org-scoped API key.
368
- * **Endpoint:** `POST /v1/organizations/{orgId}/projects/{projectId}/sources/scrape`
369
- */
370
209
  export interface ProjectSourceScrapeParams {
371
- /** One or more absolute URLs to fetch and save into the project. */
372
210
  urls: string[];
373
211
  }
374
212
  export interface ProjectSourceUpdateParams {
@@ -380,7 +218,6 @@ export interface ProjectSourceUpdateParams {
380
218
  }
381
219
  export interface ProjectSourceResponse {
382
220
  source_id: string;
383
- org_id: string;
384
221
  project_id: string;
385
222
  url: string;
386
223
  title: string;
@@ -390,7 +227,7 @@ export interface ProjectSourceResponse {
390
227
  source_type: string;
391
228
  description: string;
392
229
  status: SourceStatus;
393
- metadata: Record<string, unknown>;
230
+ metadata?: Record<string, unknown>;
394
231
  }
395
232
  export interface ProjectSourceListResponse {
396
233
  sources: ProjectSourceResponse[];
@@ -416,7 +253,6 @@ export interface PublishScheduleUpdateParams {
416
253
  }
417
254
  export interface PublishScheduleResponse {
418
255
  schedule_id: string;
419
- org_id: string;
420
256
  project_id: string;
421
257
  content_id: string;
422
258
  target_platforms: string[];
@@ -427,210 +263,96 @@ export interface PublishScheduleResponse {
427
263
  timezone: string;
428
264
  status: ScheduleStatus;
429
265
  delivery_endpoint?: string | null;
430
- delivery_headers: Record<string, string>;
266
+ delivery_headers?: Record<string, string>;
431
267
  published_at?: string | null;
432
- last_result: Record<string, unknown>;
433
- metadata: Record<string, unknown>;
268
+ last_result?: Record<string, unknown>;
269
+ metadata?: Record<string, unknown>;
434
270
  }
435
271
  export interface PublishScheduleListResponse {
436
272
  schedules: PublishScheduleResponse[];
437
273
  total: number;
438
274
  }
439
- /**
440
- * Response from manually running due Content Creator schedules.
441
- *
442
- * Returned by `POST /v1/admin/content-creator/schedules/run-due`.
443
- */
444
275
  export interface ScheduleRunResultResponse {
445
276
  processed: number;
446
277
  published: number;
447
278
  failed: number;
448
279
  schedules: PublishScheduleResponse[];
449
280
  }
450
- /**
451
- * Parameters for starting an asynchronous video generation job (Vertex AI Veo).
452
- *
453
- * **Auth:** Requires org-scoped API key.
454
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/video`
455
- */
456
281
  export interface GenerateVideoParams {
457
- /** Video generation prompt (min 1 character). */
458
282
  prompt: string;
459
- /** Duration in seconds. Must be 4, 6, or 8. @default 8 */
460
283
  duration?: 4 | 6 | 8;
461
- /** Aspect ratio (e.g. `"16:9"`, `"9:16"`, `"1:1"`). @default "16:9" */
462
284
  aspect_ratio?: string;
463
- /** Visual style hint (e.g. `"cinematic"`, `"anime"`). */
464
285
  style?: string;
465
- /** Optional user identifier for tracking. */
466
286
  user_id?: string;
467
287
  }
468
- /**
469
- * Parameters for starting an asynchronous image generation job (Vertex AI Imagen).
470
- *
471
- * **Auth:** Requires org-scoped API key.
472
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/image`
473
- */
474
288
  export interface GenerateImageParams {
475
- /** Image generation prompt (min 1 character). */
476
289
  prompt: string;
477
- /** Aspect ratio (e.g. `"1:1"`, `"16:9"`, `"9:16"`). @default "1:1" */
478
290
  aspect_ratio?: string;
479
- /** Visual style hint (e.g. `"digital art"`, `"photorealistic"`). */
480
291
  style?: string;
481
- /** Number of images to generate (1–8). @default 1 */
482
292
  num_images?: number;
483
- /** Optional user identifier for tracking. */
484
293
  user_id?: string;
485
294
  }
486
- /**
487
- * Parameters for starting an asynchronous music generation job.
488
- *
489
- * **Auth:** Requires org-scoped API key.
490
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/music`
491
- */
492
295
  export interface GenerateMusicParams {
493
- /** Target genre (e.g. `"ambient"`). */
494
296
  genre: string;
495
- /** Target mood (e.g. `"uplifting"`). */
496
297
  mood: string;
497
- /** Duration in seconds. */
498
298
  duration: number;
499
- /** Optional user identifier for tracking. */
500
299
  user_id?: string;
501
300
  }
502
- /** Response returned when an asynchronous generation job is accepted (HTTP 202). */
503
301
  export interface JobAcceptedResponse {
504
- /** Unique job identifier. Use with `getJob()` or `waitForJob()` to poll status. */
505
302
  job_id: string;
506
- /** Initial status — always `"processing"`. */
507
303
  status: string;
508
- /** Estimated processing time in seconds. */
509
304
  estimated_time: number;
510
305
  }
511
- /**
512
- * Status of an asynchronous job (video or image generation).
513
- *
514
- * **Auth:** Requires org-scoped API key.
515
- * **Endpoint:** `GET /v1/organizations/{orgId}/jobs/{jobId}`
516
- */
517
306
  export interface JobStatusResponse {
518
- /** Job identifier. */
519
307
  job_id: string;
520
- /** Current status: `"processing"`, `"completed"`, `"failed"`, or `"cancelled"`. */
521
308
  status: string;
522
- /** Result payload when completed (e.g. `{ output_url, signed_url }`). `null` while processing. */
523
309
  result: unknown;
524
- /** Error message if the job failed. `null` otherwise. */
525
310
  error: string | null;
526
311
  }
527
- /**
528
- * Parameters for a natural-language query over BigQuery datasets.
529
- *
530
- * **Auth:** Requires org-scoped API key.
531
- * **Endpoint:** `POST /v1/organizations/{orgId}/data-chat`
532
- */
533
312
  export interface DataChatParams {
534
- /** Natural-language question (min 1 character). */
535
313
  question: string;
536
- /** Optional user identifier for tracking. */
537
314
  user_id?: string;
538
315
  }
539
- /** Response from a data chat query, including the generated SQL and result rows. */
540
316
  export interface DataChatResponse {
541
- /** Natural-language answer summarizing the results. */
542
317
  answer: string;
543
- /** Generated SQL query executed against the data backend. */
544
318
  sql: string;
545
- /** Result rows returned by the query. */
546
319
  data: Array<Record<string, unknown>>;
547
- /** Number of rows returned. */
548
320
  row_count: number;
549
- /** Backend tool used (e.g. "alloydb"). */
550
321
  tool_used: string;
551
322
  }
552
- /**
553
- * Parameters for creating a custom AI agent template.
554
- *
555
- * **Auth:** Requires org-scoped API key.
556
- * **Endpoint:** `POST /v1/organizations/{orgId}/agents/custom`
557
- */
558
323
  export interface AgentCreateParams {
559
- /** Agent name (2–64 characters). */
560
324
  name: string;
561
- /** System instructions for the agent (min 4 characters). */
562
325
  instructions: string;
563
- /** Tool identifiers the agent can use (e.g. `["rag_search", "ticket_create"]`). @default [] */
564
326
  tools?: string[];
565
327
  }
566
- /** Response from creating a custom agent. */
567
328
  export interface AgentCreateResponse {
568
- /** Unique agent identifier. */
569
329
  agent_id: string;
570
- /** Agent name. */
571
330
  name: string;
572
- /** Tools enabled for this agent. */
573
331
  tools: string[];
574
332
  }
575
- /**
576
- * Parameters for querying an AI agent.
577
- *
578
- * **Auth:** Requires org-scoped API key.
579
- * **Endpoint:** `POST /v1/organizations/{orgId}/agents/query`
580
- */
581
333
  export interface AgentQueryParams {
582
- /** User query text (min 1 character). */
583
334
  query: string;
584
- /** User identifier (required for agent context). */
585
- user_id: string;
586
- /** Agent type to route to. @default "auto" */
335
+ user_id?: string;
587
336
  agent_type?: string;
588
337
  }
589
- /** Response from an agent query. */
590
338
  export interface AgentQueryResponse {
591
- /** Agent type that handled the query. */
592
339
  agent_type: string;
593
- /** Agent's response text. */
594
340
  response: string;
595
- /** Actions taken by the agent during processing. */
596
341
  actions: string[];
597
342
  }
598
- /**
599
- * Parameters for audio transcription (speech-to-text).
600
- *
601
- * **Auth:** Requires org-scoped API key.
602
- * **Endpoint:** `POST /v1/organizations/{orgId}/audio/transcribe`
603
- */
604
343
  export interface AudioTranscribeParams {
605
- /** Legacy fallback text input used when no audio URL is provided. */
606
344
  audio_text?: string;
607
- /** Public or cloud-storage URL for the audio file to transcribe with ElevenLabs Scribe. */
608
345
  audio_url?: string;
609
- /** BCP-47 language code. @default "en-US" */
610
346
  language_code?: string;
611
- /** Speech-to-text model. @default "scribe_v2" */
612
347
  model_id?: string;
613
348
  }
614
- /**
615
- * Parameters for text-to-speech synthesis.
616
- *
617
- * **Auth:** Requires org-scoped API key.
618
- * **Endpoint:** `POST /v1/organizations/{orgId}/audio/synthesize`
619
- */
620
349
  export interface AudioSynthesizeParams {
621
- /** Text to convert to speech (min 1 character). */
622
350
  text: string;
623
- /** Voice identifier. @default "en-US-Neural2-J" */
624
351
  voice_name?: string;
625
- /** Optional ElevenLabs model override, e.g. `eleven_v3`. */
626
352
  model_id?: string;
627
- /** Optional ElevenLabs output format override, e.g. `mp3_44100_128`. */
628
353
  output_format?: string;
629
- /** Optional ISO 639-1 language code passed to ElevenLabs. */
630
354
  language_code?: string;
631
- /** Optional deterministic seed passed to ElevenLabs. */
632
355
  seed?: number;
633
- /** Optional per-request ElevenLabs voice settings override. */
634
356
  voice_settings?: {
635
357
  stability?: number;
636
358
  similarity_boost?: number;
@@ -639,12 +361,10 @@ export interface AudioSynthesizeParams {
639
361
  speed?: number;
640
362
  };
641
363
  }
642
- /** A speaker turn detected by the transcription pipeline. */
643
364
  export interface AudioSpeakerTurn {
644
365
  speaker: number;
645
366
  word_count: number;
646
367
  }
647
- /** Response from audio transcription (speech-to-text). */
648
368
  export interface AudioTranscriptionResponse {
649
369
  transcript: string;
650
370
  speaker_turns: AudioSpeakerTurn[];
@@ -653,7 +373,6 @@ export interface AudioTranscriptionResponse {
653
373
  transcription_id?: string | null;
654
374
  source_url?: string | null;
655
375
  }
656
- /** Response from text-to-speech synthesis. */
657
376
  export interface AudioSynthesizeResponse {
658
377
  url: string;
659
378
  output_url: string;
@@ -668,256 +387,80 @@ export interface AudioSynthesizeResponse {
668
387
  content_type?: string | null;
669
388
  request_id?: string | null;
670
389
  }
671
- /**
672
- * Parameters for training a predictive model on tabular data.
673
- *
674
- * **Auth:** Requires org-scoped API key.
675
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/train`
676
- */
677
390
  export interface TrainModelParams {
678
- /** Column name to predict. */
679
391
  target_column: string;
680
- /** Feature column names used as model inputs. */
681
392
  feature_columns: string[];
682
- /** Training data rows. Each row is an object with feature + target columns. */
683
393
  rows: Array<Record<string, unknown>>;
684
394
  }
685
- /** Response from training a predictive model. */
686
395
  export interface TrainModelResponse {
687
- /** Unique model identifier. Use with `predict()`. */
688
396
  model_id: string;
689
- /** Deployment status (e.g. `"deployed"`). */
690
397
  status: string;
691
398
  }
692
- /**
693
- * Parameters for running predictions with a trained model.
694
- *
695
- * **Auth:** Requires org-scoped API key.
696
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/predict`
697
- */
698
399
  export interface PredictParams {
699
- /** Trained model identifier (from `trainModel()`). */
700
400
  model_id: string;
701
- /** Data instances to predict on. Each instance has the model's feature columns. */
702
401
  instances: Array<Record<string, unknown>>;
703
402
  }
704
- /** Response containing prediction results. */
705
403
  export interface PredictResponse {
706
- /** Predictions for each input instance. */
707
404
  predictions: unknown[];
708
405
  }
709
- /**
710
- * Parameters for time-series forecasting.
711
- *
712
- * **Auth:** Requires org-scoped API key.
713
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/forecast`
714
- */
715
406
  export interface ForecastParams {
716
- /** Historical time-series values. */
717
407
  series: number[];
718
- /** Forecast horizon in periods (1–365). @default 30 */
719
408
  horizon?: number;
720
409
  }
721
- /** Response containing the forecast values. */
722
410
  export interface ForecastResponse {
723
- /** Predicted future values for the specified horizon. */
724
411
  forecast: number[];
725
- /** Model used for forecasting. */
726
412
  model: string;
727
413
  }
728
- /**
729
- * Monthly usage summary for an organization.
730
- * Includes token, image, video, storage, and compute usage against tier limits.
731
- */
732
- export interface UsageSummaryResponse {
733
- /** Organization identifier. */
734
- org_id: string;
735
- /** Month in `YYYY-MM` format. */
736
- month: string;
737
- /** Usage counters (tokens_used, images_generated, videos_generated, storage_bytes, compute_hours). */
738
- usage: Record<string, unknown>;
739
- /** Tier limits for comparison. */
740
- limits: Record<string, unknown>;
741
- /** Whether the organization is within all quotas. */
742
- within_quota: boolean;
743
- /** List of limit keys that have been exceeded. */
744
- exceeded_limits: string[];
745
- }
746
- /**
747
- * Monthly invoice with cost breakdown by resource type.
748
- * Costs are calculated based on the platform's pricing configuration.
749
- */
750
- export interface InvoiceResponse {
751
- /** Organization identifier. */
752
- org_id: string;
753
- /** Month in `YYYY-MM` format. */
754
- month: string;
755
- /** Usage counters for the billing period. */
756
- usage: Record<string, unknown>;
757
- /** Cost breakdown by resource type. */
758
- costs: Record<string, number>;
759
- /** Total cost for the period. */
760
- total: number;
761
- /** Currency code. */
762
- currency: string;
763
- }
764
- /** A single audit log entry recording an API action. */
765
414
  export interface AuditRecord {
766
- /** ISO 8601 timestamp of the action. */
767
415
  timestamp: string;
768
- /** Organization identifier. */
769
- org_id: string;
770
- /** User who performed the action (null for system actions). */
771
416
  user_id: string | null;
772
- /** Action identifier (e.g. `"query.execute"`, `"document.upload"`). */
773
417
  action: string;
774
- /** Resource path (e.g. `"rag/query"`, `"documents/upload"`). */
775
418
  resource: string;
776
- /** Outcome status (e.g. `"success"`, `"failure"`). */
777
419
  status: string;
778
- /** Additional context (model_type, file size, etc.). */
779
420
  metadata: Record<string, unknown>;
780
421
  }
781
- /**
782
- * Response containing audit log records for an organization.
783
- * Backend model: `AuditLogListResponse`.
784
- */
785
422
  export interface AuditLogResponse {
786
- /** Organization identifier. */
787
- org_id: string;
788
- /** Audit log entries, newest first. */
789
423
  records: AuditRecord[];
790
424
  }
791
- /**
792
- * Parameters for submitting URLs to scrape.
793
- *
794
- * **Auth:** None required.
795
- * **Endpoint:** `POST /v1/scraping/scrape`
796
- */
797
425
  export interface ScrapeParams {
798
- /** List of URLs to scrape. JS-heavy sites (Reddit, Twitter, etc.) are auto-routed to Selenium. */
799
426
  urls: string[];
800
427
  }
801
- /** Response from submitting a scrape job. */
802
428
  export interface ScrapeResponse {
803
- /** Unique task identifier. Use with `getScrapeStatus()` to poll results. */
804
429
  task_id: string;
805
- /** Submission status (`"completed"` for inline mode, `"submitted"` for Celery mode). */
806
430
  status: string;
807
431
  }
808
- /** A single scraped page result. */
809
432
  export interface ScrapeResultItem {
810
- /** Source URL. */
811
433
  url?: string;
812
- /** Page title. */
813
434
  title?: string;
814
- /** Meta description. */
815
435
  description?: string;
816
- /** Extracted text paragraphs. */
817
436
  paragraphs?: string[];
818
- /** Full extracted text content. */
819
437
  full_text?: string;
820
- /** Error message if scraping this URL failed. */
821
438
  error?: string;
822
439
  }
823
- /**
824
- * Status and results of a scrape task.
825
- *
826
- * **Endpoint:** `GET /v1/scraping/status/{taskId}`
827
- */
828
440
  export interface ScrapeStatusResponse {
829
- /** Task identifier. */
830
441
  task_id: string;
831
- /** Task status: `"PENDING"`, `"SUCCESS"`, `"FAILURE"`, or `"completed"`. */
832
442
  status: string;
833
- /** Scraped results (empty while pending). */
834
443
  result: ScrapeResultItem[];
835
444
  }
836
- /**
837
- * Runtime scraping configuration.
838
- *
839
- * **Endpoint:** `GET /v1/scraping/config`
840
- */
841
445
  export interface ScrapingConfigResponse {
842
- /** Execution mode: `"inline"`, `"celery"`, or `"auto"`. */
843
446
  execution_mode: string;
844
- /** Whether running on Cloud Run. */
845
447
  is_cloud_run: boolean;
846
- /** Maximum inline result cache size. */
847
448
  inline_result_cache_size: number;
848
- /** Current number of cached entries. */
849
449
  inline_result_cache_entries: number;
850
450
  }
851
- /**
852
- * Payload for the video generation completion webhook.
853
- *
854
- * **Auth:** Requires `webhookSecret` in client config.
855
- * **Endpoint:** `POST /v1/webhook/video-complete`
856
- */
857
451
  export interface VideoCompleteWebhook {
858
- /** Job identifier. */
859
452
  job_id: string;
860
- /** Organization identifier. */
861
- org_id: string;
862
- /** Completion status (e.g. `"completed"`, `"failed"`). */
863
453
  status: string;
864
- /** Additional metadata (e.g. `{ output_uri: "gs://..." }`). */
865
454
  metadata?: Record<string, unknown>;
866
455
  }
867
- /**
868
- * Payload for the document processing completion webhook.
869
- *
870
- * **Auth:** Requires `webhookSecret` in client config.
871
- * **Endpoint:** `POST /v1/webhook/document-processed`
872
- */
873
456
  export interface DocumentProcessedWebhook {
874
- /** Document identifier. */
875
457
  document_id: string;
876
- /** Organization identifier. */
877
- org_id: string;
878
- /** Processing status (e.g. `"processed"`, `"failed"`). */
879
458
  status: string;
880
- /** Additional metadata (e.g. `{ chunks: 47 }`). */
881
459
  metadata?: Record<string, unknown>;
882
460
  }
883
- /**
884
- * Root service metadata response.
885
- *
886
- * **Auth:** None required.
887
- * **Endpoint:** `GET /`
888
- */
889
- export interface RootResponse {
890
- /** Service name. */
891
- service: string;
892
- /** Service status (`"ok"`). */
893
- status: string;
894
- /** Relative health endpoint path. */
895
- health: string;
896
- /** Relative Swagger docs path. */
897
- docs: string;
898
- }
899
- /**
900
- * Service health check response.
901
- *
902
- * **Auth:** None required.
903
- * **Endpoint:** `GET /v1/health`
904
- */
905
- export interface HealthResponse {
906
- /** Service name. */
907
- service: string;
908
- /** Service version. */
909
- version: string;
910
- /** Health status (`"ok"`). */
911
- status: string;
912
- /** Aggregate statistics (organizations, documents, total_chunks). */
913
- stats: Record<string, unknown>;
461
+ export interface WebhookAckResponse {
462
+ received: boolean;
914
463
  }
915
- /**
916
- * Full service configuration overview.
917
- *
918
- * **Auth:** Requires `adminKey` in client config.
919
- * **Endpoint:** `GET /v1/admin/config`
920
- */
921
464
  export interface ConfigOverview {
922
465
  service_name: string;
923
466
  service_version: string;
@@ -945,36 +488,30 @@ export interface ConfigOverview {
945
488
  log_level: string;
946
489
  debug: boolean;
947
490
  }
948
- /** Request to update a runtime setting. */
949
491
  export interface UpdateSettingRequest {
950
492
  key: string;
951
493
  value: unknown;
952
494
  }
953
- /** Response after updating a runtime setting. */
954
495
  export interface UpdateSettingResponse {
955
496
  key: string;
956
497
  previous_value: unknown;
957
498
  new_value: unknown;
958
499
  updated_at: string;
959
500
  }
960
- /** Request to change the log level. */
961
501
  export interface LogLevelRequest {
962
502
  level: string;
963
503
  }
964
- /** Response from changing the log level. */
965
504
  export interface LogLevelResponse {
966
505
  previous_level: string;
967
506
  new_level: string;
968
507
  updated_at: string;
969
508
  }
970
- /** Information about a single logger. */
971
509
  export interface LoggerInfo {
972
510
  name: string;
973
511
  level: string;
974
512
  effective_level: string;
975
513
  handlers: string[];
976
514
  }
977
- /** Inbound traffic statistics. */
978
515
  export interface InboundTrafficStats {
979
516
  total_requests: number;
980
517
  requests_by_method: Record<string, number>;
@@ -983,7 +520,6 @@ export interface InboundTrafficStats {
983
520
  top_paths: Array<Record<string, unknown>>;
984
521
  collected_since: string;
985
522
  }
986
- /** A single outbound dependency health check. */
987
523
  export interface OutboundDependency {
988
524
  name: string;
989
525
  type: string;
@@ -991,151 +527,100 @@ export interface OutboundDependency {
991
527
  latency_ms: number | null;
992
528
  details: Record<string, unknown>;
993
529
  }
994
- /** Response from checking outbound dependencies. */
995
530
  export interface OutboundStatusResponse {
996
531
  checked_at: string;
997
532
  dependencies: OutboundDependency[];
998
533
  }
999
- /** A single rate-limit entry for an organization. */
1000
534
  export interface RateLimitEntry {
1001
- org_id: string;
535
+ scope_id: string;
1002
536
  current_count: number;
1003
537
  window_start: string | null;
1004
538
  }
1005
- /** Summary of an organization for admin listing. */
1006
- export interface OrgSummary {
1007
- org_id: string;
1008
- name: string;
1009
- tier: string;
1010
- status: string;
1011
- created_at: string;
1012
- }
1013
- /** Response from listing all organizations. */
1014
- export interface OrgListResponse {
1015
- total: number;
1016
- organizations: OrgSummary[];
1017
- }
1018
- /** Summary of a job for admin listing. */
1019
539
  export interface JobSummary {
1020
540
  job_id: string;
1021
- org_id: string;
541
+ scope_id: string;
1022
542
  status: string;
1023
543
  created_at: string;
1024
544
  completed_at: string | null;
1025
545
  }
1026
- /** Response from listing all jobs. */
1027
546
  export interface JobListResponse {
1028
547
  total: number;
1029
548
  jobs: JobSummary[];
1030
549
  }
1031
- /** A single feature flag. */
1032
550
  export interface FeatureFlag {
1033
551
  key: string;
1034
552
  enabled: boolean;
1035
553
  description: string;
1036
554
  }
1037
- /** Request to create or update a feature flag. */
1038
555
  export interface FeatureFlagUpdate {
1039
556
  key: string;
1040
557
  enabled: boolean;
1041
558
  }
1042
- /** Request to set maintenance mode. */
1043
559
  export interface MaintenanceModeRequest {
1044
560
  enabled: boolean;
1045
561
  message?: string;
1046
562
  }
1047
- /** Response with current maintenance mode state. */
1048
563
  export interface MaintenanceModeResponse {
1049
564
  enabled: boolean;
1050
565
  message: string;
1051
566
  updated_at: string;
1052
567
  }
1053
- /** Cache statistics. */
1054
568
  export interface CacheStatsResponse {
1055
569
  backend: string;
1056
570
  connected: boolean;
1057
571
  details: Record<string, unknown>;
1058
572
  }
1059
- /** Configuration for a single tier. */
1060
- export interface TierConfigResponse {
1061
- tier: string;
1062
- max_tokens_per_month: number;
1063
- max_images_per_month: number;
1064
- max_videos_per_month: number;
1065
- max_storage_gb: number;
1066
- max_compute_hours: number;
1067
- requests_per_minute: number;
1068
- concurrent_jobs: number;
1069
- features: string[];
1070
- }
1071
- /** Pricing configuration. */
1072
- export interface PricingResponse {
1073
- pricing: Record<string, number>;
1074
- }
1075
- /** A single admin audit log entry. */
1076
573
  export interface AdminAuditEntry {
1077
574
  timestamp: string;
1078
575
  admin_action: string;
1079
576
  detail: string;
1080
577
  metadata: Record<string, unknown>;
1081
578
  }
1082
- /** Response from the admin audit endpoint. */
1083
579
  export interface AdminAuditResponse {
1084
580
  total: number;
1085
581
  entries: AdminAuditEntry[];
1086
582
  }
1087
- /**
1088
- * Request to connect a Jira Cloud site using an API token.
1089
- *
1090
- * **Auth:** Requires org-scoped API key.
1091
- * **Endpoint:** `POST /v1/organizations/{orgId}/integrations/jira/connect`
1092
- */
583
+ export interface JiraWebhookPayload {
584
+ webhookEvent: string;
585
+ timestamp?: number | null;
586
+ issue?: Record<string, unknown> | null;
587
+ comment?: Record<string, unknown> | null;
588
+ changelog?: Record<string, unknown> | null;
589
+ user?: Record<string, unknown>;
590
+ matchedWebhookIds?: number[];
591
+ }
1093
592
  export interface JiraConnectRequest {
1094
593
  site_url: string;
1095
594
  email: string;
1096
595
  api_token: string;
1097
596
  }
1098
- /**
1099
- * Response from connecting a Jira Cloud site.
1100
- *
1101
- * **Auth:** Requires org-scoped API key.
1102
- * **Endpoint:** `POST /v1/organizations/{orgId}/integrations/jira/connect`
1103
- */
597
+ export interface JiraIntegrationStatusResponse {
598
+ connected: boolean;
599
+ site_url?: string | null;
600
+ cloud_id?: string | null;
601
+ status?: string | null;
602
+ connected_at?: string | null;
603
+ }
1104
604
  export interface JiraConnectResponse {
1105
605
  status: string;
1106
- org_id: string;
1107
606
  site_url: string;
1108
607
  cloud_id: string;
1109
608
  }
1110
- /**
1111
- * Jira integration status for an organization.
1112
- *
1113
- * **Auth:** Requires org-scoped API key.
1114
- * **Endpoint:** `GET /v1/organizations/{orgId}/integrations/jira/status`
1115
- */
1116
- export interface JiraIntegrationStatusResponse {
1117
- org_id: string;
1118
- connected: boolean;
1119
- site_url: string | null;
1120
- cloud_id: string | null;
1121
- status: string | null;
1122
- connected_at: string | null;
1123
- }
1124
- /**
1125
- * Request to sync Jira projects.
1126
- *
1127
- * **Auth:** Requires org-scoped API key.
1128
- * **Endpoint:** `POST /v1/organizations/{orgId}/integrations/jira/sync`
1129
- */
1130
609
  export interface JiraSyncRequest {
1131
610
  project_keys: string[];
1132
611
  }
1133
- /** Response from initiating a Jira sync. */
1134
612
  export interface JiraSyncResponse {
1135
613
  job_id: string;
1136
614
  status: string;
1137
615
  project_keys: string[];
1138
616
  }
617
+ export interface JiraDisconnectResponse {
618
+ status: string;
619
+ }
620
+ export interface JiraWebhookAckResponse {
621
+ received: boolean;
622
+ result: Record<string, unknown>;
623
+ }
1139
624
  export interface AIGenerationRules {
1140
625
  enabled: boolean;
1141
626
  context_required: string[];
@@ -1149,8 +634,8 @@ export interface BlueprintSection {
1149
634
  is_required: boolean;
1150
635
  section_type: string;
1151
636
  ai_generation_rules: AIGenerationRules;
1152
- min_length: number | null;
1153
- max_length: number | null;
637
+ min_length?: number | null;
638
+ max_length?: number | null;
1154
639
  }
1155
640
  export interface WorkflowStageConfig {
1156
641
  allowed_roles: string[];
@@ -1176,11 +661,10 @@ export interface TargetRoles {
1176
661
  }
1177
662
  export interface BlueprintResponse {
1178
663
  blueprint_id: string;
1179
- org_id: string;
1180
664
  name: string;
1181
665
  description: string;
1182
666
  category: string;
1183
- status: "draft" | "published" | "archived";
667
+ status: string;
1184
668
  version: number;
1185
669
  created_at: string;
1186
670
  updated_at: string;
@@ -1205,16 +689,9 @@ export interface BlueprintCreateParams {
1205
689
  target_roles?: Partial<TargetRoles>;
1206
690
  sections?: Array<Omit<BlueprintSection, "section_id">>;
1207
691
  workflow_config?: Partial<WorkflowConfig>;
692
+ metadata?: Record<string, unknown>;
1208
693
  }
1209
- export interface BlueprintUpdateParams {
1210
- name?: string;
1211
- description?: string;
1212
- category?: string;
1213
- default_workflow?: string;
1214
- visibility_notes?: string;
1215
- target_roles?: Partial<TargetRoles>;
1216
- sections?: Array<Omit<BlueprintSection, "section_id">>;
1217
- workflow_config?: Partial<WorkflowConfig>;
694
+ export interface BlueprintUpdateParams extends BlueprintCreateParams {
1218
695
  }
1219
696
  export interface DocumentSectionContent {
1220
697
  section_id: string;
@@ -1235,8 +712,8 @@ export interface DocumentSection {
1235
712
  order: number;
1236
713
  content: string;
1237
714
  is_ai_generated: boolean;
1238
- last_edited_by: string | null;
1239
- last_edited_at: string | null;
715
+ last_edited_by: string;
716
+ last_edited_at?: string | null;
1240
717
  }
1241
718
  export interface WorkflowAction {
1242
719
  action_id: string;
@@ -1249,10 +726,9 @@ export interface WorkflowAction {
1249
726
  }
1250
727
  export interface ManagedDocumentResponse {
1251
728
  document_id: string;
1252
- org_id: string;
1253
729
  blueprint_id: string;
1254
730
  title: string;
1255
- status: "draft" | "in_review" | "approved" | "sealed" | "rejected" | "revision";
731
+ status: string;
1256
732
  created_at: string;
1257
733
  updated_at: string;
1258
734
  created_by: string;
@@ -1276,51 +752,23 @@ export interface DocumentWorkflowActionParams {
1276
752
  action: "submit" | "approve" | "reject" | "request_changes" | "seal";
1277
753
  comment?: string;
1278
754
  }
1279
- /** Parameters for AI-generating content for a document section. */
1280
755
  export interface DocumentGenerateSectionParams {
1281
- /** Section ID to generate content for. */
1282
756
  section_id: string;
1283
- /** Key-value context for AI generation. */
1284
757
  context?: Record<string, string>;
1285
758
  }
1286
- /** Response from AI-generating a document section. */
1287
759
  export interface DocumentGenerateResponse {
1288
- /** Section that was generated. */
1289
760
  section_id: string;
1290
- /** Generated content. */
1291
761
  generated_content: string;
1292
- /** AI model used for generation. */
1293
762
  model_used: string;
1294
763
  }
1295
- /** Response from a webhook acknowledgment. */
1296
- export interface WebhookAckResponse {
1297
- received: boolean;
1298
- }
1299
- /** Response from disconnecting a Jira integration. */
1300
- export interface JiraDisconnectResponse {
1301
- status: string;
1302
- org_id: string;
1303
- }
1304
- /** Response from a Jira webhook acknowledgment. */
1305
- export interface JiraWebhookAckResponse {
1306
- received: boolean;
1307
- org_id: string;
1308
- result: Record<string, unknown>;
1309
- }
1310
- /** A parsed Server-Sent Event. */
1311
764
  export interface SseEvent {
1312
- /** Event type (from the `event:` line). Undefined for unnamed events. */
1313
765
  event?: string;
1314
- /** Payload string (from the `data:` line(s)). */
1315
766
  data: string;
1316
- /** Event ID (from the `id:` line), if present. */
1317
767
  id?: string;
1318
768
  }
1319
- /** Typed SSE events emitted by the chat/stream endpoint. */
1320
769
  export type ChatStreamEvent = {
1321
770
  event: "start";
1322
771
  data: {
1323
- org_id: string;
1324
772
  project_id: string;
1325
773
  };
1326
774
  } | {
@@ -1332,7 +780,6 @@ export type ChatStreamEvent = {
1332
780
  message: string;
1333
781
  };
1334
782
  };
1335
- /** Command sent by the client over a chat WebSocket. */
1336
783
  export interface WsChatCommand {
1337
784
  type: "chat";
1338
785
  message: string;
@@ -1341,7 +788,6 @@ export interface WsChatCommand {
1341
788
  temperature?: number;
1342
789
  retrieval_strategy?: string;
1343
790
  }
1344
- /** Frames sent by the server over a chat WebSocket. */
1345
791
  export type WsChatFrame = {
1346
792
  type: "result";
1347
793
  payload: QueryResponse;