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