mitra-interactions-sdk 1.0.60-beta.26 → 1.0.60-beta.28
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 +5 -7
- package/dist/index.d.mts +23 -17
- package/dist/index.d.ts +23 -17
- package/dist/index.js +87 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -278
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -275,11 +275,9 @@ Retorna uma `AgentTaskSession` que encapsula o ciclo de vida do chat. A task é
|
|
|
275
275
|
```typescript
|
|
276
276
|
import { getAgentTaskMitra } from 'mitra-interactions-sdk';
|
|
277
277
|
|
|
278
|
-
// Chat novo —
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
// Chat com um agente business (system prompt + SFs do agente; token escopado)
|
|
282
|
-
const sales = getAgentTaskMitra({ create: true, agentId: 'uuid-do-agente' });
|
|
278
|
+
// Chat novo — SEMPRE com agentId (sessão sem agente não executa nada).
|
|
279
|
+
// taskId é preenchido no primeiro send() (evento taskCreated)
|
|
280
|
+
const session = getAgentTaskMitra({ create: true, agentId: 'uuid-do-agente', agentType: 'ANTHROPIC_CLAUDE_OPUS', name: 'Meu chat' });
|
|
283
281
|
|
|
284
282
|
// Chat existente
|
|
285
283
|
const existing = getAgentTaskMitra({ taskId: 'uuid-da-task' });
|
|
@@ -289,7 +287,7 @@ await existing.loadHistory({ limit: 50 });
|
|
|
289
287
|
`getAgentTaskMitra({ create: true, agentType?, name?, agentId?, transport? })` ou `getAgentTaskMitra({ taskId, transport? })`.
|
|
290
288
|
|
|
291
289
|
- `agentType` vem de `manageAgentCredentialMitra({ action: 'list_models' })` — ex.: `'ANTHROPIC_CLAUDE_OPUS'`, `'OPENAI_GPT5'`, `'GOOGLE_GEMINI_PRO'`. Default: `'ANTHROPIC_CLAUDE_OPUS'`.
|
|
292
|
-
- **`agentId`**: id de um agente business (CRUD via `mitra-sdk`: `listAgentsMitra` e família). A sessão sobe com o system prompt do agente e um token escopado — as tools enxergam só as Server Functions dele. Sem `agentId
|
|
290
|
+
- **`agentId`**: id de um agente business (CRUD via `mitra-sdk`: `listAgentsMitra` e família). A sessão sobe com o system prompt do agente e um token escopado — as tools enxergam só as Server Functions dele. **Sem `agentId`: sessão business sem agente** — sem system prompt e sem acesso às Server Functions (as tools recusam); não há adoção automática de agente único. Na prática, sempre passe `agentId`.
|
|
293
291
|
|
|
294
292
|
#### Propriedades (somente leitura)
|
|
295
293
|
|
|
@@ -318,7 +316,7 @@ await existing.loadHistory({ limit: 50 });
|
|
|
318
316
|
`statusChange` · `historyLoaded` · `taskCreated` · `turnStart` · `delta` (`{ delta, kind: 'text' | 'thinking' }`) · `tool` (`{ tool, toolId?, input?, content?, phase: 'call' | 'result' }`) · `turnEnd` (`{ content }`) · `cancelled` · `queueChange` · `error` (`{ code?, error }`) · `raw` (eventos não mapeados do stream, ex.: `workspace`).
|
|
319
317
|
|
|
320
318
|
```typescript
|
|
321
|
-
const session = getAgentTaskMitra({ create: true });
|
|
319
|
+
const session = getAgentTaskMitra({ create: true, agentId: 'uuid-do-agente' });
|
|
322
320
|
|
|
323
321
|
session.on('delta', ({ delta, kind }) => { if (kind === 'text') process.stdout.write(delta); });
|
|
324
322
|
session.on('tool', ({ tool, phase }) => console.log('🔧', phase, tool));
|
package/dist/index.d.mts
CHANGED
|
@@ -205,7 +205,7 @@ interface AgentChat {
|
|
|
205
205
|
id: string;
|
|
206
206
|
name: string | null;
|
|
207
207
|
agentType: AgentType;
|
|
208
|
-
/** Agente business dono do chat (null =
|
|
208
|
+
/** Agente business dono do chat (null = sessão business sem agente — não executa nada). */
|
|
209
209
|
agentId: string | null;
|
|
210
210
|
archived: boolean;
|
|
211
211
|
createdAt: string;
|
|
@@ -276,8 +276,10 @@ interface GetAgentTaskCreateOptions {
|
|
|
276
276
|
/**
|
|
277
277
|
* ID de um agente business (CRUD via mitra-sdk: listAgentsMitra e família).
|
|
278
278
|
* Com agentId, a sessão sobe com o system prompt do agente e um token escopado —
|
|
279
|
-
* as tools enxergam só as Server Functions daquele agente.
|
|
280
|
-
*
|
|
279
|
+
* as tools enxergam só as Server Functions daquele agente.
|
|
280
|
+
* Sem agentId: sessão business SEM agente — sem system prompt e sem acesso às
|
|
281
|
+
* Server Functions (as tools recusam). Não há adoção automática de agente
|
|
282
|
+
* único; na prática, sempre passe agentId.
|
|
281
283
|
*/
|
|
282
284
|
agentId?: string;
|
|
283
285
|
/** Transporte do prompt (default 'ws'). */
|
|
@@ -523,29 +525,33 @@ declare function getConfig(): MitraConfig;
|
|
|
523
525
|
declare function resolveProjectId(projectId?: number | string): number | string;
|
|
524
526
|
|
|
525
527
|
/**
|
|
526
|
-
* Mitra Interactions SDK - Autenticação (
|
|
528
|
+
* Mitra Interactions SDK - Autenticação (Novo Mitra)
|
|
527
529
|
*
|
|
528
|
-
*
|
|
529
|
-
* -
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
530
|
+
* Implementação do auth para o novo Mitra (Kong gateway).
|
|
531
|
+
* - Email login/signup/refresh: via BFF (mitra-legacy-bff), POST {gateway}/auth/*.
|
|
532
|
+
* O BFF resolve projectId->appId, chama o mitra-iam e já devolve o envelope
|
|
533
|
+
* { token, baseURL, integrationURL } que a SDK consome.
|
|
534
|
+
* - SSO (Google): página atravessadora (sdk-auth.html) faz o start do OAuth e
|
|
535
|
+
* devolve o `code` cru (popup via postMessage, redirect via #codeMitra). A SDK
|
|
536
|
+
* troca o code por token no BFF (POST {gateway}/auth/{provider}), mesmo host do
|
|
537
|
+
* /email/login. Provider-agnóstico: Microsoft entra só mudando a allowlist
|
|
538
|
+
* quando o back liberar o endpoint. Suporta popup (desktop) e redirect (mobile).
|
|
533
539
|
*/
|
|
534
540
|
|
|
535
|
-
declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
|
|
536
|
-
declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
537
|
-
declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
538
|
-
declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
|
|
539
541
|
/**
|
|
540
|
-
* Gera o JWT a partir do code do SSO (
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
542
|
+
* Gera o JWT a partir do `code` do SSO (retorno do redirect). Valida o `state`
|
|
543
|
+
* contra o nonce gerado no start (anti-CSRF), troca o code no BFF
|
|
544
|
+
* (POST {gateway}/auth/{provider}) e configura o SDK. Ler/limpar o fragment da
|
|
545
|
+
* URL é responsabilidade do app — aqui só se gera o token.
|
|
544
546
|
*/
|
|
545
547
|
declare function exchangeSsoCodeMitra(options: {
|
|
546
548
|
code: string;
|
|
547
549
|
state: string;
|
|
548
550
|
}): Promise<LoginResponse>;
|
|
551
|
+
declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
552
|
+
declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
553
|
+
declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
|
|
554
|
+
declare function refreshTokenSilently(authUrl: string, _projectId: number | string): Promise<LoginResponse>;
|
|
549
555
|
|
|
550
556
|
/**
|
|
551
557
|
* Mitra Interactions SDK — Agent Chat (via BFF)
|
package/dist/index.d.ts
CHANGED
|
@@ -205,7 +205,7 @@ interface AgentChat {
|
|
|
205
205
|
id: string;
|
|
206
206
|
name: string | null;
|
|
207
207
|
agentType: AgentType;
|
|
208
|
-
/** Agente business dono do chat (null =
|
|
208
|
+
/** Agente business dono do chat (null = sessão business sem agente — não executa nada). */
|
|
209
209
|
agentId: string | null;
|
|
210
210
|
archived: boolean;
|
|
211
211
|
createdAt: string;
|
|
@@ -276,8 +276,10 @@ interface GetAgentTaskCreateOptions {
|
|
|
276
276
|
/**
|
|
277
277
|
* ID de um agente business (CRUD via mitra-sdk: listAgentsMitra e família).
|
|
278
278
|
* Com agentId, a sessão sobe com o system prompt do agente e um token escopado —
|
|
279
|
-
* as tools enxergam só as Server Functions daquele agente.
|
|
280
|
-
*
|
|
279
|
+
* as tools enxergam só as Server Functions daquele agente.
|
|
280
|
+
* Sem agentId: sessão business SEM agente — sem system prompt e sem acesso às
|
|
281
|
+
* Server Functions (as tools recusam). Não há adoção automática de agente
|
|
282
|
+
* único; na prática, sempre passe agentId.
|
|
281
283
|
*/
|
|
282
284
|
agentId?: string;
|
|
283
285
|
/** Transporte do prompt (default 'ws'). */
|
|
@@ -523,29 +525,33 @@ declare function getConfig(): MitraConfig;
|
|
|
523
525
|
declare function resolveProjectId(projectId?: number | string): number | string;
|
|
524
526
|
|
|
525
527
|
/**
|
|
526
|
-
* Mitra Interactions SDK - Autenticação (
|
|
528
|
+
* Mitra Interactions SDK - Autenticação (Novo Mitra)
|
|
527
529
|
*
|
|
528
|
-
*
|
|
529
|
-
* -
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
530
|
+
* Implementação do auth para o novo Mitra (Kong gateway).
|
|
531
|
+
* - Email login/signup/refresh: via BFF (mitra-legacy-bff), POST {gateway}/auth/*.
|
|
532
|
+
* O BFF resolve projectId->appId, chama o mitra-iam e já devolve o envelope
|
|
533
|
+
* { token, baseURL, integrationURL } que a SDK consome.
|
|
534
|
+
* - SSO (Google): página atravessadora (sdk-auth.html) faz o start do OAuth e
|
|
535
|
+
* devolve o `code` cru (popup via postMessage, redirect via #codeMitra). A SDK
|
|
536
|
+
* troca o code por token no BFF (POST {gateway}/auth/{provider}), mesmo host do
|
|
537
|
+
* /email/login. Provider-agnóstico: Microsoft entra só mudando a allowlist
|
|
538
|
+
* quando o back liberar o endpoint. Suporta popup (desktop) e redirect (mobile).
|
|
533
539
|
*/
|
|
534
540
|
|
|
535
|
-
declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
|
|
536
|
-
declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
537
|
-
declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
538
|
-
declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
|
|
539
541
|
/**
|
|
540
|
-
* Gera o JWT a partir do code do SSO (
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
542
|
+
* Gera o JWT a partir do `code` do SSO (retorno do redirect). Valida o `state`
|
|
543
|
+
* contra o nonce gerado no start (anti-CSRF), troca o code no BFF
|
|
544
|
+
* (POST {gateway}/auth/{provider}) e configura o SDK. Ler/limpar o fragment da
|
|
545
|
+
* URL é responsabilidade do app — aqui só se gera o token.
|
|
544
546
|
*/
|
|
545
547
|
declare function exchangeSsoCodeMitra(options: {
|
|
546
548
|
code: string;
|
|
547
549
|
state: string;
|
|
548
550
|
}): Promise<LoginResponse>;
|
|
551
|
+
declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
552
|
+
declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
|
|
553
|
+
declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
|
|
554
|
+
declare function refreshTokenSilently(authUrl: string, _projectId: number | string): Promise<LoginResponse>;
|
|
549
555
|
|
|
550
556
|
/**
|
|
551
557
|
* Mitra Interactions SDK — Agent Chat (via BFF)
|