mitra-interactions-sdk 1.0.60-beta.33 → 1.0.60-beta.35
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 +32 -4
- package/dist/index.d.mts +141 -6
- package/dist/index.d.ts +141 -6
- package/dist/index.js +281 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +281 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,7 +248,7 @@ const result2 = await listRecordsMitra({
|
|
|
248
248
|
|
|
249
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
|
-
Precisa de `token` e `baseURL` configurados (o login já deixa pronto). O transporte do prompt aceita `transport: 'ws' | 'http'` — `'ws'` é o default; `'http'` é
|
|
251
|
+
Precisa de `token` e `baseURL` configurados (o login já deixa pronto). O transporte do prompt aceita `transport: 'ws' | 'http'` — `'ws'` é o default; `'http'` é **funcional**: `POST /copilot/api/v1/tasks/{id}/inputs` + SSE em `/events` via fetch, com a MESMA paridade de eventos do WS (pra ambientes onde WebSocket não rola, ex.: serverless).
|
|
252
252
|
|
|
253
253
|
### Gerenciar os chats — `manageAgentChatMitra`
|
|
254
254
|
|
|
@@ -284,7 +284,9 @@ const existing = getAgentTaskMitra({ taskId: 'uuid-da-task' });
|
|
|
284
284
|
await existing.loadHistory({ limit: 50 });
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
`getAgentTaskMitra({ create: true, agentType?, name?, agentId?, transport? })` ou `getAgentTaskMitra({ taskId, transport? })`.
|
|
287
|
+
`getAgentTaskMitra({ create: true, agentType?, name?, agentId?, reasoningEffort?, autonomous?, transport? })` ou `getAgentTaskMitra({ taskId, transport? })`.
|
|
288
|
+
|
|
289
|
+
**Chat autônomo (`autonomous: true`)**: cria o chat **sem dono** (`user_id NULL` — a dona é o agente), pra Server Function/webhook/cron dirigir o agente. Exige `agentId` (fail-fast no client) e o agente precisa ter uma **connection anexada** como credencial; auth `AGENT_WRITE` (chave de SF ou token de app EDIT), senão 403. Depois de criado, dirigir/listar é igual ao chat normal (`getAgentTaskMitra({ taskId })`, `send`, `manageAgentChatMitra({ list, agentId })`). Sem o flag, comportamento de sempre (chat com dono = o caller). ⚠️ Depende do backend `impl-autonomous` — antes dele o servidor ignora o flag.
|
|
288
290
|
|
|
289
291
|
- `agentType` vem de `manageAgentCredentialMitra({ action: 'list_models' })` — ex.: `'ANTHROPIC_CLAUDE_OPUS'`, `'OPENAI_GPT5'`. Default: `'ANTHROPIC_CLAUDE_OPUS'`.
|
|
290
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`: 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`.
|
|
@@ -303,7 +305,7 @@ await existing.loadHistory({ limit: 50 });
|
|
|
303
305
|
|
|
304
306
|
#### Métodos
|
|
305
307
|
|
|
306
|
-
- `send(prompt)` → `void` — dispara um turno (WS `
|
|
308
|
+
- `send(prompt, { reasoningEffort?, agentType? })` → `void` — dispara um turno (`message` no WS ou POST `/inputs`). Se já está streamando, **enfileira** (FIFO, máx 10; as opções viajam com o item). `reasoningEffort`: intensidade desta mensagem — valores válidos vêm das `reasoningOptions` do modelo em `list_models` (**nunca invente**; fora do registro = `INVALID_REASONING_EFFORT`); herda o default de `getAgentTaskMitra({ create, reasoningEffort })` quando omitido. `agentType`: troca o modelo nesta mensagem — **só dentro do mesmo harness** (Claude↔Codex em conversa iniciada = `HARNESS_SWITCH`).
|
|
307
309
|
- `cancel()` → `Promise<void>` — interrompe o turno atual (WS `interrupt`, safety net de 10s).
|
|
308
310
|
- `respondApproval(approved)` → `void` — responde um pedido de aprovação do agente (WS `approval_response`).
|
|
309
311
|
- `loadHistory({ limit? })` → `Promise<AgentTimelineItem[]>` — histórico persistido via REST, já no formato canônico da timeline (renderizou o streaming, renderizou o histórico).
|
|
@@ -344,7 +346,9 @@ const { providers } = await manageAgentCredentialMitra({ action: 'list_providers
|
|
|
344
346
|
|
|
345
347
|
// Modelos selecionáveis → use o agentType em getAgentTaskMitra
|
|
346
348
|
const { models } = await manageAgentCredentialMitra({ action: 'list_models' });
|
|
347
|
-
// AgentModel[]: { model, name, provider, agentType }
|
|
349
|
+
// AgentModel[]: { model, name, provider, agentType, reasoningOptions }
|
|
350
|
+
// reasoningOptions = registro das intensidades válidas por modelo (variam por
|
|
351
|
+
// harness) — monte o seletor de reasoning a partir DAQUI, nunca hardcode
|
|
348
352
|
|
|
349
353
|
// API key
|
|
350
354
|
await manageAgentCredentialMitra({ action: 'save', target: 'openai', key: 'sk-...' });
|
|
@@ -359,6 +363,30 @@ const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', ta
|
|
|
359
363
|
const { connected, email } = await manageAgentCredentialMitra({ action: 'connect', target: 'anthropic', code, state });
|
|
360
364
|
```
|
|
361
365
|
|
|
366
|
+
### Connections do app — `manageAgentConnectionMitra`
|
|
367
|
+
|
|
368
|
+
Credencial de agente **compartilhada do app** (tenant+app) — espelho do management de credencial de user, apontando um `connectionId`. Pra sistemas montarem a tela de auth do agente. REST direto no copilot (`{origin}/copilot/api/v1/connections`).
|
|
369
|
+
|
|
370
|
+
Chamável com **token de user** (app-scoped, roles EDIT/OWNER/ADMIN) **ou** com **chave de SF** (`CONNECTION_READ`/`CONNECTION_WRITE`) — o caminho por chave é aditivo. A credencial nunca sai do servidor.
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import { manageAgentConnectionMitra } from 'mitra-interactions-sdk';
|
|
374
|
+
|
|
375
|
+
const { connections } = await manageAgentConnectionMitra({ action: 'list' });
|
|
376
|
+
const conn = await manageAgentConnectionMitra({ action: 'create', provider: 'anthropic', name: 'shared' });
|
|
377
|
+
|
|
378
|
+
// API key
|
|
379
|
+
await manageAgentConnectionMitra({ action: 'save', connectionId: conn.id, key: 'sk-...' });
|
|
380
|
+
|
|
381
|
+
// OAuth (anthropic)
|
|
382
|
+
const { authUrl, state } = await manageAgentConnectionMitra({ action: 'auth', connectionId: conn.id });
|
|
383
|
+
await manageAgentConnectionMitra({ action: 'connect', connectionId: conn.id, code, state });
|
|
384
|
+
|
|
385
|
+
// Device flow (openai)
|
|
386
|
+
const { deviceAuthId, userCode, verificationUri } = await manageAgentConnectionMitra({ action: 'device_auth', connectionId: conn.id });
|
|
387
|
+
await manageAgentConnectionMitra({ action: 'device_poll', connectionId: conn.id, deviceAuthId });
|
|
388
|
+
```
|
|
389
|
+
|
|
362
390
|
Device flow (só OpenAI) — mostre `userCode` + `verificationUri` e faça polling:
|
|
363
391
|
|
|
364
392
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -276,9 +276,9 @@ interface DeleteAgentChatResult {
|
|
|
276
276
|
deleted: boolean;
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
|
-
* Transporte do prompt. 'ws' (default) = streaming via WebSocket.
|
|
280
|
-
* 'http' =
|
|
281
|
-
*
|
|
279
|
+
* Transporte do prompt. 'ws' (default) = streaming via WebSocket por task.
|
|
280
|
+
* 'http' = POST /inputs + SSE /events via fetch — mesma paridade de eventos,
|
|
281
|
+
* pra ambientes onde WebSocket não rola (ex.: serverless).
|
|
282
282
|
*/
|
|
283
283
|
type AgentTaskTransport = 'ws' | 'http';
|
|
284
284
|
interface GetAgentTaskCreateOptions {
|
|
@@ -288,6 +288,12 @@ interface GetAgentTaskCreateOptions {
|
|
|
288
288
|
projectId?: number | string;
|
|
289
289
|
/** Tipo/modelo do agente (de list_models). Default: 'ANTHROPIC_CLAUDE_OPUS'. */
|
|
290
290
|
agentType?: AgentType;
|
|
291
|
+
/**
|
|
292
|
+
* Default de intensidade de reasoning da session — o send() herda quando a
|
|
293
|
+
* mensagem não sobrescreve. Valores válidos: reasoningOptions do modelo em
|
|
294
|
+
* list_models (nunca invente).
|
|
295
|
+
*/
|
|
296
|
+
reasoningEffort?: string;
|
|
291
297
|
/** Nome/título do chat. */
|
|
292
298
|
name?: string;
|
|
293
299
|
/**
|
|
@@ -299,6 +305,16 @@ interface GetAgentTaskCreateOptions {
|
|
|
299
305
|
* único; na prática, sempre passe agentId.
|
|
300
306
|
*/
|
|
301
307
|
agentId?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Cria o chat SEM dono (user_id NULL — a dona é o agente): a modalidade
|
|
310
|
+
* AUTÔNOMA, onde uma Server Function / webhook / cron dirige o agente.
|
|
311
|
+
* Exige `agentId` e o agente precisa ter uma connection anexada (credencial);
|
|
312
|
+
* auth AGENT_WRITE (chave de SF ou token de app EDIT), senão 403.
|
|
313
|
+
* Omitido = chat com dono (o caller), comportamento de sempre.
|
|
314
|
+
* ATENÇÃO: depende do backend impl-autonomous — antes dele o servidor
|
|
315
|
+
* ignora o flag e cria chat com dono normalmente.
|
|
316
|
+
*/
|
|
317
|
+
autonomous?: boolean;
|
|
302
318
|
/** Transporte do prompt (default 'ws'). */
|
|
303
319
|
transport?: AgentTaskTransport;
|
|
304
320
|
}
|
|
@@ -318,10 +334,26 @@ interface QueuedItem {
|
|
|
318
334
|
seq: number;
|
|
319
335
|
createdAt: number;
|
|
320
336
|
status: 'pending' | 'sending';
|
|
337
|
+
/** Opções da mensagem preservadas na fila (enviadas quando o item despachar). */
|
|
338
|
+
reasoningEffort?: string;
|
|
339
|
+
agentType?: AgentType;
|
|
321
340
|
}
|
|
322
341
|
interface SendOptions {
|
|
323
|
-
/**
|
|
324
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Intensidade de reasoning DESTA mensagem. Valores válidos vêm SEMPRE do
|
|
344
|
+
* registro `reasoningOptions` do modelo em list_models (variam por harness) —
|
|
345
|
+
* nunca invente: valor fora do registro é recusado pelo copilot
|
|
346
|
+
* (INVALID_REASONING_EFFORT). Sobrescreve o default da session; a SDK envia
|
|
347
|
+
* em maiúsculo. Omitido = herda o default da abertura (ou o do backend).
|
|
348
|
+
*/
|
|
349
|
+
reasoningEffort?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Troca o modelo NESTA mensagem (value de list_models). O copilot reinicia a
|
|
352
|
+
* sessão retomando o mesmo chat com os parâmetros novos. Só dentro do MESMO
|
|
353
|
+
* harness — trocar Claude↔Codex numa conversa iniciada é recusado
|
|
354
|
+
* (HARNESS_SWITCH).
|
|
355
|
+
*/
|
|
356
|
+
agentType?: AgentType;
|
|
325
357
|
}
|
|
326
358
|
interface AgentDeltaEvent {
|
|
327
359
|
delta: string;
|
|
@@ -416,6 +448,12 @@ interface AgentModel {
|
|
|
416
448
|
name: string;
|
|
417
449
|
provider: string;
|
|
418
450
|
agentType: AgentType;
|
|
451
|
+
/**
|
|
452
|
+
* Registro das intensidades de reasoning válidas pra este modelo (variam por
|
|
453
|
+
* harness — ex.: claude low..max; codex none..ultra). A UI monta o seletor a
|
|
454
|
+
* partir DAQUI; valor fora do registro é recusado pelo copilot.
|
|
455
|
+
*/
|
|
456
|
+
reasoningOptions?: string[];
|
|
419
457
|
}
|
|
420
458
|
interface ListAgentProvidersResult {
|
|
421
459
|
providers: AgentCredentialStatus[];
|
|
@@ -476,6 +514,43 @@ type ManageAgentCredentialOptions = {
|
|
|
476
514
|
deviceAuthId: string;
|
|
477
515
|
projectId?: number | string;
|
|
478
516
|
};
|
|
517
|
+
/** Connection do app (shape do copilot; campos extras passam intactos). */
|
|
518
|
+
interface AgentConnection {
|
|
519
|
+
id: string;
|
|
520
|
+
provider?: string;
|
|
521
|
+
name?: string;
|
|
522
|
+
connected?: boolean;
|
|
523
|
+
[key: string]: unknown;
|
|
524
|
+
}
|
|
525
|
+
type ManageAgentConnectionOptions = {
|
|
526
|
+
action: 'list';
|
|
527
|
+
} | {
|
|
528
|
+
action: 'create';
|
|
529
|
+
provider: AgentProvider;
|
|
530
|
+
name?: string;
|
|
531
|
+
} | {
|
|
532
|
+
action: 'save';
|
|
533
|
+
connectionId: string;
|
|
534
|
+
key: string;
|
|
535
|
+
} | {
|
|
536
|
+
action: 'auth';
|
|
537
|
+
connectionId: string;
|
|
538
|
+
} | {
|
|
539
|
+
action: 'connect';
|
|
540
|
+
connectionId: string;
|
|
541
|
+
code: string;
|
|
542
|
+
state: string;
|
|
543
|
+
} | {
|
|
544
|
+
action: 'device_auth';
|
|
545
|
+
connectionId: string;
|
|
546
|
+
} | {
|
|
547
|
+
action: 'device_poll';
|
|
548
|
+
connectionId: string;
|
|
549
|
+
deviceAuthId: string;
|
|
550
|
+
};
|
|
551
|
+
interface ListAgentConnectionsResult {
|
|
552
|
+
connections: AgentConnection[];
|
|
553
|
+
}
|
|
479
554
|
|
|
480
555
|
/**
|
|
481
556
|
* Mitra Interactions SDK - Instance
|
|
@@ -681,6 +756,66 @@ declare function manageAgentCredentialMitra(options: {
|
|
|
681
756
|
projectId?: number | string;
|
|
682
757
|
}): Promise<ConnectAgentCredentialResult>;
|
|
683
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Mitra Interactions SDK — Agent Connections
|
|
761
|
+
*
|
|
762
|
+
* Management de credencial de agente COMPARTILHADA (connection do app,
|
|
763
|
+
* tenant+app) — espelho do management de credencial de user
|
|
764
|
+
* (agent-credentials.ts), apontando um connectionId. Pra sistemas montarem
|
|
765
|
+
* a tela de auth do agente.
|
|
766
|
+
*
|
|
767
|
+
* REST direto no copilot ({origin}/copilot/api/v1/connections):
|
|
768
|
+
* - list → GET /connections
|
|
769
|
+
* - create → POST /connections
|
|
770
|
+
* - save → PUT /connections/{id}/api-key
|
|
771
|
+
* - auth → POST /connections/{id}/oauth/start
|
|
772
|
+
* - connect → POST /connections/{id}/oauth/exchange
|
|
773
|
+
* - device_auth → POST /connections/{id}/device-authorizations
|
|
774
|
+
* - device_poll → POST /connections/{id}/device-authorizations/{deviceAuthId}/poll
|
|
775
|
+
*
|
|
776
|
+
* Auth: Authorization Bearer com o token da config — funciona com token de
|
|
777
|
+
* user (app-scoped, roles EDIT/OWNER/ADMIN) E com chave de SF
|
|
778
|
+
* (CONNECTION_READ/WRITE). O caminho por chave é aditivo: nada aqui exige
|
|
779
|
+
* tipo específico de credencial — o servidor decide. Só sessão de CONSOLE
|
|
780
|
+
* (JWT token_use=session, sem app_id) é barrada no client, com causa clara.
|
|
781
|
+
*
|
|
782
|
+
* SEGURANÇA: a credencial nunca sai do servidor — as respostas trazem só
|
|
783
|
+
* status/metadados da connection.
|
|
784
|
+
*/
|
|
785
|
+
|
|
786
|
+
declare function manageAgentConnectionMitra(options: {
|
|
787
|
+
action: 'list';
|
|
788
|
+
}): Promise<ListAgentConnectionsResult>;
|
|
789
|
+
declare function manageAgentConnectionMitra(options: {
|
|
790
|
+
action: 'create';
|
|
791
|
+
provider: 'anthropic' | 'openai';
|
|
792
|
+
name?: string;
|
|
793
|
+
}): Promise<AgentConnection>;
|
|
794
|
+
declare function manageAgentConnectionMitra(options: {
|
|
795
|
+
action: 'save';
|
|
796
|
+
connectionId: string;
|
|
797
|
+
key: string;
|
|
798
|
+
}): Promise<void>;
|
|
799
|
+
declare function manageAgentConnectionMitra(options: {
|
|
800
|
+
action: 'auth';
|
|
801
|
+
connectionId: string;
|
|
802
|
+
}): Promise<AuthAgentCredentialResult>;
|
|
803
|
+
declare function manageAgentConnectionMitra(options: {
|
|
804
|
+
action: 'connect';
|
|
805
|
+
connectionId: string;
|
|
806
|
+
code: string;
|
|
807
|
+
state: string;
|
|
808
|
+
}): Promise<ConnectAgentCredentialResult>;
|
|
809
|
+
declare function manageAgentConnectionMitra(options: {
|
|
810
|
+
action: 'device_auth';
|
|
811
|
+
connectionId: string;
|
|
812
|
+
}): Promise<DeviceAuthAgentCredentialResult>;
|
|
813
|
+
declare function manageAgentConnectionMitra(options: {
|
|
814
|
+
action: 'device_poll';
|
|
815
|
+
connectionId: string;
|
|
816
|
+
deviceAuthId: string;
|
|
817
|
+
}): Promise<ConnectAgentCredentialResult>;
|
|
818
|
+
|
|
684
819
|
/**
|
|
685
820
|
* Mitra Interactions SDK - Services
|
|
686
821
|
*/
|
|
@@ -736,4 +871,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
|
|
|
736
871
|
declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
|
|
737
872
|
declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
738
873
|
|
|
739
|
-
export { type AgentChat, type AgentCredentialStatus, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
|
|
874
|
+
export { type AgentChat, type AgentConnection, type AgentCredentialStatus, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentConnectionsResult, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentConnectionOptions, type ManageAgentCredentialOptions, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentConnectionMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
|
package/dist/index.d.ts
CHANGED
|
@@ -276,9 +276,9 @@ interface DeleteAgentChatResult {
|
|
|
276
276
|
deleted: boolean;
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
|
-
* Transporte do prompt. 'ws' (default) = streaming via WebSocket.
|
|
280
|
-
* 'http' =
|
|
281
|
-
*
|
|
279
|
+
* Transporte do prompt. 'ws' (default) = streaming via WebSocket por task.
|
|
280
|
+
* 'http' = POST /inputs + SSE /events via fetch — mesma paridade de eventos,
|
|
281
|
+
* pra ambientes onde WebSocket não rola (ex.: serverless).
|
|
282
282
|
*/
|
|
283
283
|
type AgentTaskTransport = 'ws' | 'http';
|
|
284
284
|
interface GetAgentTaskCreateOptions {
|
|
@@ -288,6 +288,12 @@ interface GetAgentTaskCreateOptions {
|
|
|
288
288
|
projectId?: number | string;
|
|
289
289
|
/** Tipo/modelo do agente (de list_models). Default: 'ANTHROPIC_CLAUDE_OPUS'. */
|
|
290
290
|
agentType?: AgentType;
|
|
291
|
+
/**
|
|
292
|
+
* Default de intensidade de reasoning da session — o send() herda quando a
|
|
293
|
+
* mensagem não sobrescreve. Valores válidos: reasoningOptions do modelo em
|
|
294
|
+
* list_models (nunca invente).
|
|
295
|
+
*/
|
|
296
|
+
reasoningEffort?: string;
|
|
291
297
|
/** Nome/título do chat. */
|
|
292
298
|
name?: string;
|
|
293
299
|
/**
|
|
@@ -299,6 +305,16 @@ interface GetAgentTaskCreateOptions {
|
|
|
299
305
|
* único; na prática, sempre passe agentId.
|
|
300
306
|
*/
|
|
301
307
|
agentId?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Cria o chat SEM dono (user_id NULL — a dona é o agente): a modalidade
|
|
310
|
+
* AUTÔNOMA, onde uma Server Function / webhook / cron dirige o agente.
|
|
311
|
+
* Exige `agentId` e o agente precisa ter uma connection anexada (credencial);
|
|
312
|
+
* auth AGENT_WRITE (chave de SF ou token de app EDIT), senão 403.
|
|
313
|
+
* Omitido = chat com dono (o caller), comportamento de sempre.
|
|
314
|
+
* ATENÇÃO: depende do backend impl-autonomous — antes dele o servidor
|
|
315
|
+
* ignora o flag e cria chat com dono normalmente.
|
|
316
|
+
*/
|
|
317
|
+
autonomous?: boolean;
|
|
302
318
|
/** Transporte do prompt (default 'ws'). */
|
|
303
319
|
transport?: AgentTaskTransport;
|
|
304
320
|
}
|
|
@@ -318,10 +334,26 @@ interface QueuedItem {
|
|
|
318
334
|
seq: number;
|
|
319
335
|
createdAt: number;
|
|
320
336
|
status: 'pending' | 'sending';
|
|
337
|
+
/** Opções da mensagem preservadas na fila (enviadas quando o item despachar). */
|
|
338
|
+
reasoningEffort?: string;
|
|
339
|
+
agentType?: AgentType;
|
|
321
340
|
}
|
|
322
341
|
interface SendOptions {
|
|
323
|
-
/**
|
|
324
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Intensidade de reasoning DESTA mensagem. Valores válidos vêm SEMPRE do
|
|
344
|
+
* registro `reasoningOptions` do modelo em list_models (variam por harness) —
|
|
345
|
+
* nunca invente: valor fora do registro é recusado pelo copilot
|
|
346
|
+
* (INVALID_REASONING_EFFORT). Sobrescreve o default da session; a SDK envia
|
|
347
|
+
* em maiúsculo. Omitido = herda o default da abertura (ou o do backend).
|
|
348
|
+
*/
|
|
349
|
+
reasoningEffort?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Troca o modelo NESTA mensagem (value de list_models). O copilot reinicia a
|
|
352
|
+
* sessão retomando o mesmo chat com os parâmetros novos. Só dentro do MESMO
|
|
353
|
+
* harness — trocar Claude↔Codex numa conversa iniciada é recusado
|
|
354
|
+
* (HARNESS_SWITCH).
|
|
355
|
+
*/
|
|
356
|
+
agentType?: AgentType;
|
|
325
357
|
}
|
|
326
358
|
interface AgentDeltaEvent {
|
|
327
359
|
delta: string;
|
|
@@ -416,6 +448,12 @@ interface AgentModel {
|
|
|
416
448
|
name: string;
|
|
417
449
|
provider: string;
|
|
418
450
|
agentType: AgentType;
|
|
451
|
+
/**
|
|
452
|
+
* Registro das intensidades de reasoning válidas pra este modelo (variam por
|
|
453
|
+
* harness — ex.: claude low..max; codex none..ultra). A UI monta o seletor a
|
|
454
|
+
* partir DAQUI; valor fora do registro é recusado pelo copilot.
|
|
455
|
+
*/
|
|
456
|
+
reasoningOptions?: string[];
|
|
419
457
|
}
|
|
420
458
|
interface ListAgentProvidersResult {
|
|
421
459
|
providers: AgentCredentialStatus[];
|
|
@@ -476,6 +514,43 @@ type ManageAgentCredentialOptions = {
|
|
|
476
514
|
deviceAuthId: string;
|
|
477
515
|
projectId?: number | string;
|
|
478
516
|
};
|
|
517
|
+
/** Connection do app (shape do copilot; campos extras passam intactos). */
|
|
518
|
+
interface AgentConnection {
|
|
519
|
+
id: string;
|
|
520
|
+
provider?: string;
|
|
521
|
+
name?: string;
|
|
522
|
+
connected?: boolean;
|
|
523
|
+
[key: string]: unknown;
|
|
524
|
+
}
|
|
525
|
+
type ManageAgentConnectionOptions = {
|
|
526
|
+
action: 'list';
|
|
527
|
+
} | {
|
|
528
|
+
action: 'create';
|
|
529
|
+
provider: AgentProvider;
|
|
530
|
+
name?: string;
|
|
531
|
+
} | {
|
|
532
|
+
action: 'save';
|
|
533
|
+
connectionId: string;
|
|
534
|
+
key: string;
|
|
535
|
+
} | {
|
|
536
|
+
action: 'auth';
|
|
537
|
+
connectionId: string;
|
|
538
|
+
} | {
|
|
539
|
+
action: 'connect';
|
|
540
|
+
connectionId: string;
|
|
541
|
+
code: string;
|
|
542
|
+
state: string;
|
|
543
|
+
} | {
|
|
544
|
+
action: 'device_auth';
|
|
545
|
+
connectionId: string;
|
|
546
|
+
} | {
|
|
547
|
+
action: 'device_poll';
|
|
548
|
+
connectionId: string;
|
|
549
|
+
deviceAuthId: string;
|
|
550
|
+
};
|
|
551
|
+
interface ListAgentConnectionsResult {
|
|
552
|
+
connections: AgentConnection[];
|
|
553
|
+
}
|
|
479
554
|
|
|
480
555
|
/**
|
|
481
556
|
* Mitra Interactions SDK - Instance
|
|
@@ -681,6 +756,66 @@ declare function manageAgentCredentialMitra(options: {
|
|
|
681
756
|
projectId?: number | string;
|
|
682
757
|
}): Promise<ConnectAgentCredentialResult>;
|
|
683
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Mitra Interactions SDK — Agent Connections
|
|
761
|
+
*
|
|
762
|
+
* Management de credencial de agente COMPARTILHADA (connection do app,
|
|
763
|
+
* tenant+app) — espelho do management de credencial de user
|
|
764
|
+
* (agent-credentials.ts), apontando um connectionId. Pra sistemas montarem
|
|
765
|
+
* a tela de auth do agente.
|
|
766
|
+
*
|
|
767
|
+
* REST direto no copilot ({origin}/copilot/api/v1/connections):
|
|
768
|
+
* - list → GET /connections
|
|
769
|
+
* - create → POST /connections
|
|
770
|
+
* - save → PUT /connections/{id}/api-key
|
|
771
|
+
* - auth → POST /connections/{id}/oauth/start
|
|
772
|
+
* - connect → POST /connections/{id}/oauth/exchange
|
|
773
|
+
* - device_auth → POST /connections/{id}/device-authorizations
|
|
774
|
+
* - device_poll → POST /connections/{id}/device-authorizations/{deviceAuthId}/poll
|
|
775
|
+
*
|
|
776
|
+
* Auth: Authorization Bearer com o token da config — funciona com token de
|
|
777
|
+
* user (app-scoped, roles EDIT/OWNER/ADMIN) E com chave de SF
|
|
778
|
+
* (CONNECTION_READ/WRITE). O caminho por chave é aditivo: nada aqui exige
|
|
779
|
+
* tipo específico de credencial — o servidor decide. Só sessão de CONSOLE
|
|
780
|
+
* (JWT token_use=session, sem app_id) é barrada no client, com causa clara.
|
|
781
|
+
*
|
|
782
|
+
* SEGURANÇA: a credencial nunca sai do servidor — as respostas trazem só
|
|
783
|
+
* status/metadados da connection.
|
|
784
|
+
*/
|
|
785
|
+
|
|
786
|
+
declare function manageAgentConnectionMitra(options: {
|
|
787
|
+
action: 'list';
|
|
788
|
+
}): Promise<ListAgentConnectionsResult>;
|
|
789
|
+
declare function manageAgentConnectionMitra(options: {
|
|
790
|
+
action: 'create';
|
|
791
|
+
provider: 'anthropic' | 'openai';
|
|
792
|
+
name?: string;
|
|
793
|
+
}): Promise<AgentConnection>;
|
|
794
|
+
declare function manageAgentConnectionMitra(options: {
|
|
795
|
+
action: 'save';
|
|
796
|
+
connectionId: string;
|
|
797
|
+
key: string;
|
|
798
|
+
}): Promise<void>;
|
|
799
|
+
declare function manageAgentConnectionMitra(options: {
|
|
800
|
+
action: 'auth';
|
|
801
|
+
connectionId: string;
|
|
802
|
+
}): Promise<AuthAgentCredentialResult>;
|
|
803
|
+
declare function manageAgentConnectionMitra(options: {
|
|
804
|
+
action: 'connect';
|
|
805
|
+
connectionId: string;
|
|
806
|
+
code: string;
|
|
807
|
+
state: string;
|
|
808
|
+
}): Promise<ConnectAgentCredentialResult>;
|
|
809
|
+
declare function manageAgentConnectionMitra(options: {
|
|
810
|
+
action: 'device_auth';
|
|
811
|
+
connectionId: string;
|
|
812
|
+
}): Promise<DeviceAuthAgentCredentialResult>;
|
|
813
|
+
declare function manageAgentConnectionMitra(options: {
|
|
814
|
+
action: 'device_poll';
|
|
815
|
+
connectionId: string;
|
|
816
|
+
deviceAuthId: string;
|
|
817
|
+
}): Promise<ConnectAgentCredentialResult>;
|
|
818
|
+
|
|
684
819
|
/**
|
|
685
820
|
* Mitra Interactions SDK - Services
|
|
686
821
|
*/
|
|
@@ -736,4 +871,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
|
|
|
736
871
|
declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
|
|
737
872
|
declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
738
873
|
|
|
739
|
-
export { type AgentChat, type AgentCredentialStatus, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
|
|
874
|
+
export { type AgentChat, type AgentConnection, type AgentCredentialStatus, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentConnectionsResult, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentConnectionOptions, type ManageAgentCredentialOptions, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentConnectionMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
|