mitra-interactions-sdk 1.0.60-beta.25 → 1.0.60-beta.26
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 +4 -4
- package/dist/index.d.mts +26 -10
- package/dist/index.d.ts +26 -10
- package/dist/index.js +226 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -246,7 +246,7 @@ const result2 = await listRecordsMitra({
|
|
|
246
246
|
|
|
247
247
|
## Agent Chat (copilot)
|
|
248
248
|
|
|
249
|
-
Chat com o agente de IA embarcado. **REST-first
|
|
249
|
+
Chat com o agente de IA embarcado. **REST-first, tudo pela BFF no `baseURL` normal** (`/agentAiShortcut/*` — herda `fetchWithRefresh` e CORS): chats (`createChat`/`listChats`/`readChat`/`renameChat`/`deleteChat`), histórico (`listChatMessages`), credenciais e modelos. `projectId` obrigatório em todas (opcional na chamada se veio do `configureSdkMitra`). **Só o prompt é streaming** — um WebSocket por task em `wss://{origin}/copilot/ws/tasks/{taskId}?token=JWT`, aberto pela SDK quando a conversa começa (WS não passa por preflight de CORS).
|
|
250
250
|
|
|
251
251
|
Precisa de `token` e `baseURL` configurados (o login já deixa pronto). O transporte do prompt aceita `transport: 'ws' | 'http'` — `'ws'` é o default; `'http'` é reservado pra ambientes serverless e hoje lança erro claro (o backend ainda não expõe prompt por HTTP).
|
|
252
252
|
|
|
@@ -265,12 +265,12 @@ const deleted = await manageAgentChatMitra({ action: 'delete', taskId }); // ar
|
|
|
265
265
|
```
|
|
266
266
|
|
|
267
267
|
- `action: 'list'` → `AgentChat[]` — `{ id, name, agentType, agentId, archived, createdAt, updatedAt }`. Filtros: `agentId?`, `archived?`, `search?`, `page?`, `size?`.
|
|
268
|
-
- `action: 'rename'` → `{ taskId, name }` (
|
|
269
|
-
- `action: 'delete'` → `{ taskId, deleted }` (
|
|
268
|
+
- `action: 'rename'` → `{ taskId, name }` (POST `/agentAiShortcut/renameChat`)
|
|
269
|
+
- `action: 'delete'` → `{ taskId, deleted }` (POST `/agentAiShortcut/deleteChat` — arquiva, o histórico não é destruído)
|
|
270
270
|
|
|
271
271
|
### Abrir uma session — `getAgentTaskMitra`
|
|
272
272
|
|
|
273
|
-
Retorna uma `AgentTaskSession` que encapsula o ciclo de vida do chat. A task é criada via
|
|
273
|
+
Retorna uma `AgentTaskSession` que encapsula o ciclo de vida do chat. A task é criada via BFF (`POST /agentAiShortcut/createChat`) no primeiro `send()`; o WS da task conecta em seguida. Abrir a mesma `taskId` duas vezes devolve a **mesma** instância (cache).
|
|
274
274
|
|
|
275
275
|
```typescript
|
|
276
276
|
import { getAgentTaskMitra } from 'mitra-interactions-sdk';
|
package/dist/index.d.mts
CHANGED
|
@@ -222,6 +222,8 @@ interface AgentMessage {
|
|
|
222
222
|
type ChatManageAction = 'list' | 'rename' | 'delete';
|
|
223
223
|
interface ManageAgentChatListOptions {
|
|
224
224
|
action: 'list';
|
|
225
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
226
|
+
projectId?: number | string;
|
|
225
227
|
/** Filtra os chats de um agente business específico. Omitido = todos os chats. */
|
|
226
228
|
agentId?: string;
|
|
227
229
|
/** Inclui só arquivados (true) ou só ativos (false, default). */
|
|
@@ -237,10 +239,14 @@ interface ManageAgentChatRenameOptions {
|
|
|
237
239
|
action: 'rename';
|
|
238
240
|
taskId: string;
|
|
239
241
|
name: string;
|
|
242
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
243
|
+
projectId?: number | string;
|
|
240
244
|
}
|
|
241
245
|
interface ManageAgentChatDeleteOptions {
|
|
242
246
|
action: 'delete';
|
|
243
247
|
taskId: string;
|
|
248
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
249
|
+
projectId?: number | string;
|
|
244
250
|
}
|
|
245
251
|
type ManageAgentChatOptions = ManageAgentChatListOptions | ManageAgentChatRenameOptions | ManageAgentChatDeleteOptions;
|
|
246
252
|
interface RenameAgentChatResult {
|
|
@@ -259,8 +265,10 @@ interface DeleteAgentChatResult {
|
|
|
259
265
|
*/
|
|
260
266
|
type AgentTaskTransport = 'ws' | 'http';
|
|
261
267
|
interface GetAgentTaskCreateOptions {
|
|
262
|
-
/** Cria chat novo. A task é criada via
|
|
268
|
+
/** Cria chat novo. A task é criada via BFF no primeiro send(). */
|
|
263
269
|
create: true;
|
|
270
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
271
|
+
projectId?: number | string;
|
|
264
272
|
/** Tipo/modelo do agente (de list_models). Default: 'ANTHROPIC_CLAUDE_OPUS'. */
|
|
265
273
|
agentType?: AgentType;
|
|
266
274
|
/** Nome/título do chat. */
|
|
@@ -278,6 +286,8 @@ interface GetAgentTaskCreateOptions {
|
|
|
278
286
|
interface GetAgentTaskOpenOptions {
|
|
279
287
|
/** Abre chat existente. */
|
|
280
288
|
taskId: string;
|
|
289
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
290
|
+
projectId?: number | string;
|
|
281
291
|
/** Transporte do prompt (default 'ws'). */
|
|
282
292
|
transport?: AgentTaskTransport;
|
|
283
293
|
}
|
|
@@ -538,11 +548,15 @@ declare function exchangeSsoCodeMitra(options: {
|
|
|
538
548
|
}): Promise<LoginResponse>;
|
|
539
549
|
|
|
540
550
|
/**
|
|
541
|
-
* Mitra Interactions SDK — Agent Chat (
|
|
551
|
+
* Mitra Interactions SDK — Agent Chat (via BFF)
|
|
552
|
+
*
|
|
553
|
+
* REST-first, tudo pela BFF no baseURL normal (`/agentAiShortcut/*`) — herda
|
|
554
|
+
* fetchWithRefresh e o CORS do BFF. Envelope `{ status, result }`; listas vêm
|
|
555
|
+
* desembrulhadas do Page (result é o array direto).
|
|
542
556
|
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
557
|
+
* SÓ o prompt é streaming: WebSocket por task em
|
|
558
|
+
* `wss://{origin}/copilot/ws/tasks/{taskId}?token=JWT` (não passa por
|
|
559
|
+
* preflight de CORS).
|
|
546
560
|
*
|
|
547
561
|
* API pública:
|
|
548
562
|
* - manageAgentChatMitra({ action: 'list' | 'rename' | 'delete', ... })
|
|
@@ -550,10 +564,12 @@ declare function exchangeSsoCodeMitra(options: {
|
|
|
550
564
|
*/
|
|
551
565
|
|
|
552
566
|
/**
|
|
553
|
-
* Gerencia a coleção de chats do usuário — tudo HTTP:
|
|
554
|
-
* - list → GET
|
|
555
|
-
* - rename →
|
|
556
|
-
* - delete →
|
|
567
|
+
* Gerencia a coleção de chats do usuário — tudo HTTP via BFF:
|
|
568
|
+
* - list → GET /agentAiShortcut/listChats (filtros: agentId, archived, search, page, size)
|
|
569
|
+
* - rename → POST /agentAiShortcut/renameChat
|
|
570
|
+
* - delete → POST /agentAiShortcut/deleteChat (arquiva; some da lista default)
|
|
571
|
+
*
|
|
572
|
+
* `projectId` é obrigatório (opcional na chamada se configurado no configureSdkMitra).
|
|
557
573
|
*
|
|
558
574
|
* @example
|
|
559
575
|
* const chats = await manageAgentChatMitra({ action: 'list' });
|
|
@@ -566,7 +582,7 @@ declare function manageAgentChatMitra(options: ManageAgentChatRenameOptions): Pr
|
|
|
566
582
|
declare function manageAgentChatMitra(options: ManageAgentChatDeleteOptions): Promise<DeleteAgentChatResult>;
|
|
567
583
|
/**
|
|
568
584
|
* Abre um handle de chat (session). Use:
|
|
569
|
-
* - `{ create: true }` para iniciar um chat novo (a task é criada via
|
|
585
|
+
* - `{ create: true }` para iniciar um chat novo (a task é criada via BFF no 1º send)
|
|
570
586
|
* - `{ taskId: 'X' }` para abrir um chat existente
|
|
571
587
|
*
|
|
572
588
|
* A session expõe histórico, streaming, fila, cancel e eventos. Se a
|
package/dist/index.d.ts
CHANGED
|
@@ -222,6 +222,8 @@ interface AgentMessage {
|
|
|
222
222
|
type ChatManageAction = 'list' | 'rename' | 'delete';
|
|
223
223
|
interface ManageAgentChatListOptions {
|
|
224
224
|
action: 'list';
|
|
225
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
226
|
+
projectId?: number | string;
|
|
225
227
|
/** Filtra os chats de um agente business específico. Omitido = todos os chats. */
|
|
226
228
|
agentId?: string;
|
|
227
229
|
/** Inclui só arquivados (true) ou só ativos (false, default). */
|
|
@@ -237,10 +239,14 @@ interface ManageAgentChatRenameOptions {
|
|
|
237
239
|
action: 'rename';
|
|
238
240
|
taskId: string;
|
|
239
241
|
name: string;
|
|
242
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
243
|
+
projectId?: number | string;
|
|
240
244
|
}
|
|
241
245
|
interface ManageAgentChatDeleteOptions {
|
|
242
246
|
action: 'delete';
|
|
243
247
|
taskId: string;
|
|
248
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
249
|
+
projectId?: number | string;
|
|
244
250
|
}
|
|
245
251
|
type ManageAgentChatOptions = ManageAgentChatListOptions | ManageAgentChatRenameOptions | ManageAgentChatDeleteOptions;
|
|
246
252
|
interface RenameAgentChatResult {
|
|
@@ -259,8 +265,10 @@ interface DeleteAgentChatResult {
|
|
|
259
265
|
*/
|
|
260
266
|
type AgentTaskTransport = 'ws' | 'http';
|
|
261
267
|
interface GetAgentTaskCreateOptions {
|
|
262
|
-
/** Cria chat novo. A task é criada via
|
|
268
|
+
/** Cria chat novo. A task é criada via BFF no primeiro send(). */
|
|
263
269
|
create: true;
|
|
270
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
271
|
+
projectId?: number | string;
|
|
264
272
|
/** Tipo/modelo do agente (de list_models). Default: 'ANTHROPIC_CLAUDE_OPUS'. */
|
|
265
273
|
agentType?: AgentType;
|
|
266
274
|
/** Nome/título do chat. */
|
|
@@ -278,6 +286,8 @@ interface GetAgentTaskCreateOptions {
|
|
|
278
286
|
interface GetAgentTaskOpenOptions {
|
|
279
287
|
/** Abre chat existente. */
|
|
280
288
|
taskId: string;
|
|
289
|
+
/** Obrigatório (opcional na chamada se configurado via configureSdkMitra). */
|
|
290
|
+
projectId?: number | string;
|
|
281
291
|
/** Transporte do prompt (default 'ws'). */
|
|
282
292
|
transport?: AgentTaskTransport;
|
|
283
293
|
}
|
|
@@ -538,11 +548,15 @@ declare function exchangeSsoCodeMitra(options: {
|
|
|
538
548
|
}): Promise<LoginResponse>;
|
|
539
549
|
|
|
540
550
|
/**
|
|
541
|
-
* Mitra Interactions SDK — Agent Chat (
|
|
551
|
+
* Mitra Interactions SDK — Agent Chat (via BFF)
|
|
552
|
+
*
|
|
553
|
+
* REST-first, tudo pela BFF no baseURL normal (`/agentAiShortcut/*`) — herda
|
|
554
|
+
* fetchWithRefresh e o CORS do BFF. Envelope `{ status, result }`; listas vêm
|
|
555
|
+
* desembrulhadas do Page (result é o array direto).
|
|
542
556
|
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
557
|
+
* SÓ o prompt é streaming: WebSocket por task em
|
|
558
|
+
* `wss://{origin}/copilot/ws/tasks/{taskId}?token=JWT` (não passa por
|
|
559
|
+
* preflight de CORS).
|
|
546
560
|
*
|
|
547
561
|
* API pública:
|
|
548
562
|
* - manageAgentChatMitra({ action: 'list' | 'rename' | 'delete', ... })
|
|
@@ -550,10 +564,12 @@ declare function exchangeSsoCodeMitra(options: {
|
|
|
550
564
|
*/
|
|
551
565
|
|
|
552
566
|
/**
|
|
553
|
-
* Gerencia a coleção de chats do usuário — tudo HTTP:
|
|
554
|
-
* - list → GET
|
|
555
|
-
* - rename →
|
|
556
|
-
* - delete →
|
|
567
|
+
* Gerencia a coleção de chats do usuário — tudo HTTP via BFF:
|
|
568
|
+
* - list → GET /agentAiShortcut/listChats (filtros: agentId, archived, search, page, size)
|
|
569
|
+
* - rename → POST /agentAiShortcut/renameChat
|
|
570
|
+
* - delete → POST /agentAiShortcut/deleteChat (arquiva; some da lista default)
|
|
571
|
+
*
|
|
572
|
+
* `projectId` é obrigatório (opcional na chamada se configurado no configureSdkMitra).
|
|
557
573
|
*
|
|
558
574
|
* @example
|
|
559
575
|
* const chats = await manageAgentChatMitra({ action: 'list' });
|
|
@@ -566,7 +582,7 @@ declare function manageAgentChatMitra(options: ManageAgentChatRenameOptions): Pr
|
|
|
566
582
|
declare function manageAgentChatMitra(options: ManageAgentChatDeleteOptions): Promise<DeleteAgentChatResult>;
|
|
567
583
|
/**
|
|
568
584
|
* Abre um handle de chat (session). Use:
|
|
569
|
-
* - `{ create: true }` para iniciar um chat novo (a task é criada via
|
|
585
|
+
* - `{ create: true }` para iniciar um chat novo (a task é criada via BFF no 1º send)
|
|
570
586
|
* - `{ taskId: 'X' }` para abrir um chat existente
|
|
571
587
|
*
|
|
572
588
|
* A session expõe histórico, streaming, fila, cancel e eventos. Se a
|