@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/client.d.ts CHANGED
@@ -1,25 +1,18 @@
1
- import type { AdminLoginParams, AdminLoginResponse, AdminAuditResponse, AgentCreateParams, AgentCreateResponse, AgentQueryParams, AgentQueryResponse, AudioSynthesizeParams, AudioSynthesizeResponse, AudioTranscribeParams, AudioTranscriptionResponse, AuditLogResponse, CacheStatsResponse, ChangeOrgStatusResponse, ChatStreamEvent, CreateOrganizationOptions, ContentItemCreateParams, ContentItemListResponse, ContentItemResponse, ContentItemUpdateParams, ContentProject, ContentProjectListResponse, ConfigOverview, DataChatParams, DataChatResponse, DocumentGenerateResponse, DocumentGenerateSectionParams, DocumentProcessedWebhook, DocumentUploadResponse, FeatureFlag, FeatureFlagUpdate, ForecastParams, ForecastResponse, GenerateImageParams, GenerateMusicParams, GenerateVideoParams, HealthResponse, InboundTrafficStats, InvoiceResponse, JiraConnectRequest, JiraConnectResponse, JiraDisconnectResponse, JiraIntegrationStatusResponse, JiraSyncRequest, JiraSyncResponse, JiraWebhookAckResponse, BlueprintCreateParams, BlueprintUpdateParams, BlueprintResponse, BlueprintListResponse, DocumentCreateFromBlueprintParams, DocumentUpdateSectionParams, DocumentWorkflowActionParams, ManagedDocumentResponse, ManagedDocumentListResponse, JobAcceptedResponse, JobListResponse, JobStatusResponse, LogLevelRequest, LogLevelResponse, LoggerInfo, MaintenanceModeRequest, MaintenanceModeResponse, OrgBootstrapResponse, OrgCreateParams, OrgEnsureResponse, OrgListResponse, Organization, OutboundStatusResponse, PredictParams, PredictResponse, PricingResponse, ProjectChatHistoryResponse, ProjectChatParams, ProjectCreateParams, ProjectSourceCreateParams, ProjectSourceListResponse, ProjectSourceResponse, ProjectSourceScrapeParams, ProjectSourceUpdateParams, ProjectUpdateParams, QueryParams, QueryResponse, SearchParams, SearchResponse, RateLimitEntry, RootResponse, RotateApiKeyResponse, ScrapeParams, ScrapeResponse, ScrapeStatusResponse, ScrapingConfigResponse, ScheduleRunResultResponse, TierConfigResponse, TrainModelParams, TrainModelResponse, UpdateSettingRequest, UpdateSettingResponse, UsageSummaryResponse, WebhookAckResponse, WsChatCommand, WsChatFrame, PublishScheduleCreateParams, PublishScheduleListResponse, PublishScheduleResponse, PublishScheduleUpdateParams, HivemindClientConfigInput, RequestOptions, VideoCompleteWebhook } from "./types";
1
+ import type { AdminAuditResponse, AdminLoginParams, AdminLoginResponse, AgentCreateParams, AgentCreateResponse, AgentQueryParams, AgentQueryResponse, ApiKeyBootstrapResponse, ApiKeyIssueParams, ApiKeyRotateResponse, ApiKeyScope, AudioSynthesizeParams, AudioSynthesizeResponse, AudioTranscribeParams, AudioTranscriptionResponse, AuditLogResponse, BlueprintCreateParams, BlueprintListResponse, BlueprintResponse, BlueprintUpdateParams, CacheStatsResponse, ChatStreamEvent, ConfigOverview, ContentItemCreateParams, ContentItemListResponse, ContentItemResponse, ContentItemUpdateParams, ContentProject, ContentProjectListResponse, DataChatParams, DataChatResponse, DocumentCreateFromBlueprintParams, DocumentGenerateResponse, DocumentGenerateSectionParams, DocumentProcessedWebhook, DocumentUpdateSectionParams, DocumentUploadResponse, DocumentWorkflowActionParams, FeatureFlag, FeatureFlagUpdate, ForecastParams, ForecastResponse, GenerateImageParams, GenerateMusicParams, GenerateVideoParams, HealthResponse, HivemindClientConfigInput, InboundTrafficStats, JiraConnectRequest, JiraConnectResponse, JiraDisconnectResponse, JiraIntegrationStatusResponse, JiraSyncRequest, JiraSyncResponse, JiraWebhookAckResponse, JobAcceptedResponse, JobListResponse, JobStatusResponse, LogLevelRequest, LogLevelResponse, LoggerInfo, MaintenanceModeRequest, MaintenanceModeResponse, ManagedDocumentListResponse, ManagedDocumentResponse, OutboundStatusResponse, PredictParams, PredictResponse, ProjectChatHistoryResponse, ProjectChatParams, ProjectCreateParams, ProjectSourceCreateParams, ProjectSourceListResponse, ProjectSourceResponse, ProjectSourceScrapeParams, ProjectSourceUpdateParams, ProjectUpdateParams, PublishScheduleCreateParams, PublishScheduleListResponse, PublishScheduleResponse, PublishScheduleUpdateParams, QueryParams, QueryResponse, RateLimitEntry, RequestOptions, RootResponse, ScheduleRunResultResponse, ScrapeParams, ScrapeResponse, ScrapeStatusResponse, ScrapingConfigResponse, SearchParams, SearchResponse, TrainModelParams, TrainModelResponse, UpdateSettingRequest, UpdateSettingResponse, VideoCompleteWebhook, WebhookAckResponse, WsChatCommand } from "./types";
2
2
  export * from "./types";
3
- /**
4
- * Error thrown when an API request fails.
5
- * Contains the HTTP status code and the raw response body for inspection.
6
- *
7
- * @example
8
- * ```typescript
9
- * try {
10
- * await client.query("my-org", { query: "hello" });
11
- * } catch (err) {
12
- * if (err instanceof HivemindError) {
13
- * console.error(`HTTP ${err.statusCode}:`, err.detail);
14
- * }
15
- * }
16
- * ```
17
- */
18
3
  export declare class HivemindError extends Error {
19
4
  statusCode: number;
20
5
  detail: unknown;
21
6
  constructor(statusCode: number, detail: unknown, message?: string);
22
7
  }
8
+ type QueryMap = Record<string, string | number | boolean | undefined | null>;
9
+ type RequestConfig = {
10
+ body?: unknown;
11
+ headers?: Record<string, string>;
12
+ query?: QueryMap;
13
+ formData?: FormData;
14
+ apiKey?: string;
15
+ };
23
16
  export declare class HivemindClient {
24
17
  private readonly baseUrl;
25
18
  private readonly prefix;
@@ -28,1218 +21,142 @@ export declare class HivemindClient {
28
21
  private request;
29
22
  private requestUnprefixed;
30
23
  private performRequest;
31
- /**
32
- * Build the same request a normal REST call would, but return the full
33
- * envelope instead of unwrapping `.data`. Useful when callers need
34
- * `message` or `statusCode` directly.
35
- */
36
- requestEnvelope<T>(method: string, path: string, opts?: {
37
- body?: unknown;
38
- headers?: Record<string, string>;
39
- query?: Record<string, string>;
40
- apiKey?: string;
41
- }): Promise<import("./types").ApiEnvelope<T>>;
24
+ requestEnvelope<T>(method: string, path: string, opts?: Omit<RequestConfig, "formData">): Promise<import("./types").ApiEnvelope<T>>;
42
25
  private asEnvelope;
43
26
  private extractErrorMessage;
44
- private isOrganizationAlreadyExistsError;
45
27
  private get;
46
28
  private post;
47
- private del;
48
29
  private put;
49
30
  private patch;
50
- /**
51
- * Fetch the unauthenticated service root metadata payload.
52
- *
53
- * @returns Service name plus relative health/docs entrypoints.
54
- *
55
- * **Endpoint:** `GET /`
56
- */
31
+ private del;
57
32
  root(): Promise<RootResponse>;
58
- /**
59
- * Check service health status. No authentication required.
60
- *
61
- * @returns Service name, version, status, and aggregate statistics.
62
- *
63
- * **Endpoint:** `GET /v1/health`
64
- *
65
- * @example
66
- * ```typescript
67
- * const health = await client.health();
68
- * console.log(health.status); // "ok"
69
- * console.log(health.stats); // { organizations: 12, documents: 450, total_chunks: 3200 }
70
- * ```
71
- */
72
33
  health(): Promise<HealthResponse>;
73
- /**
74
- * Exchange the bootstrap admin key for a signed session token.
75
- * The token can be used as `Authorization: Bearer <token>` for admin endpoints
76
- * instead of sending the raw admin key on every request.
77
- *
78
- * @param params - Object containing the `admin_key`.
79
- * @returns Signed session token with type and expiry.
80
- * @throws {@link HivemindError} 400 if admin key is not configured on the server.
81
- * @throws {@link HivemindError} 401 if the admin key is invalid.
82
- *
83
- * **Endpoint:** `POST /v1/admin/login`
84
- *
85
- * @example
86
- * ```typescript
87
- * const { access_token, expires_in_seconds } = await client.adminLogin({
88
- * admin_key: "your-bootstrap-admin-key",
89
- * });
90
- * // Use access_token as Bearer token for subsequent admin requests
91
- * ```
92
- */
93
34
  adminLogin(params: AdminLoginParams): Promise<AdminLoginResponse>;
94
- /**
95
- * Create a new organization. Returns the organization details and a generated API key.
96
- *
97
- * **Auth:** Requires `adminKey` in client config (sends `X-Admin-Key` header).
98
- *
99
- * @param params - Organization creation parameters (org_id, name, tier, settings).
100
- * @param options - Optional behavior flags. By default, duplicate-organization
101
- * responses are treated as a successful lookup instead of throwing. Pass
102
- * `{ allowExisting: false }` for strict create-only behavior.
103
- * @returns The created organization and its API key, or the existing organization
104
- * when the org has already been provisioned.
105
- * @throws {@link HivemindError} 400 if validation fails, or if the org already exists
106
- * and you passed `{ allowExisting: false }`.
107
- * @throws {@link HivemindError} 401 if admin credentials are invalid.
108
- *
109
- * **Endpoint:** `POST /v1/organizations`
110
- *
111
- * @example
112
- * ```typescript
113
- * const { organization, api_key } = await admin.createOrganization({
114
- * org_id: "acme-corp",
115
- * name: "Acme Corporation",
116
- * tier: "premium",
117
- * });
118
- * console.log("API Key:", api_key); // Store securely — shown only once
119
- * ```
120
- */
121
- createOrganization(params: OrgCreateParams): Promise<OrgEnsureResponse>;
122
- createOrganization(params: OrgCreateParams, options: CreateOrganizationOptions & {
123
- allowExisting: false;
124
- }): Promise<OrgBootstrapResponse>;
125
- createOrganization(params: OrgCreateParams, options: CreateOrganizationOptions & {
126
- allowExisting: true;
127
- }): Promise<OrgEnsureResponse>;
128
- /**
129
- * Ensure an organization exists without throwing when it has already been provisioned.
130
- *
131
- * **Auth:** Requires `adminKey` in client config.
132
- *
133
- * @param params - Organization creation parameters.
134
- * @returns A discriminated result describing whether the org was created or already existed.
135
- */
136
- ensureOrganization(params: OrgCreateParams): Promise<OrgEnsureResponse>;
137
- /**
138
- * Retrieve organization details including tier, status, and settings.
139
- *
140
- * **Auth:** Requires org-scoped API key (via config or `options.apiKey`).
141
- *
142
- * @param orgId - Organization identifier.
143
- * @param options - Optional per-request overrides (e.g. `{ apiKey }`).
144
- * @returns Full organization entity.
145
- * @throws {@link HivemindError} 401 if API key is missing or invalid.
146
- * @throws {@link HivemindError} 403 if the API key belongs to a different org.
147
- * @throws {@link HivemindError} 404 if the organization does not exist.
148
- *
149
- * **Endpoint:** `GET /v1/organizations/{orgId}`
150
- */
151
- getOrganization(orgId: string, options?: RequestOptions): Promise<Organization>;
152
- /**
153
- * Rotate the API key for an organization. The previous key remains valid
154
- * for a 24-hour grace period.
155
- *
156
- * **Auth:** Requires `adminKey` in client config.
157
- *
158
- * @param orgId - Organization identifier.
159
- * @param options - Optional per-request overrides.
160
- * @returns New API key and grace period expiry for the previous key.
161
- * @throws {@link HivemindError} 401 if admin credentials are invalid.
162
- * @throws {@link HivemindError} 404 if the organization does not exist.
163
- *
164
- * **Endpoint:** `POST /v1/organizations/{orgId}/api-keys/rotate`
165
- */
166
- rotateApiKey(orgId: string, options?: RequestOptions): Promise<RotateApiKeyResponse>;
167
- /**
168
- * Suspend an organization, blocking all API key access until reactivated.
169
- *
170
- * **Auth:** Requires `adminKey` in client config.
171
- *
172
- * @param orgId - Organization identifier.
173
- * @param options - Optional per-request overrides.
174
- * @returns Updated organization status.
175
- * @throws {@link HivemindError} 401 if admin credentials are invalid.
176
- * @throws {@link HivemindError} 404 if the organization does not exist.
177
- *
178
- * **Endpoint:** `POST /v1/organizations/{orgId}/suspend`
179
- */
180
- suspendOrganization(orgId: string, options?: RequestOptions): Promise<ChangeOrgStatusResponse>;
181
- /**
182
- * Reactivate a suspended organization, restoring API key access.
183
- *
184
- * **Auth:** Requires `adminKey` in client config.
185
- *
186
- * @param orgId - Organization identifier.
187
- * @param options - Optional per-request overrides.
188
- * @returns Updated organization status.
189
- * @throws {@link HivemindError} 401 if admin credentials are invalid.
190
- * @throws {@link HivemindError} 404 if the organization does not exist.
191
- *
192
- * **Endpoint:** `POST /v1/organizations/{orgId}/reactivate`
193
- */
194
- reactivateOrganization(orgId: string, options?: RequestOptions): Promise<ChangeOrgStatusResponse>;
195
- /**
196
- * Permanently delete an organization and all associated data.
197
- * This action is irreversible.
198
- *
199
- * **Auth:** Requires `adminKey` in client config.
200
- *
201
- * @param orgId - Organization identifier.
202
- * @param options - Optional per-request overrides.
203
- * @throws {@link HivemindError} 401 if admin credentials are invalid.
204
- * @throws {@link HivemindError} 404 if the organization does not exist.
205
- *
206
- * **Endpoint:** `DELETE /v1/organizations/{orgId}`
207
- */
208
- deleteOrganization(orgId: string, options?: RequestOptions): Promise<void>;
209
- /**
210
- * Upload and ingest a document file (PDF, TXT, DOCX, etc.).
211
- * The document is stored in GCS, split into chunks, and embedded for RAG retrieval.
212
- *
213
- * **Auth:** Requires org-scoped API key.
214
- *
215
- * @param orgId - Organization identifier.
216
- * @param file - Document content as a `Blob` or `Buffer`.
217
- * @param filename - Original filename (e.g. `"report.pdf"`).
218
- * @param options - Optional per-request overrides (e.g. `{ apiKey }`).
219
- * @returns Upload result with document ID, chunk count, and status.
220
- * @throws {@link HivemindError} 400 if the file exceeds the maximum upload size (default 25 MB).
221
- * @throws {@link HivemindError} 401 if API key is missing or invalid.
222
- * @throws {@link HivemindError} 429 if rate limit is exceeded.
223
- *
224
- * **Endpoint:** `POST /v1/organizations/{orgId}/documents/upload`
225
- * **Content-Type:** `multipart/form-data`
226
- *
227
- * @example
228
- * ```typescript
229
- * import { readFileSync } from "fs";
230
- * const file = readFileSync("./report.pdf");
231
- * const result = await client.uploadDocument("acme-corp", file, "report.pdf");
232
- * console.log(`Uploaded: ${result.document_id}, ${result.chunks} chunks`);
233
- * ```
234
- */
235
- uploadDocument(orgId: string, file: Blob | Buffer, filename: string, options?: RequestOptions): Promise<DocumentUploadResponse>;
236
- /**
237
- * Query the organization's document knowledge base using RAG
238
- * (Retrieval-Augmented Generation). Retrieves relevant document chunks,
239
- * then generates a response with citations.
240
- *
241
- * **Auth:** Requires org-scoped API key.
242
- *
243
- * @param orgId - Organization identifier.
244
- * @param params - Query parameters (query text, model, temperature, strategy).
245
- * @param options - Optional per-request overrides (e.g. `{ apiKey }`).
246
- * @returns Generated answer with source citations, confidence, and processing time.
247
- * @throws {@link HivemindError} 401 if API key is missing or invalid.
248
- * @throws {@link HivemindError} 403 if cross-organization access is attempted.
249
- * @throws {@link HivemindError} 429 if rate limit or token quota is exceeded.
250
- *
251
- * **Endpoint:** `POST /v1/organizations/{orgId}/query`
252
- *
253
- * @example
254
- * ```typescript
255
- * const result = await client.query("acme-corp", {
256
- * query: "What are the key findings in Q4?",
257
- * temperature: 0.2,
258
- * retrieval_strategy: "hybrid",
259
- * });
260
- * console.log(result.answer);
261
- * console.log(result.sources); // citations with doc_id, chunk_id, score, snippet
262
- * ```
263
- */
264
- query(orgId: string, params: QueryParams, options?: RequestOptions): Promise<QueryResponse>;
265
- /**
266
- * Search indexed sources for source discovery.
267
- *
268
- * **Auth:** Requires org-scoped API key.
269
- *
270
- * **Endpoint:** `POST /v1/organizations/{orgId}/search`
271
- */
272
- search(orgId: string, params: SearchParams, options?: RequestOptions): Promise<SearchResponse>;
273
- createProject(orgId: string, params: ProjectCreateParams, options?: RequestOptions): Promise<ContentProject>;
274
- listProjects(orgId: string, options?: RequestOptions): Promise<ContentProjectListResponse>;
275
- getProject(orgId: string, projectId: string, options?: RequestOptions): Promise<ContentProject>;
276
- updateProject(orgId: string, projectId: string, params: ProjectUpdateParams, options?: RequestOptions): Promise<ContentProject>;
277
- deleteProject(orgId: string, projectId: string, options?: RequestOptions): Promise<void>;
278
- chatProject(orgId: string, projectId: string, params: ProjectChatParams, options?: RequestOptions): Promise<QueryResponse>;
279
- getProjectChatHistory(orgId: string, projectId: string, userId: string, options?: RequestOptions): Promise<ProjectChatHistoryResponse>;
280
- createContentItem(orgId: string, projectId: string, params: ContentItemCreateParams, options?: RequestOptions): Promise<ContentItemResponse>;
281
- listContentItems(orgId: string, projectId: string, options?: RequestOptions): Promise<ContentItemListResponse>;
282
- getContentItem(orgId: string, projectId: string, contentId: string, options?: RequestOptions): Promise<ContentItemResponse>;
283
- updateContentItem(orgId: string, projectId: string, contentId: string, params: ContentItemUpdateParams, options?: RequestOptions): Promise<ContentItemResponse>;
284
- deleteContentItem(orgId: string, projectId: string, contentId: string, options?: RequestOptions): Promise<void>;
285
- createProjectSource(orgId: string, projectId: string, params: ProjectSourceCreateParams, options?: RequestOptions): Promise<ProjectSourceResponse>;
286
- /**
287
- * Scrape external URLs and save the normalized results as project sources.
288
- *
289
- * **Auth:** Requires org-scoped API key.
290
- *
291
- * **Endpoint:** `POST /v1/organizations/{orgId}/projects/{projectId}/sources/scrape`
292
- */
293
- scrapeProjectSources(orgId: string, projectId: string, params: ProjectSourceScrapeParams, options?: RequestOptions): Promise<ProjectSourceListResponse>;
294
- listProjectSources(orgId: string, projectId: string, options?: RequestOptions): Promise<ProjectSourceListResponse>;
295
- getProjectSource(orgId: string, projectId: string, sourceId: string, options?: RequestOptions): Promise<ProjectSourceResponse>;
296
- updateProjectSource(orgId: string, projectId: string, sourceId: string, params: ProjectSourceUpdateParams, options?: RequestOptions): Promise<ProjectSourceResponse>;
297
- deleteProjectSource(orgId: string, projectId: string, sourceId: string, options?: RequestOptions): Promise<void>;
298
- /**
299
- * Create a publish schedule for an existing content item.
300
- *
301
- * **Auth:** Requires org-scoped API key.
302
- *
303
- * **Endpoint:** `POST /v1/organizations/{orgId}/projects/{projectId}/schedules`
304
- */
305
- createPublishSchedule(orgId: string, projectId: string, params: PublishScheduleCreateParams, options?: RequestOptions): Promise<PublishScheduleResponse>;
306
- /**
307
- * List publish schedules for a project.
308
- *
309
- * **Auth:** Requires org-scoped API key.
310
- *
311
- * **Endpoint:** `GET /v1/organizations/{orgId}/projects/{projectId}/schedules`
312
- */
313
- listPublishSchedules(orgId: string, projectId: string, options?: RequestOptions): Promise<PublishScheduleListResponse>;
314
- /**
315
- * Get a single publish schedule.
316
- *
317
- * **Auth:** Requires org-scoped API key.
318
- *
319
- * **Endpoint:** `GET /v1/organizations/{orgId}/projects/{projectId}/schedules/{scheduleId}`
320
- */
321
- getPublishSchedule(orgId: string, projectId: string, scheduleId: string, options?: RequestOptions): Promise<PublishScheduleResponse>;
322
- /**
323
- * Update a publish schedule.
324
- *
325
- * **Auth:** Requires org-scoped API key.
326
- *
327
- * **Endpoint:** `PATCH /v1/organizations/{orgId}/projects/{projectId}/schedules/{scheduleId}`
328
- */
329
- updatePublishSchedule(orgId: string, projectId: string, scheduleId: string, params: PublishScheduleUpdateParams, options?: RequestOptions): Promise<PublishScheduleResponse>;
330
- /**
331
- * Delete a publish schedule.
332
- *
333
- * **Auth:** Requires org-scoped API key.
334
- *
335
- * **Endpoint:** `DELETE /v1/organizations/{orgId}/projects/{projectId}/schedules/{scheduleId}`
336
- */
337
- deletePublishSchedule(orgId: string, projectId: string, scheduleId: string, options?: RequestOptions): Promise<void>;
338
- /**
339
- * Manually run due Content Creator schedules immediately.
340
- *
341
- * This is primarily an admin fallback or operational tool. In normal
342
- * deployments, due schedules are processed automatically by the backend's
343
- * background content schedule runner.
344
- *
345
- * **Auth:** Requires admin key.
346
- *
347
- * **Endpoint:** `POST /v1/admin/content-creator/schedules/run-due`
348
- */
35
+ issueApiKey(params?: ApiKeyIssueParams): Promise<ApiKeyBootstrapResponse>;
36
+ getCurrentScope(options?: RequestOptions): Promise<ApiKeyScope>;
37
+ rotateApiKey(options?: RequestOptions): Promise<ApiKeyRotateResponse>;
38
+ uploadDocument(file: Blob | Buffer, filename: string, options?: RequestOptions): Promise<DocumentUploadResponse>;
39
+ query(params: QueryParams, options?: RequestOptions): Promise<QueryResponse>;
40
+ search(params: SearchParams, options?: RequestOptions): Promise<SearchResponse>;
41
+ createProject(params: ProjectCreateParams, options?: RequestOptions): Promise<ContentProject>;
42
+ listProjects(options?: RequestOptions): Promise<ContentProjectListResponse>;
43
+ getProject(projectId: string, options?: RequestOptions): Promise<ContentProject>;
44
+ updateProject(projectId: string, params: ProjectUpdateParams, options?: RequestOptions): Promise<ContentProject>;
45
+ deleteProject(projectId: string, options?: RequestOptions): Promise<void>;
46
+ chatProject(projectId: string, params: ProjectChatParams, options?: RequestOptions): Promise<QueryResponse>;
47
+ getProjectChatHistory(projectId: string, userId: string, options?: RequestOptions): Promise<ProjectChatHistoryResponse>;
48
+ createContentItem(projectId: string, params: ContentItemCreateParams, options?: RequestOptions): Promise<ContentItemResponse>;
49
+ listContentItems(projectId: string, options?: RequestOptions): Promise<ContentItemListResponse>;
50
+ getContentItem(projectId: string, contentId: string, options?: RequestOptions): Promise<ContentItemResponse>;
51
+ updateContentItem(projectId: string, contentId: string, params: ContentItemUpdateParams, options?: RequestOptions): Promise<ContentItemResponse>;
52
+ deleteContentItem(projectId: string, contentId: string, options?: RequestOptions): Promise<void>;
53
+ createProjectSource(projectId: string, params: ProjectSourceCreateParams, options?: RequestOptions): Promise<ProjectSourceResponse>;
54
+ scrapeProjectSources(projectId: string, params: ProjectSourceScrapeParams, options?: RequestOptions): Promise<ProjectSourceListResponse>;
55
+ listProjectSources(projectId: string, options?: RequestOptions): Promise<ProjectSourceListResponse>;
56
+ getProjectSource(projectId: string, sourceId: string, options?: RequestOptions): Promise<ProjectSourceResponse>;
57
+ updateProjectSource(projectId: string, sourceId: string, params: ProjectSourceUpdateParams, options?: RequestOptions): Promise<ProjectSourceResponse>;
58
+ deleteProjectSource(projectId: string, sourceId: string, options?: RequestOptions): Promise<void>;
59
+ createPublishSchedule(projectId: string, params: PublishScheduleCreateParams, options?: RequestOptions): Promise<PublishScheduleResponse>;
60
+ listPublishSchedules(projectId: string, options?: RequestOptions): Promise<PublishScheduleListResponse>;
61
+ getPublishSchedule(projectId: string, scheduleId: string, options?: RequestOptions): Promise<PublishScheduleResponse>;
62
+ updatePublishSchedule(projectId: string, scheduleId: string, params: PublishScheduleUpdateParams, options?: RequestOptions): Promise<PublishScheduleResponse>;
63
+ deletePublishSchedule(projectId: string, scheduleId: string, options?: RequestOptions): Promise<void>;
349
64
  runDueSchedules(): Promise<ScheduleRunResultResponse>;
350
- /**
351
- * Start an asynchronous video generation job using Vertex AI Veo.
352
- * Returns a job ID — poll with `getJob()` or `waitForJob()` for results.
353
- *
354
- * **Auth:** Requires org-scoped API key.
355
- *
356
- * @param orgId - Organization identifier.
357
- * @param params - Video generation parameters (prompt, duration, aspect_ratio, style).
358
- * @param options - Optional per-request overrides.
359
- * @returns Job ID and estimated processing time (HTTP 202).
360
- * @throws {@link HivemindError} 429 if rate limit, video quota, or concurrent job limit is exceeded.
361
- *
362
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/video`
363
- *
364
- * @example
365
- * ```typescript
366
- * const job = await client.generateVideo("acme-corp", {
367
- * prompt: "A drone flyover of a mountain lake at sunset",
368
- * duration: 8,
369
- * aspect_ratio: "16:9",
370
- * style: "cinematic",
371
- * });
372
- * const result = await client.waitForJob("acme-corp", job.job_id);
373
- * console.log(result.result); // { output_url, signed_url }
374
- * ```
375
- */
376
- generateVideo(orgId: string, params: GenerateVideoParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
377
- /**
378
- * Start an asynchronous image generation job using Vertex AI Imagen.
379
- * Returns a job ID — poll with `getJob()` or `waitForJob()` for results.
380
- *
381
- * **Auth:** Requires org-scoped API key.
382
- *
383
- * @param orgId - Organization identifier.
384
- * @param params - Image generation parameters (prompt, aspect_ratio, style, num_images).
385
- * @param options - Optional per-request overrides.
386
- * @returns Job ID and estimated processing time (HTTP 202).
387
- * @throws {@link HivemindError} 429 if rate limit, image quota, or concurrent job limit is exceeded.
388
- *
389
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/image`
390
- *
391
- * @example
392
- * ```typescript
393
- * const job = await client.generateImage("acme-corp", {
394
- * prompt: "A futuristic city skyline at dusk",
395
- * aspect_ratio: "16:9",
396
- * style: "digital art",
397
- * num_images: 4,
398
- * });
399
- * const result = await client.waitForJob("acme-corp", job.job_id);
400
- * ```
401
- */
402
- generateImage(orgId: string, params: GenerateImageParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
403
- /**
404
- * Start an asynchronous music generation job.
405
- * Returns a job ID — poll with `getJob()` or `waitForJob()` for results.
406
- *
407
- * **Auth:** Requires org-scoped API key.
408
- *
409
- * **Endpoint:** `POST /v1/organizations/{orgId}/generate/music`
410
- */
411
- generateMusic(orgId: string, params: GenerateMusicParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
412
- /**
413
- * Check the status of an asynchronous job (video or image generation).
414
- *
415
- * **Auth:** Requires org-scoped API key.
416
- *
417
- * @param orgId - Organization identifier.
418
- * @param jobId - Job identifier (from `generateVideo()` or `generateImage()`).
419
- * @param options - Optional per-request overrides.
420
- * @returns Job status, result URLs (when completed), or error details (when failed).
421
- * @throws {@link HivemindError} 404 if the job does not exist.
422
- *
423
- * **Endpoint:** `GET /v1/organizations/{orgId}/jobs/{jobId}`
424
- */
425
- getJob(orgId: string, jobId: string, options?: RequestOptions): Promise<JobStatusResponse>;
426
- /**
427
- * Poll a job until it reaches a terminal status (`completed`, `failed`, or `cancelled`).
428
- *
429
- * @param orgId - Organization identifier.
430
- * @param jobId - Job identifier.
431
- * @param intervalMs - Polling interval in milliseconds. @default 2000
432
- * @param maxWaitMs - Maximum wait time in milliseconds. @default 300000 (5 min)
433
- * @param options - Optional per-request overrides.
434
- * @returns Final job status with result or error.
435
- * @throws Error if the job does not complete within `maxWaitMs`.
436
- *
437
- * @example
438
- * ```typescript
439
- * const job = await client.generateVideo("acme-corp", { prompt: "..." });
440
- * const result = await client.waitForJob("acme-corp", job.job_id, 3000, 600_000);
441
- * if (result.status === "completed") console.log(result.result);
442
- * ```
443
- */
444
- waitForJob(orgId: string, jobId: string, intervalMs?: number, maxWaitMs?: number, options?: RequestOptions): Promise<JobStatusResponse>;
445
- /**
446
- * Ask a natural-language question over BigQuery datasets.
447
- * Gemini generates SQL from the question, executes it, and returns formatted results.
448
- *
449
- * **Auth:** Requires org-scoped API key.
450
- *
451
- * @param orgId - Organization identifier.
452
- * @param params - Question and optional user ID.
453
- * @param options - Optional per-request overrides.
454
- * @returns Generated SQL, natural-language answer, and result rows.
455
- * @throws {@link HivemindError} 429 if rate limit or token quota is exceeded.
456
- *
457
- * **Endpoint:** `POST /v1/organizations/{orgId}/data-chat`
458
- *
459
- * @example
460
- * ```typescript
461
- * const result = await client.dataChat("acme-corp", {
462
- * question: "How many active users this month?",
463
- * });
464
- * console.log(result.answer); // "There are 1,247 active users this month."
465
- * console.log(result.sql); // Generated SQL
466
- * console.log(result.rows); // [{ active_users: 1247 }]
467
- * ```
468
- */
469
- dataChat(orgId: string, params: DataChatParams, options?: RequestOptions): Promise<DataChatResponse>;
470
- /**
471
- * Create a custom AI agent template with system instructions and optional tool bindings.
472
- *
473
- * **Auth:** Requires org-scoped API key.
474
- *
475
- * @param orgId - Organization identifier.
476
- * @param params - Agent name, instructions, and optional tools.
477
- * @param options - Optional per-request overrides.
478
- * @returns Created agent with ID, name, and enabled tools.
479
- *
480
- * **Endpoint:** `POST /v1/organizations/{orgId}/agents/custom`
481
- *
482
- * @example
483
- * ```typescript
484
- * const agent = await client.createAgent("acme-corp", {
485
- * name: "Support Bot",
486
- * instructions: "You are a helpful customer support agent.",
487
- * tools: ["rag_search", "ticket_create"],
488
- * });
489
- * console.log(agent.agent_id);
490
- * ```
491
- */
492
- createAgent(orgId: string, params: AgentCreateParams, options?: RequestOptions): Promise<AgentCreateResponse>;
493
- /**
494
- * Send a query to an AI agent. Routes to the specified agent type or auto-selects.
495
- *
496
- * **Auth:** Requires org-scoped API key.
497
- *
498
- * @param orgId - Organization identifier.
499
- * @param params - Query text, user ID, and optional agent type.
500
- * @param options - Optional per-request overrides.
501
- * @returns Agent response text, agent type, and any tool calls made.
502
- * @throws {@link HivemindError} 429 if rate limit or token quota is exceeded.
503
- *
504
- * **Endpoint:** `POST /v1/organizations/{orgId}/agents/query`
505
- */
506
- queryAgent(orgId: string, params: AgentQueryParams, options?: RequestOptions): Promise<AgentQueryResponse>;
507
- /**
508
- * Transcribe audio content to text (speech-to-text).
509
- *
510
- * **Auth:** Requires org-scoped API key.
511
- *
512
- * @param orgId - Organization identifier.
513
- * @param params - Audio content and optional BCP-47 language code.
514
- * @param options - Optional per-request overrides.
515
- * @returns Transcription result with transcript text, confidence, and language.
516
- * @throws {@link HivemindError} 429 if rate limit is exceeded.
517
- *
518
- * **Endpoint:** `POST /v1/organizations/{orgId}/audio/transcribe`
519
- */
520
- transcribeAudio(orgId: string, params: AudioTranscribeParams, options?: RequestOptions): Promise<AudioTranscriptionResponse>;
521
- /**
522
- * Convert text to speech (text-to-speech synthesis).
523
- * Returns a signed URL to the generated audio file.
524
- *
525
- * **Auth:** Requires org-scoped API key.
526
- *
527
- * @param orgId - Organization identifier.
528
- * @param params - Text to synthesize and optional voice name.
529
- * @param options - Optional per-request overrides.
530
- * @returns Audio URL, duration, and voice used.
531
- * @throws {@link HivemindError} 429 if rate limit is exceeded.
532
- *
533
- * **Endpoint:** `POST /v1/organizations/{orgId}/audio/synthesize`
534
- */
535
- synthesizeAudio(orgId: string, params: AudioSynthesizeParams, options?: RequestOptions): Promise<AudioSynthesizeResponse>;
536
- /**
537
- * Train a predictive model on tabular data.
538
- *
539
- * **Auth:** Requires org-scoped API key.
540
- *
541
- * @param orgId - Organization identifier.
542
- * @param params - Target column, feature columns, and training data rows.
543
- * @param options - Optional per-request overrides.
544
- * @returns Deployed model ID and status.
545
- *
546
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/train`
547
- *
548
- * @example
549
- * ```typescript
550
- * const model = await client.trainModel("acme-corp", {
551
- * target_column: "churn",
552
- * feature_columns: ["tenure", "monthly_charges", "total_charges"],
553
- * rows: [
554
- * { tenure: 12, monthly_charges: 50, total_charges: 600, churn: 0 },
555
- * { tenure: 2, monthly_charges: 80, total_charges: 160, churn: 1 },
556
- * ],
557
- * });
558
- * console.log(model.model_id); // Use with predict()
559
- * ```
560
- */
561
- trainModel(orgId: string, params: TrainModelParams, options?: RequestOptions): Promise<TrainModelResponse>;
562
- /**
563
- * Run predictions using a previously trained model.
564
- *
565
- * **Auth:** Requires org-scoped API key.
566
- *
567
- * @param orgId - Organization identifier.
568
- * @param params - Model ID and data instances to predict on.
569
- * @param options - Optional per-request overrides.
570
- * @returns Predictions for each input instance.
571
- * @throws {@link HivemindError} 404 if the model does not exist.
572
- *
573
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/predict`
574
- */
575
- predict(orgId: string, params: PredictParams, options?: RequestOptions): Promise<PredictResponse>;
576
- /**
577
- * Generate a time-series forecast from historical data using ARIMA-based modeling.
578
- *
579
- * **Auth:** Requires org-scoped API key.
580
- *
581
- * @param orgId - Organization identifier.
582
- * @param params - Historical series values and optional forecast horizon (1–365).
583
- * @param options - Optional per-request overrides.
584
- * @returns Predicted future values.
585
- *
586
- * **Endpoint:** `POST /v1/organizations/{orgId}/analytics/forecast`
587
- */
588
- forecast(orgId: string, params: ForecastParams, options?: RequestOptions): Promise<ForecastResponse>;
589
- /**
590
- * Get the monthly usage summary for an organization.
591
- * Includes token, image, video, storage, and compute usage against tier limits.
592
- *
593
- * **Auth:** Requires org-scoped API key.
594
- *
595
- * @param orgId - Organization identifier.
596
- * @param month - Month in `YYYY-MM` format. Defaults to current month.
597
- * @param options - Optional per-request overrides.
598
- * @returns Usage counters, tier limits, and quota status.
599
- *
600
- * **Endpoint:** `GET /v1/organizations/{orgId}/usage?month={month}`
601
- */
602
- getUsage(orgId: string, month?: string, options?: RequestOptions): Promise<UsageSummaryResponse>;
603
- /**
604
- * Get the monthly invoice with detailed cost breakdown by resource type.
605
- *
606
- * **Auth:** Requires org-scoped API key.
607
- *
608
- * @param orgId - Organization identifier.
609
- * @param month - Month in `YYYY-MM` format. Defaults to current month.
610
- * @param options - Optional per-request overrides.
611
- * @returns Invoice with itemized costs and total in USD.
612
- *
613
- * **Endpoint:** `GET /v1/organizations/{orgId}/invoice?month={month}`
614
- */
615
- getInvoice(orgId: string, month?: string, options?: RequestOptions): Promise<InvoiceResponse>;
616
- /**
617
- * Retrieve audit log records for an organization.
618
- *
619
- * **Auth:** Requires org-scoped API key.
620
- *
621
- * @param orgId - Organization identifier.
622
- * @param options - Optional per-request overrides.
623
- * @returns Audit log entries with timestamps, actions, and metadata.
624
- *
625
- * **Endpoint:** `GET /v1/organizations/{orgId}/audit`
626
- */
627
- getAuditLogs(orgId: string, options?: RequestOptions): Promise<AuditLogResponse>;
628
- /**
629
- * Get the current scraping runtime configuration.
630
- *
631
- * **Auth:** None required.
632
- *
633
- * @returns Execution mode, Cloud Run status, and cache statistics.
634
- *
635
- * **Endpoint:** `GET /v1/scraping/config`
636
- */
65
+ generateVideo(params: GenerateVideoParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
66
+ generateImage(params: GenerateImageParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
67
+ generateMusic(params: GenerateMusicParams, options?: RequestOptions): Promise<JobAcceptedResponse>;
68
+ getJob(jobId: string, options?: RequestOptions): Promise<JobStatusResponse>;
69
+ waitForJob(jobId: string, intervalMs?: number, maxWaitMs?: number, options?: RequestOptions): Promise<JobStatusResponse>;
70
+ dataChat(params: DataChatParams, options?: RequestOptions): Promise<DataChatResponse>;
71
+ createAgent(params: AgentCreateParams, options?: RequestOptions): Promise<AgentCreateResponse>;
72
+ queryAgent(params: AgentQueryParams, options?: RequestOptions): Promise<AgentQueryResponse>;
73
+ transcribeAudio(params: AudioTranscribeParams, options?: RequestOptions): Promise<AudioTranscriptionResponse>;
74
+ synthesizeAudio(params: AudioSynthesizeParams, options?: RequestOptions): Promise<AudioSynthesizeResponse>;
75
+ trainModel(params: TrainModelParams, options?: RequestOptions): Promise<TrainModelResponse>;
76
+ predict(params: PredictParams, options?: RequestOptions): Promise<PredictResponse>;
77
+ forecast(params: ForecastParams, options?: RequestOptions): Promise<ForecastResponse>;
78
+ getAuditLogs(options?: RequestOptions): Promise<AuditLogResponse>;
637
79
  getScrapingConfig(): Promise<ScrapingConfigResponse>;
638
- /**
639
- * Submit URLs for scraping. JS-heavy sites (Reddit, Twitter, LinkedIn)
640
- * are auto-routed to Selenium.
641
- *
642
- * **Auth:** None required.
643
- *
644
- * @param params - Object containing the `urls` array.
645
- * @returns Task ID and submission status.
646
- *
647
- * **Endpoint:** `POST /v1/scraping/scrape`
648
- */
649
80
  scrape(params: ScrapeParams): Promise<ScrapeResponse>;
650
- /**
651
- * Check the status and results of a scrape task.
652
- *
653
- * **Auth:** None required.
654
- *
655
- * @param taskId - Task identifier (from `scrape()`).
656
- * @returns Task status and scraped results (empty while pending).
657
- *
658
- * **Endpoint:** `GET /v1/scraping/status/{taskId}`
659
- */
660
81
  getScrapeStatus(taskId: string): Promise<ScrapeStatusResponse>;
661
- /**
662
- * Submit a scrape job and poll until results are ready.
663
- *
664
- * @param urls - URLs to scrape.
665
- * @param intervalMs - Polling interval in milliseconds. @default 2000
666
- * @param maxWaitMs - Maximum wait time in milliseconds. @default 120000 (2 min)
667
- * @returns Final scrape status with results.
668
- * @throws Error if the task does not complete within `maxWaitMs`.
669
- *
670
- * @example
671
- * ```typescript
672
- * const result = await client.scrapeAndWait(
673
- * ["https://example.com", "https://example.org"],
674
- * 2000,
675
- * 60_000,
676
- * );
677
- * for (const item of result.result) {
678
- * console.log(item.title, item.full_text?.substring(0, 200));
679
- * }
680
- * ```
681
- */
682
82
  scrapeAndWait(urls: string[], intervalMs?: number, maxWaitMs?: number): Promise<ScrapeStatusResponse>;
683
- /**
684
- * Send a video generation completion webhook notification.
685
- *
686
- * **Auth:** Requires `webhookSecret` in client config (sends `X-Webhook-Secret` header).
687
- *
688
- * @param payload - Webhook payload with job_id, org_id, status, and optional metadata.
689
- * @returns `{ received: true }` on success.
690
- * @throws {@link HivemindError} 401 if the webhook secret is invalid.
691
- *
692
- * **Endpoint:** `POST /v1/webhook/video-complete`
693
- */
694
83
  sendVideoCompleteWebhook(payload: VideoCompleteWebhook): Promise<WebhookAckResponse>;
695
- /**
696
- * Send a document processing completion webhook notification.
697
- *
698
- * **Auth:** Requires `webhookSecret` in client config (sends `X-Webhook-Secret` header).
699
- *
700
- * @param payload - Webhook payload with document_id, org_id, status, and optional metadata.
701
- * @returns `{ received: true }` on success.
702
- * @throws {@link HivemindError} 401 if the webhook secret is invalid.
703
- *
704
- * **Endpoint:** `POST /v1/webhook/document-processed`
705
- */
706
84
  sendDocumentProcessedWebhook(payload: DocumentProcessedWebhook): Promise<WebhookAckResponse>;
707
- /**
708
- * Get full service configuration overview.
709
- *
710
- * **Auth:** Requires `adminKey` in client config.
711
- *
712
- * **Endpoint:** `GET /v1/admin/config`
713
- */
714
85
  getAdminConfig(): Promise<ConfigOverview>;
715
- /**
716
- * Get runtime setting overrides.
717
- *
718
- * **Auth:** Requires `adminKey` in client config.
719
- *
720
- * **Endpoint:** `GET /v1/admin/config/overrides`
721
- */
722
86
  getAdminConfigOverrides(): Promise<{
723
87
  overrides: Record<string, unknown>;
724
88
  }>;
725
- /**
726
- * Update a mutable runtime setting (e.g. log_level, debug, cors_allow_origins).
727
- *
728
- * **Auth:** Requires `adminKey` in client config.
729
- *
730
- * @param params - Setting key and new value.
731
- *
732
- * **Endpoint:** `PUT /v1/admin/settings`
733
- */
734
89
  updateAdminSetting(params: UpdateSettingRequest): Promise<UpdateSettingResponse>;
735
- /**
736
- * Get the current application log level.
737
- *
738
- * **Auth:** Requires `adminKey` in client config.
739
- *
740
- * **Endpoint:** `GET /v1/admin/logging/level`
741
- */
742
90
  getLogLevel(): Promise<LogLevelResponse>;
743
- /**
744
- * Change the application log level.
745
- *
746
- * **Auth:** Requires `adminKey` in client config.
747
- *
748
- * @param params - The new log level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
749
- *
750
- * **Endpoint:** `PUT /v1/admin/logging/level`
751
- */
752
91
  setLogLevel(params: LogLevelRequest): Promise<LogLevelResponse>;
753
- /**
754
- * List all loggers with their levels and handlers.
755
- *
756
- * **Auth:** Requires `adminKey` in client config.
757
- *
758
- * **Endpoint:** `GET /v1/admin/logging/loggers`
759
- */
760
92
  getLoggers(): Promise<{
761
93
  loggers: LoggerInfo[];
762
94
  }>;
763
- /**
764
- * Get inbound traffic statistics.
765
- *
766
- * **Auth:** Requires `adminKey` in client config.
767
- *
768
- * **Endpoint:** `GET /v1/admin/traffic/inbound`
769
- */
770
95
  getInboundTraffic(): Promise<InboundTrafficStats>;
771
- /**
772
- * Reset inbound traffic counters.
773
- *
774
- * **Auth:** Requires `adminKey` in client config.
775
- *
776
- * **Endpoint:** `POST /v1/admin/traffic/inbound/reset`
777
- */
778
96
  resetInboundTraffic(): Promise<{
779
97
  status: string;
780
98
  timestamp: string;
781
99
  }>;
782
- /**
783
- * Check health of outbound dependencies (GCP, Vertex, BigQuery, Redis).
784
- *
785
- * **Auth:** Requires `adminKey` in client config.
786
- *
787
- * **Endpoint:** `GET /v1/admin/traffic/outbound`
788
- */
789
100
  getOutboundStatus(): Promise<OutboundStatusResponse>;
790
- /**
791
- * Get the current CORS allowed origins.
792
- *
793
- * **Auth:** Requires `adminKey` in client config.
794
- *
795
- * **Endpoint:** `GET /v1/admin/cors`
796
- */
797
101
  getCors(): Promise<{
798
102
  allow_origins: string[];
799
103
  }>;
800
- /**
801
- * Update the CORS allowed origins.
802
- *
803
- * **Auth:** Requires `adminKey` in client config.
804
- *
805
- * @param allowOrigins - Comma-separated origins or `"*"`.
806
- *
807
- * **Endpoint:** `PUT /v1/admin/cors`
808
- */
809
104
  setCors(allowOrigins: string): Promise<{
810
105
  previous: string;
811
106
  new: string;
812
107
  note: string;
813
108
  }>;
814
- /**
815
- * List all rate-limit entries.
816
- *
817
- * **Auth:** Requires `adminKey` in client config.
818
- *
819
- * **Endpoint:** `GET /v1/admin/rate-limits`
820
- */
821
109
  getRateLimits(): Promise<{
822
110
  rate_limits: RateLimitEntry[];
823
111
  }>;
824
- /**
825
- * Reset the rate-limit counter for an organization.
826
- *
827
- * **Auth:** Requires `adminKey` in client config.
828
- *
829
- * @param orgId - Organization identifier.
830
- *
831
- * **Endpoint:** `POST /v1/admin/rate-limits/reset/{orgId}`
832
- */
833
- resetRateLimit(orgId: string): Promise<{
834
- org_id: string;
112
+ resetRateLimit(scopeId: string): Promise<{
113
+ scope_id: string;
835
114
  status: string;
836
115
  }>;
837
- /**
838
- * List all organizations (admin view).
839
- *
840
- * **Auth:** Requires `adminKey` in client config.
841
- *
842
- * @param limit - Maximum number of organizations to return (1–1000, default 100).
843
- *
844
- * **Endpoint:** `GET /v1/admin/organizations`
845
- */
846
- listOrganizations(limit?: number): Promise<OrgListResponse>;
847
- /**
848
- * Get a single organization (admin view).
849
- *
850
- * **Auth:** Requires `adminKey` in client config.
851
- *
852
- * @param orgId - Organization identifier.
853
- *
854
- * **Endpoint:** `GET /v1/admin/organizations/{orgId}`
855
- */
856
- getAdminOrganization(orgId: string): Promise<Organization>;
857
- /**
858
- * List recent jobs across all organizations (admin view).
859
- *
860
- * **Auth:** Requires `adminKey` in client config.
861
- *
862
- * @param limit - Maximum number of jobs to return (1–500, default 50).
863
- *
864
- * **Endpoint:** `GET /v1/admin/jobs`
865
- */
866
116
  listJobs(limit?: number): Promise<JobListResponse>;
867
- /**
868
- * Get all feature flags.
869
- *
870
- * **Auth:** Requires `adminKey` in client config.
871
- *
872
- * **Endpoint:** `GET /v1/admin/feature-flags`
873
- */
874
117
  getFeatureFlags(): Promise<{
875
118
  flags: Record<string, unknown>;
876
119
  }>;
877
- /**
878
- * Get a single feature flag by key.
879
- *
880
- * **Auth:** Requires `adminKey` in client config.
881
- *
882
- * @param key - Feature flag key.
883
- *
884
- * **Endpoint:** `GET /v1/admin/feature-flags/{key}`
885
- */
886
120
  getFeatureFlag(key: string): Promise<FeatureFlag>;
887
- /**
888
- * Create or update a feature flag.
889
- *
890
- * **Auth:** Requires `adminKey` in client config.
891
- *
892
- * @param params - Flag key and enabled status.
893
- *
894
- * **Endpoint:** `PUT /v1/admin/feature-flags`
895
- */
896
121
  setFeatureFlag(params: FeatureFlagUpdate): Promise<FeatureFlag>;
897
- /**
898
- * Delete a feature flag.
899
- *
900
- * **Auth:** Requires `adminKey` in client config.
901
- *
902
- * @param key - Feature flag key to delete.
903
- *
904
- * **Endpoint:** `DELETE /v1/admin/feature-flags/{key}`
905
- */
906
122
  deleteFeatureFlag(key: string): Promise<{
907
123
  key: string;
908
124
  deleted: boolean;
909
125
  }>;
910
- /**
911
- * Get current maintenance mode state.
912
- *
913
- * **Auth:** Requires `adminKey` in client config.
914
- *
915
- * **Endpoint:** `GET /v1/admin/maintenance`
916
- */
917
126
  getMaintenanceMode(): Promise<MaintenanceModeResponse>;
918
- /**
919
- * Enable or disable maintenance mode.
920
- *
921
- * **Auth:** Requires `adminKey` in client config.
922
- *
923
- * @param params - Enabled flag and optional message.
924
- *
925
- * **Endpoint:** `PUT /v1/admin/maintenance`
926
- */
927
127
  setMaintenanceMode(params: MaintenanceModeRequest): Promise<MaintenanceModeResponse>;
928
- /**
929
- * Get cache statistics.
930
- *
931
- * **Auth:** Requires `adminKey` in client config.
932
- *
933
- * **Endpoint:** `GET /v1/admin/cache`
934
- */
935
128
  getCacheStats(): Promise<CacheStatsResponse>;
936
- /**
937
- * Flush all caches.
938
- *
939
- * **Auth:** Requires `adminKey` in client config.
940
- *
941
- * **Endpoint:** `POST /v1/admin/cache/flush`
942
- */
943
129
  flushCache(): Promise<{
944
130
  status: string;
945
131
  backend: string;
946
132
  }>;
947
- /**
948
- * Get all tier configurations.
949
- *
950
- * **Auth:** Requires `adminKey` in client config.
951
- *
952
- * **Endpoint:** `GET /v1/admin/tiers`
953
- */
954
- getTiers(): Promise<{
955
- tiers: TierConfigResponse[];
956
- }>;
957
- /**
958
- * Get current pricing configuration.
959
- *
960
- * **Auth:** Requires `adminKey` in client config.
961
- *
962
- * **Endpoint:** `GET /v1/admin/pricing`
963
- */
964
- getPricing(): Promise<PricingResponse>;
965
- /**
966
- * Get admin-level audit log entries.
967
- *
968
- * **Auth:** Requires `adminKey` in client config.
969
- *
970
- * @param limit - Maximum entries to return (1–1000, default 100).
971
- *
972
- * **Endpoint:** `GET /v1/admin/audit`
973
- */
974
133
  getAdminAudit(limit?: number): Promise<AdminAuditResponse>;
975
- /**
976
- * Get system information (Python version, platform, architecture, PID, etc.).
977
- *
978
- * **Auth:** Requires `adminKey` in client config.
979
- *
980
- * **Endpoint:** `GET /v1/admin/system`
981
- */
982
134
  getSystemInfo(): Promise<Record<string, unknown>>;
983
- /**
984
- * Connect a Jira Cloud site using an API token.
985
- * Validates credentials, registers a webhook, and stores the encrypted token.
986
- *
987
- * **Auth:** Requires org-scoped API key.
988
- *
989
- * @param orgId - Organization identifier.
990
- * @param params - Jira connection details (site_url, email, api_token).
991
- * @param options - Optional per-request overrides.
992
- *
993
- * **Endpoint:** `POST /v1/organizations/{orgId}/integrations/jira/connect`
994
- */
995
- connectJira(orgId: string, params: JiraConnectRequest, options?: RequestOptions): Promise<JiraConnectResponse>;
996
- /**
997
- * Get the current Jira integration status for an organization.
998
- *
999
- * **Auth:** Requires org-scoped API key.
1000
- *
1001
- * @param orgId - Organization identifier.
1002
- * @param options - Optional per-request overrides.
1003
- *
1004
- * **Endpoint:** `GET /v1/organizations/{orgId}/integrations/jira/status`
1005
- */
1006
- getJiraStatus(orgId: string, options?: RequestOptions): Promise<JiraIntegrationStatusResponse>;
1007
- /**
1008
- * Disconnect (unlink) an organization's Jira integration.
1009
- * Deregisters the webhook and deletes stored credentials.
1010
- *
1011
- * **Auth:** Requires org-scoped API key.
1012
- *
1013
- * @param orgId - Organization identifier.
1014
- * @param options - Optional per-request overrides.
1015
- *
1016
- * **Endpoint:** `DELETE /v1/organizations/{orgId}/integrations/jira`
1017
- */
1018
- disconnectJira(orgId: string, options?: RequestOptions): Promise<JiraDisconnectResponse>;
1019
- /**
1020
- * Trigger a bulk sync of Jira issues from specified projects into the
1021
- * document store for RAG retrieval.
1022
- *
1023
- * **Auth:** Requires org-scoped API key.
1024
- *
1025
- * @param orgId - Organization identifier.
1026
- * @param params - Object containing `project_keys` array.
1027
- * @param options - Optional per-request overrides.
1028
- *
1029
- * **Endpoint:** `POST /v1/organizations/{orgId}/integrations/jira/sync`
1030
- */
1031
- syncJira(orgId: string, params: JiraSyncRequest, options?: RequestOptions): Promise<JiraSyncResponse>;
1032
- /**
1033
- * Send a Jira webhook event manually.
1034
- *
1035
- * **Auth:** Requires `webhookSecret` in client config.
1036
- *
1037
- * @param payload - Jira webhook payload (issue, webhookEvent, etc.).
1038
- *
1039
- * **Endpoint:** `POST /v1/webhook/jira`
1040
- */
135
+ connectJira(params: JiraConnectRequest, options?: RequestOptions): Promise<JiraConnectResponse>;
136
+ getJiraStatus(options?: RequestOptions): Promise<JiraIntegrationStatusResponse>;
137
+ disconnectJira(options?: RequestOptions): Promise<JiraDisconnectResponse>;
138
+ syncJira(params: JiraSyncRequest, options?: RequestOptions): Promise<JiraSyncResponse>;
1041
139
  sendJiraWebhook(payload: Record<string, unknown>): Promise<JiraWebhookAckResponse>;
1042
- /**
1043
- * Create a new document blueprint (template).
1044
- *
1045
- * **Auth:** Requires org-scoped API key.
1046
- *
1047
- * @param orgId - Organization ID.
1048
- * @param params - Blueprint details (name, sections, workflow_config, etc.).
1049
- *
1050
- * **Endpoint:** `POST /v1/organizations/{orgId}/blueprints`
1051
- */
1052
- createBlueprint(orgId: string, params: BlueprintCreateParams, options?: RequestOptions): Promise<BlueprintResponse>;
1053
- /**
1054
- * List all blueprints for an organization.
1055
- *
1056
- * **Auth:** Requires org-scoped API key.
1057
- *
1058
- * @param orgId - Organization ID.
1059
- *
1060
- * **Endpoint:** `GET /v1/organizations/{orgId}/blueprints`
1061
- */
1062
- listBlueprints(orgId: string, options?: RequestOptions): Promise<BlueprintListResponse>;
1063
- /**
1064
- * Get a single blueprint by ID.
1065
- *
1066
- * **Auth:** Requires org-scoped API key.
1067
- *
1068
- * @param orgId - Organization ID.
1069
- * @param blueprintId - Blueprint ID.
1070
- *
1071
- * **Endpoint:** `GET /v1/organizations/{orgId}/blueprints/{blueprintId}`
1072
- */
1073
- getBlueprint(orgId: string, blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
1074
- /**
1075
- * Update an existing blueprint. Only provided fields are changed.
1076
- *
1077
- * **Auth:** Requires org-scoped API key.
1078
- *
1079
- * @param orgId - Organization ID.
1080
- * @param blueprintId - Blueprint ID.
1081
- * @param params - Fields to update.
1082
- *
1083
- * **Endpoint:** `PUT /v1/organizations/{orgId}/blueprints/{blueprintId}`
1084
- */
1085
- updateBlueprint(orgId: string, blueprintId: string, params: BlueprintUpdateParams, options?: RequestOptions): Promise<BlueprintResponse>;
1086
- /**
1087
- * Publish a blueprint, making it available for document creation.
1088
- *
1089
- * **Auth:** Requires org-scoped API key.
1090
- *
1091
- * @param orgId - Organization ID.
1092
- * @param blueprintId - Blueprint ID.
1093
- *
1094
- * **Endpoint:** `POST /v1/organizations/{orgId}/blueprints/{blueprintId}/publish`
1095
- */
1096
- publishBlueprint(orgId: string, blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
1097
- /**
1098
- * Archive a blueprint, preventing new documents from being created from it.
1099
- *
1100
- * **Auth:** Requires org-scoped API key.
1101
- *
1102
- * @param orgId - Organization ID.
1103
- * @param blueprintId - Blueprint ID.
1104
- *
1105
- * **Endpoint:** `POST /v1/organizations/{orgId}/blueprints/{blueprintId}/archive`
1106
- */
1107
- archiveBlueprint(orgId: string, blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
1108
- /**
1109
- * Permanently delete a blueprint.
1110
- *
1111
- * **Auth:** Requires org-scoped API key.
1112
- *
1113
- * @param orgId - Organization ID.
1114
- * @param blueprintId - Blueprint ID.
1115
- *
1116
- * **Endpoint:** `DELETE /v1/organizations/{orgId}/blueprints/{blueprintId}`
1117
- */
1118
- deleteBlueprint(orgId: string, blueprintId: string, options?: RequestOptions): Promise<void>;
1119
- /**
1120
- * Create a new managed document from a published blueprint.
1121
- *
1122
- * **Auth:** Requires org-scoped API key.
1123
- *
1124
- * @param orgId - Organization ID.
1125
- * @param params - Document details (blueprint_id, title, sections, etc.).
1126
- *
1127
- * **Endpoint:** `POST /v1/organizations/{orgId}/documents/create`
1128
- */
1129
- createDocumentFromBlueprint(orgId: string, params: DocumentCreateFromBlueprintParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
1130
- /**
1131
- * List all managed documents for an organization.
1132
- *
1133
- * **Auth:** Requires org-scoped API key.
1134
- *
1135
- * @param orgId - Organization ID.
1136
- *
1137
- * **Endpoint:** `GET /v1/organizations/{orgId}/documents/managed`
1138
- */
1139
- listManagedDocuments(orgId: string, options?: RequestOptions): Promise<ManagedDocumentListResponse>;
1140
- /**
1141
- * Get a single managed document by ID.
1142
- *
1143
- * **Auth:** Requires org-scoped API key.
1144
- *
1145
- * @param orgId - Organization ID.
1146
- * @param documentId - Document ID.
1147
- *
1148
- * **Endpoint:** `GET /v1/organizations/{orgId}/documents/managed/{documentId}`
1149
- */
1150
- getManagedDocument(orgId: string, documentId: string, options?: RequestOptions): Promise<ManagedDocumentResponse>;
1151
- /**
1152
- * Update the content of a document section. Only allowed in draft/revision status.
1153
- *
1154
- * **Auth:** Requires org-scoped API key.
1155
- *
1156
- * @param orgId - Organization ID.
1157
- * @param documentId - Document ID.
1158
- * @param params - Section ID and new content.
1159
- *
1160
- * **Endpoint:** `PATCH /v1/organizations/{orgId}/documents/managed/{documentId}/sections`
1161
- */
1162
- updateDocumentSection(orgId: string, documentId: string, params: DocumentUpdateSectionParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
1163
- /**
1164
- * Perform a workflow action on a managed document.
1165
- *
1166
- * Actions: submit, approve, reject, request_changes, seal.
1167
- *
1168
- * **Auth:** Requires org-scoped API key.
1169
- *
1170
- * @param orgId - Organization ID.
1171
- * @param documentId - Document ID.
1172
- * @param params - Action type and optional comment.
1173
- *
1174
- * **Endpoint:** `POST /v1/organizations/{orgId}/documents/managed/{documentId}/workflow`
1175
- */
1176
- performDocumentWorkflow(orgId: string, documentId: string, params: DocumentWorkflowActionParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
1177
- /**
1178
- * Permanently delete a managed document.
1179
- *
1180
- * **Auth:** Requires org-scoped API key.
1181
- *
1182
- * @param orgId - Organization ID.
1183
- * @param documentId - Document ID.
1184
- *
1185
- * **Endpoint:** `DELETE /v1/organizations/{orgId}/documents/managed/{documentId}`
1186
- */
1187
- deleteManagedDocument(orgId: string, documentId: string, options?: RequestOptions): Promise<void>;
1188
- /**
1189
- * AI-generate content for a document section using the blueprint's AI rules.
1190
- *
1191
- * **Auth:** Requires org-scoped API key.
1192
- *
1193
- * @param orgId - Organization ID.
1194
- * @param documentId - Document ID.
1195
- * @param params - Section ID and optional context for generation.
1196
- *
1197
- * **Endpoint:** `POST /v1/organizations/{orgId}/documents/managed/{documentId}/generate`
1198
- */
1199
- generateDocumentSection(orgId: string, documentId: string, params: DocumentGenerateSectionParams, options?: RequestOptions): Promise<DocumentGenerateResponse>;
1200
- /**
1201
- * Chat inside a content project using Server-Sent Events.
1202
- * Returns an async iterator of typed {@link ChatStreamEvent} objects.
1203
- *
1204
- * **Auth:** Requires org-scoped API key.
1205
- *
1206
- * **Endpoint:** `POST /v1/organizations/{orgId}/projects/{projectId}/chat/stream`
1207
- *
1208
- * @example
1209
- * ```typescript
1210
- * for await (const evt of client.chatProjectSse("acme", "proj-1", {
1211
- * message: "Summarize our sources",
1212
- * user_id: "u1",
1213
- * })) {
1214
- * if (evt.event === "done") console.log(evt.data.answer);
1215
- * }
1216
- * ```
1217
- */
1218
- chatProjectSse(orgId: string, projectId: string, params: ProjectChatParams, options?: RequestOptions): AsyncGenerator<ChatStreamEvent, void, undefined>;
1219
- /**
1220
- * Open a WebSocket to the project chat endpoint and return a
1221
- * convenience handle for sending commands and receiving frames.
1222
- *
1223
- * **Auth:** API key is sent as `?api_key=` query param (browser-safe).
1224
- *
1225
- * **Endpoint:** `WS /v1/organizations/{orgId}/projects/{projectId}/chat/ws`
1226
- *
1227
- * @example
1228
- * ```typescript
1229
- * const ws = await client.chatProjectWebSocket("acme", "proj-1");
1230
- * const frame = await ws.chat({ message: "Hello", user_id: "u1" });
1231
- * if (frame.type === "result") console.log(frame.payload.answer);
1232
- * ws.close();
1233
- * ```
1234
- */
1235
- chatProjectWebSocket(orgId: string, projectId: string, options?: RequestOptions & {
140
+ createBlueprint(params: BlueprintCreateParams, options?: RequestOptions): Promise<BlueprintResponse>;
141
+ listBlueprints(options?: RequestOptions): Promise<BlueprintListResponse>;
142
+ getBlueprint(blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
143
+ updateBlueprint(blueprintId: string, params: BlueprintUpdateParams, options?: RequestOptions): Promise<BlueprintResponse>;
144
+ publishBlueprint(blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
145
+ archiveBlueprint(blueprintId: string, options?: RequestOptions): Promise<BlueprintResponse>;
146
+ deleteBlueprint(blueprintId: string, options?: RequestOptions): Promise<void>;
147
+ createDocumentFromBlueprint(params: DocumentCreateFromBlueprintParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
148
+ listManagedDocuments(options?: RequestOptions): Promise<ManagedDocumentListResponse>;
149
+ getManagedDocument(documentId: string, options?: RequestOptions): Promise<ManagedDocumentResponse>;
150
+ updateDocumentSection(documentId: string, params: DocumentUpdateSectionParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
151
+ performDocumentWorkflow(documentId: string, params: DocumentWorkflowActionParams, options?: RequestOptions): Promise<ManagedDocumentResponse>;
152
+ deleteManagedDocument(documentId: string, options?: RequestOptions): Promise<void>;
153
+ generateDocumentSection(documentId: string, params: DocumentGenerateSectionParams, options?: RequestOptions): Promise<DocumentGenerateResponse>;
154
+ chatProjectSse(projectId: string, params: ProjectChatParams, options?: RequestOptions): AsyncGenerator<ChatStreamEvent, void, undefined>;
155
+ chatProjectWebSocket(projectId: string, options?: RequestOptions & {
1236
156
  signal?: AbortSignal;
1237
157
  }): Promise<{
1238
- /** The underlying WebSocket instance. */
1239
158
  raw: WebSocket;
1240
- /** Send a chat command and wait for the server response frame. */
1241
- chat(params: Omit<WsChatCommand, "type">): Promise<WsChatFrame>;
1242
- /** Gracefully close the connection. */
159
+ chat(params: Omit<WsChatCommand, "type">): Promise<import("./types").WsChatFrame>;
1243
160
  close(code?: number, reason?: string): void;
1244
161
  }>;
1245
162
  }