orqo-node-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,547 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/%40orqo%2Fsdk-v0.1.0-7c3aed?style=for-the-badge&logo=typescript&logoColor=white" alt="version" />
3
+ <img src="https://img.shields.io/badge/zero--deps-✓-10b981?style=for-the-badge" alt="zero deps" />
4
+ <img src="https://img.shields.io/badge/TypeScript-strict-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript strict" />
5
+ <img src="https://img.shields.io/badge/license-MIT-f59e0b?style=for-the-badge" alt="license" />
6
+ </p>
7
+
8
+ <h1 align="center">🎯 Orqo SDK</h1>
9
+
10
+ <p align="center">
11
+ <strong>The official TypeScript SDK for the Orqo AI Agent Gateway.</strong><br/>
12
+ Provision instances, connect WhatsApp, manage agents, and orchestrate<br/>
13
+ conversations — all from a single, type-safe package with <b>zero runtime dependencies</b>.
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="#-quick-start">Quick Start</a> •
18
+ <a href="#-api-reference">API Reference</a> •
19
+ <a href="#-webhook-handler">Webhook Handler</a> •
20
+ <a href="#-api-bridge">API Bridge</a> •
21
+ <a href="#%EF%B8%8F-resilience">Resilience</a> •
22
+ <a href="#-architecture">Architecture</a>
23
+ </p>
24
+
25
+ ---
26
+
27
+ ## ✨ Features
28
+
29
+ | Feature | Description |
30
+ |---------|-------------|
31
+ | 🚀 **Plug-and-Play** | Provision → Connect → Send in 5 lines of code |
32
+ | 🔒 **Type-Safe** | Full TypeScript coverage with strict mode — every method, every event |
33
+ | 📦 **Zero Dependencies** | Only `globalThis.fetch` — works in Node.js 18+, Bun, Deno, and Edge |
34
+ | 🔁 **Retry & Resilience** | Exponential backoff with configurable retry on 429/5xx |
35
+ | 🪝 **Webhook Handler** | HMAC-verified, typed event dispatch for Express/Hono/Fastify/Node |
36
+ | 🤖 **Agent Management** | Full CRUD for AI agents with system prompts and tool bindings |
37
+ | 🔌 **API Bridge** | Connect any OpenAPI spec and the agent gains tools automatically |
38
+ | ⏰ **Cron Jobs** | Schedule recurring actions per instance |
39
+ | 🤝 **Handoff** | Bot ↔ Human session transfer with metadata |
40
+
41
+ ---
42
+
43
+ ## 📦 Installation
44
+
45
+ ```bash
46
+ npm install @orqo/sdk
47
+ ```
48
+
49
+ > **Requirements:** Node.js 18+ (or any runtime with `globalThis.fetch`)
50
+
51
+ ---
52
+
53
+ ## 🚀 Quick Start
54
+
55
+ ### 1. Provision an Instance
56
+
57
+ ```typescript
58
+ import { OrqoClient } from '@orqo/sdk';
59
+
60
+ const orqo = new OrqoClient({
61
+ host: 'https://gateway.orqo.ai',
62
+ adminToken: process.env.ORQO_ADMIN_TOKEN!,
63
+ });
64
+
65
+ const { instance, result } = await orqo.provision({
66
+ name: 'My Support Bot',
67
+ webhookUrl: 'https://my-app.com/webhooks/orqo',
68
+ webhookSecret: process.env.WEBHOOK_SECRET,
69
+ });
70
+
71
+ console.log(`✅ Instance ${result.instanceId} created`);
72
+ ```
73
+
74
+ ### 2. Connect WhatsApp
75
+
76
+ ```typescript
77
+ // Wait for QR scan with live feedback
78
+ await instance.waitForConnection({
79
+ onQr: (qr) => console.log('📱 Scan this QR:', qr),
80
+ timeoutMs: 120_000,
81
+ });
82
+
83
+ console.log('🟢 WhatsApp connected!');
84
+ ```
85
+
86
+ ### 3. Send a Message
87
+
88
+ ```typescript
89
+ await instance.sendMessage({
90
+ to: '5511999887766@s.whatsapp.net',
91
+ text: 'Hello from Orqo! 🚀',
92
+ });
93
+ ```
94
+
95
+ ### 4. Receive Events
96
+
97
+ ```typescript
98
+ import { createWebhookHandler } from '@orqo/sdk';
99
+
100
+ app.post('/webhooks/orqo', createWebhookHandler({
101
+ secret: process.env.WEBHOOK_SECRET,
102
+ onMessageReceived: async (event) => {
103
+ console.log(`💬 ${event.from}: ${event.text}`);
104
+ },
105
+ onConnectionChanged: (event) => {
106
+ console.log(`📡 ${event.state}`);
107
+ },
108
+ }));
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 📖 API Reference
114
+
115
+ ### `OrqoClient` — Admin Operations
116
+
117
+ > Requires `adminToken`. Used for instance lifecycle management.
118
+
119
+ ```typescript
120
+ const orqo = new OrqoClient({ host, adminToken });
121
+ ```
122
+
123
+ | Method | Returns | Description |
124
+ |--------|---------|-------------|
125
+ | `provision(options)` | `{ instance, result }` | Create instance + boot WhatsApp |
126
+ | `listInstances()` | `InstanceStatus[]` | List all instances |
127
+ | `getInstance(id, token)` | `OrqoInstance` | Get handle for existing instance |
128
+ | `deleteInstance(id)` | `void` | Delete an instance |
129
+
130
+ ---
131
+
132
+ ### `OrqoInstance` — Instance Operations
133
+
134
+ > Scoped to a single instance. All methods auto-retry on 429/5xx.
135
+
136
+ #### WhatsApp
137
+
138
+ | Method | Returns | Description |
139
+ |--------|---------|-------------|
140
+ | `getWhatsAppStatus()` | `WhatsAppStatus` | Connection state + QR code |
141
+ | `connectWhatsApp()` | `InstanceStatus` | Start WhatsApp socket |
142
+ | `disconnectWhatsApp()` | `void` | Disconnect WhatsApp |
143
+ | `reconnectWhatsApp()` | `InstanceStatus` | Force reconnect (stale connections) |
144
+ | `pairByPhone(phone)` | `{ code }` | Phone-number pairing code |
145
+ | `waitForConnection(opts?)` | `WhatsAppStatus` | Poll until connected (with QR callback) |
146
+
147
+ #### Messaging
148
+
149
+ | Method | Returns | Description |
150
+ |--------|---------|-------------|
151
+ | `sendMessage({ to, text })` | `SendMessageResult` | Send a text message |
152
+ | `getMessages(opts?)` | `Record[]` | Retrieve messages (with sessionKey filter) |
153
+ | `getSessions(opts?)` | `Record[]` | List conversation sessions |
154
+
155
+ #### Agents
156
+
157
+ | Method | Returns | Description |
158
+ |--------|---------|-------------|
159
+ | `createAgent(config)` | `Agent` | Create an AI agent |
160
+ | `listAgents()` | `Agent[]` | List all agents |
161
+ | `getAgent(id)` | `Agent` | Get agent by ID |
162
+ | `updateAgent(id, updates)` | `Agent` | Patch agent config |
163
+ | `deleteAgent(id)` | `void` | Remove an agent |
164
+
165
+ #### Webhooks
166
+
167
+ | Method | Returns | Description |
168
+ |--------|---------|-------------|
169
+ | `addWebhook({ url, event, secret? })` | `Webhook` | Register a webhook |
170
+ | `listWebhooks()` | `Webhook[]` | List registered webhooks |
171
+ | `removeWebhook(id)` | `void` | Unregister a webhook |
172
+
173
+ #### Guardrails
174
+
175
+ | Method | Returns | Description |
176
+ |--------|---------|-------------|
177
+ | `setGuardrails(config)` | `GuardrailConfig` | Set AI response rules |
178
+ | `getGuardrails()` | `GuardrailConfig` | Get current guardrail config |
179
+
180
+ #### Session Handoff
181
+
182
+ | Method | Returns | Description |
183
+ |--------|---------|-------------|
184
+ | `handoffToHuman(options)` | `HandoffResult` | Transfer session to human agent |
185
+ | `resumeBot(sessionId)` | `HandoffResult` | Return session to bot control |
186
+
187
+ #### Cron Jobs
188
+
189
+ | Method | Returns | Description |
190
+ |--------|---------|-------------|
191
+ | `listCronJobs()` | `Record[]` | List scheduled jobs |
192
+ | `createCronJob(config)` | `Record` | Schedule a recurring job |
193
+ | `deleteCronJob(id)` | `void` | Remove a scheduled job |
194
+ | `runCronJob(id)` | `Record` | Trigger a job manually |
195
+
196
+ #### API Bridge
197
+
198
+ | Method | Returns | Description |
199
+ |--------|---------|-------------|
200
+ | `connectApi(options)` | `{ bridge, tools }` | Connect an OpenAPI spec |
201
+ | `listApiBridges()` | `Array` | List connected bridges |
202
+ | `removeApiBridge(id)` | `{ success }` | Disconnect a bridge |
203
+ | `refreshApiBridge(id)` | `{ bridge, tools }` | Re-fetch spec & update tools |
204
+
205
+ #### Monitoring
206
+
207
+ | Method | Returns | Description |
208
+ |--------|---------|-------------|
209
+ | `getStatus()` | `InstanceStatus` | Instance health & metadata |
210
+ | `getStats()` | `Record` | Messages, sessions, uptime |
211
+
212
+ ---
213
+
214
+ ## 🪝 Webhook Handler
215
+
216
+ The `createWebhookHandler()` function provides a framework-agnostic webhook receiver with **HMAC signature verification** and **typed event dispatch**.
217
+
218
+ ### Express
219
+
220
+ ```typescript
221
+ import express from 'express';
222
+ import { createWebhookHandler } from '@orqo/sdk';
223
+
224
+ const app = express();
225
+ app.use(express.json());
226
+
227
+ app.post('/webhooks/orqo', createWebhookHandler({
228
+ secret: process.env.WEBHOOK_SECRET,
229
+ onConnectionChanged: (e) => {
230
+ console.log(`${e.instanceId}: ${e.state}`);
231
+ },
232
+ onMessageReceived: async (e) => {
233
+ console.log(`From ${e.from}: ${e.text}`);
234
+ // Process message...
235
+ },
236
+ onMessageProcessed: (e) => {
237
+ console.log(`AI processed: ${e.messageId}`);
238
+ },
239
+ onHandoff: (e) => {
240
+ console.log(`Handoff: session ${e.sessionId}`);
241
+ },
242
+ onEvent: (e) => {
243
+ // Catch-all for any event type
244
+ },
245
+ onVerificationFailed: (err) => {
246
+ console.error('⚠️ Invalid signature:', err.message);
247
+ },
248
+ }));
249
+ ```
250
+
251
+ ### Hono
252
+
253
+ ```typescript
254
+ import { Hono } from 'hono';
255
+ import { createWebhookHandler } from '@orqo/sdk';
256
+
257
+ const app = new Hono();
258
+
259
+ app.post('/webhooks/orqo', async (c) => {
260
+ const handler = createWebhookHandler({
261
+ secret: c.env.WEBHOOK_SECRET,
262
+ onMessageReceived: async (e) => {
263
+ console.log(`${e.from}: ${e.text}`);
264
+ },
265
+ });
266
+ await handler(
267
+ { body: await c.req.json(), headers: c.req.raw.headers },
268
+ { status: (s) => ({ json: (b) => c.json(b, s) }) },
269
+ );
270
+ return c.body(null, 200);
271
+ });
272
+ ```
273
+
274
+ ### Event Types
275
+
276
+ | Event | Interface | Trigger |
277
+ |-------|-----------|---------|
278
+ | `connection:changed` | `ConnectionChangedEvent` | WhatsApp connects/disconnects |
279
+ | `message:received` | `MessageReceivedEvent` | New incoming message |
280
+ | `message:processed` | `MessageProcessedEvent` | AI finishes processing |
281
+ | `session:handoff` | `HandoffEvent` | Session transferred to human |
282
+
283
+ ### Security
284
+
285
+ - **HMAC-SHA256** signature verification (`X-Webhook-Signature` header)
286
+ - **Dual runtime**: Web Crypto API (browser/edge) + Node.js `crypto` fallback
287
+ - **Timing-safe** string comparison to prevent timing attacks
288
+
289
+ ---
290
+
291
+ ## 🔌 API Bridge
292
+
293
+ Connect any external REST API via its OpenAPI spec. The AI agent automatically gains typed tools from the spec endpoints.
294
+
295
+ ```typescript
296
+ // Connect your CRM API — agent instantly gets tools like
297
+ // "crm_getContact", "crm_createLead", "crm_updateDeal"
298
+ await instance.connectApi({
299
+ name: 'salesforce',
300
+ specUrl: 'https://api.salesforce.com/openapi.json',
301
+ auth: { type: 'bearer', token: process.env.SF_TOKEN },
302
+ description: 'CRM for sales pipeline management',
303
+ });
304
+
305
+ // Connect a payments API
306
+ await instance.connectApi({
307
+ name: 'stripe',
308
+ specUrl: 'https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json',
309
+ auth: { type: 'bearer', token: process.env.STRIPE_KEY },
310
+ });
311
+
312
+ // List what's connected
313
+ const bridges = await instance.listApiBridges();
314
+ console.log(bridges.map(b => `${b.name}: ${b.tools.length} tools`));
315
+ ```
316
+
317
+ ### Auth Types
318
+
319
+ | Type | Fields | Example |
320
+ |------|--------|---------|
321
+ | `bearer` | `token` | `{ type: 'bearer', token: 'sk-...' }` |
322
+ | `apiKey` | `token`, `headerName` | `{ type: 'apiKey', token: 'key', headerName: 'X-API-Key' }` |
323
+ | `basic` | `username`, `password` | `{ type: 'basic', username: 'u', password: 'p' }` |
324
+ | `custom` | `headers` | `{ type: 'custom', headers: { 'X-Custom': 'val' } }` |
325
+
326
+ ### Security
327
+
328
+ The API Bridge includes built-in **SSRF prevention**:
329
+ - Blocks private/loopback/metadata IP addresses
330
+ - Validates URL protocols (http/https only)
331
+ - Limits spec size (2MB), operations (100), bridges per instance (10)
332
+ - Blocks redirect-based attacks
333
+
334
+ ---
335
+
336
+ ## 🛡️ Resilience
337
+
338
+ All HTTP methods include automatic retry with exponential backoff:
339
+
340
+ ```typescript
341
+ const orqo = new OrqoClient({
342
+ host: 'https://gateway.orqo.ai',
343
+ adminToken: 'token',
344
+ retry: {
345
+ maxAttempts: 5, // default: 3
346
+ backoffMs: 500, // default: 1000
347
+ multiplier: 2, // default: 2
348
+ retryOn: [429, 503], // default: [429, 500, 502, 503, 504]
349
+ },
350
+ });
351
+ ```
352
+
353
+ The retry config cascades from `OrqoClient` → `OrqoInstance`, so all instance methods inherit the same resilience settings.
354
+
355
+ ### Backoff Timeline (defaults)
356
+
357
+ ```
358
+ Attempt 1 → immediate
359
+ Attempt 2 → wait 1000ms
360
+ Attempt 3 → wait 2000ms
361
+ Attempt 4 → wait 4000ms (if maxAttempts > 3)
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 🤝 Complete Workflow Example
367
+
368
+ ```typescript
369
+ import { OrqoClient, createWebhookHandler } from '@orqo/sdk';
370
+ import express from 'express';
371
+
372
+ // ── 1. Setup ─────────────────────────────────────────────
373
+ const orqo = new OrqoClient({
374
+ host: process.env.ORQO_HOST!,
375
+ adminToken: process.env.ORQO_ADMIN_TOKEN!,
376
+ });
377
+
378
+ // ── 2. Provision ─────────────────────────────────────────
379
+ const { instance } = await orqo.provision({
380
+ name: 'Customer Support',
381
+ webhookUrl: 'https://my-app.com/webhooks/orqo',
382
+ webhookSecret: process.env.WEBHOOK_SECRET,
383
+ });
384
+
385
+ // ── 3. Configure Agent ───────────────────────────────────
386
+ await instance.createAgent({
387
+ name: 'Support Agent',
388
+ type: 'chat',
389
+ systemPrompt: `You are a helpful customer support agent.
390
+ Be concise and professional. If you cannot resolve
391
+ the issue, hand off to a human agent.`,
392
+ tools: ['knowledge-base', 'ticket-system'],
393
+ });
394
+
395
+ // ── 4. Set Guardrails ────────────────────────────────────
396
+ await instance.setGuardrails({
397
+ blockedTopics: ['competitor-pricing', 'internal-processes'],
398
+ maxResponseLength: 500,
399
+ filterPII: true,
400
+ });
401
+
402
+ // ── 5. Connect External APIs ─────────────────────────────
403
+ await instance.connectApi({
404
+ name: 'zendesk',
405
+ specUrl: 'https://api.zendesk.com/openapi.json',
406
+ auth: { type: 'bearer', token: process.env.ZENDESK_TOKEN },
407
+ });
408
+
409
+ // ── 6. Connect WhatsApp ──────────────────────────────────
410
+ await instance.waitForConnection({
411
+ onQr: (qr) => sendQrToAdmin(qr),
412
+ });
413
+
414
+ // ── 7. Receive Events ────────────────────────────────────
415
+ const app = express();
416
+ app.use(express.json());
417
+
418
+ app.post('/webhooks/orqo', createWebhookHandler({
419
+ secret: process.env.WEBHOOK_SECRET,
420
+ onMessageReceived: async (e) => {
421
+ console.log(`💬 ${e.pushName}: ${e.text}`);
422
+ },
423
+ onHandoff: async (e) => {
424
+ await notifyHumanAgent(e.sessionId, e.reason);
425
+ },
426
+ }));
427
+
428
+ // ── 8. Schedule Reminders ────────────────────────────────
429
+ await instance.createCronJob({
430
+ schedule: '0 9 * * 1', // Every Monday at 9am
431
+ action: 'send-weekly-summary',
432
+ payload: { channel: 'admin' },
433
+ });
434
+
435
+ app.listen(3000, () => console.log('🚀 Running on :3000'));
436
+ ```
437
+
438
+ ---
439
+
440
+ ## 🏗 Architecture
441
+
442
+ ```
443
+ ┌──────────────────────────────────────────────────────────────┐
444
+ │ @orqo/sdk │
445
+ ├──────────────┬─────────────────┬─────────────────────────────┤
446
+ │ OrqoClient │ OrqoInstance │ createWebhookHandler() │
447
+ │ (Admin) │ (Per-instance) │ (Event receiver) │
448
+ │ │ │ │
449
+ │ provision() │ 30 methods │ HMAC verification │
450
+ │ listInst() │ WhatsApp │ Typed event dispatch │
451
+ │ deleteInst()│ Agents │ Express/Hono/Fastify │
452
+ │ getInst() │ Webhooks │ Web Crypto + Node.js │
453
+ │ │ Guardrails │ │
454
+ │ │ Handoff │ │
455
+ │ │ API Bridge │ │
456
+ │ │ Cron Jobs │ │
457
+ │ │ Stats/Messages │ │
458
+ ├──────────────┴─────────────────┴─────────────────────────────┤
459
+ │ Retry / Resilience Layer │
460
+ │ Exponential backoff • Configurable • Cascading │
461
+ ├──────────────────────────────────────────────────────────────┤
462
+ │ globalThis.fetch (zero deps) │
463
+ │ Node.js 18+ • Bun • Deno • Cloudflare Workers │
464
+ └──────────────────────────────────────────────────────────────┘
465
+ │ │
466
+ ▼ ▼
467
+ ┌──────────────┐ ┌──────────────────┐
468
+ │ Orqo Gateway │ │ Your HTTP Server │
469
+ │ REST API │ │ Webhook Events │
470
+ └──────────────┘ └──────────────────┘
471
+ ```
472
+
473
+ ---
474
+
475
+ ## 📋 Type Exports
476
+
477
+ All types are exported from the main entry point:
478
+
479
+ ```typescript
480
+ import type {
481
+ // Config
482
+ OrqoClientConfig,
483
+ OrqoInstanceConfig,
484
+ RetryConfig,
485
+
486
+ // Provisioning
487
+ ProvisionOptions,
488
+ ProvisionResult,
489
+
490
+ // WhatsApp
491
+ WhatsAppStatus,
492
+ SendMessageOptions,
493
+ SendMessageResult,
494
+
495
+ // Instance
496
+ InstanceStatus,
497
+
498
+ // Agents
499
+ AgentConfig,
500
+ Agent,
501
+
502
+ // Webhooks
503
+ WebhookConfig,
504
+ Webhook,
505
+
506
+ // Guardrails
507
+ GuardrailConfig,
508
+
509
+ // Handoff
510
+ HandoffOptions,
511
+ HandoffResult,
512
+
513
+ // Events
514
+ WebhookEvent,
515
+ ConnectionChangedEvent,
516
+ MessageReceivedEvent,
517
+ MessageProcessedEvent,
518
+ HandoffEvent,
519
+ OrqoWebhookEvent,
520
+ WebhookHandlerOptions,
521
+ } from '@orqo/sdk';
522
+ ```
523
+
524
+ ---
525
+
526
+ ## 🔧 Runtime Compatibility
527
+
528
+ | Runtime | Version | Status |
529
+ |---------|---------|--------|
530
+ | Node.js | 18+ | ✅ Full support |
531
+ | Bun | 1.0+ | ✅ Full support |
532
+ | Deno | 1.28+ | ✅ Full support |
533
+ | Cloudflare Workers | — | ✅ Full support |
534
+ | Vercel Edge | — | ✅ Full support |
535
+ | Browser | — | ⚠️ CORS-dependent |
536
+
537
+ ---
538
+
539
+ ## 📄 License
540
+
541
+ [MIT](LICENSE) — Use it however you want.
542
+
543
+ ---
544
+
545
+ <p align="center">
546
+ <sub>Built with 💜 by the Orqo team. Zero dependencies. Maximum developer happiness.</sub>
547
+ </p>
package/README.pdf ADDED
Binary file
@@ -0,0 +1,64 @@
1
+ /**
2
+ * OrqoClient — Admin-level client for the Orqo Gateway.
3
+ *
4
+ * Provides methods for managing instances (create, list, provision)
5
+ * using the Admin Token. Individual instances are represented by
6
+ * the OrqoInstance class.
7
+ */
8
+ import type { OrqoClientConfig, ProvisionOptions, ProvisionResult, InstanceStatus } from './types.js';
9
+ import { OrqoInstance } from './instance.js';
10
+ export declare class OrqoClient {
11
+ private readonly host;
12
+ private readonly adminToken;
13
+ private readonly _fetch;
14
+ private readonly retry;
15
+ constructor(config: OrqoClientConfig);
16
+ private request;
17
+ /** List all instances. */
18
+ listInstances(): Promise<InstanceStatus[]>;
19
+ /**
20
+ * Quick-Provision: Create an instance, boot WhatsApp, and return QR code
21
+ * in a single call. Returns an OrqoInstance ready for interaction.
22
+ */
23
+ provision(options: ProvisionOptions): Promise<{
24
+ instance: OrqoInstance;
25
+ result: ProvisionResult;
26
+ }>;
27
+ /**
28
+ * Get an OrqoInstance handle for an existing instance.
29
+ * Does NOT validate the instance exists — use listInstances() first.
30
+ */
31
+ getInstance(instanceId: string, apiToken: string): OrqoInstance;
32
+ /**
33
+ * Delete an instance.
34
+ */
35
+ deleteInstance(instanceId: string): Promise<void>;
36
+ /** Search instances by query string. */
37
+ searchInstances(query: string): Promise<InstanceStatus[]>;
38
+ /** Get a single instance by ID (admin detail view). */
39
+ getInstanceById(instanceId: string): Promise<InstanceStatus>;
40
+ /** Update instance metadata (name, etc). */
41
+ updateInstance(instanceId: string, updates: Record<string, unknown>): Promise<InstanceStatus>;
42
+ /** Get full instance settings. */
43
+ getInstanceSettings(instanceId: string): Promise<Record<string, unknown>>;
44
+ /** Update instance settings. */
45
+ updateInstanceSettings(instanceId: string, settings: Record<string, unknown>): Promise<Record<string, unknown>>;
46
+ /** Rotate API token for an instance. Returns the new token. */
47
+ rotateToken(instanceId: string): Promise<{
48
+ apiToken: string;
49
+ }>;
50
+ /** Delete a contact's data (LGPD/GDPR DSR). */
51
+ deleteContact(instanceId: string, contactId: string): Promise<void>;
52
+ /** Generate a full instance configuration using AI. */
53
+ generateInstanceConfig(config: {
54
+ instanceName: string;
55
+ description?: string;
56
+ context: string;
57
+ language?: string;
58
+ }): Promise<Record<string, unknown>>;
59
+ /** Rotate (re-generate) a secret by key. Returns the new secret value. */
60
+ rotateSecret(secretKey: string): Promise<{
61
+ key: string;
62
+ rotatedAt: string;
63
+ }>;
64
+ }