mitra-interactions-sdk 1.0.60-beta.32 → 1.0.60-beta.34

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 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'` é reservado pra ambientes serverless e hoje lança erro claro (o backend ainda não expõe prompt por 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
 
@@ -286,7 +286,7 @@ await existing.loadHistory({ limit: 50 });
286
286
 
287
287
  `getAgentTaskMitra({ create: true, agentType?, name?, agentId?, transport? })` ou `getAgentTaskMitra({ taskId, transport? })`.
288
288
 
289
- - `agentType` vem de `manageAgentCredentialMitra({ action: 'list_models' })` — ex.: `'ANTHROPIC_CLAUDE_OPUS'`, `'OPENAI_GPT5'`, `'GOOGLE_GEMINI_PRO'`. Default: `'ANTHROPIC_CLAUDE_OPUS'`.
289
+ - `agentType` vem de `manageAgentCredentialMitra({ action: 'list_models' })` — ex.: `'ANTHROPIC_CLAUDE_OPUS'`, `'OPENAI_GPT5'`. Default: `'ANTHROPIC_CLAUDE_OPUS'`.
290
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`.
291
291
 
292
292
  #### Propriedades (somente leitura)
@@ -303,7 +303,7 @@ await existing.loadHistory({ limit: 50 });
303
303
 
304
304
  #### Métodos
305
305
 
306
- - `send(prompt)` → `void` — dispara um turno (WS `message`). Se já está streamando, **enfileira** (FIFO, máx 10).
306
+ - `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
307
  - `cancel()` → `Promise<void>` — interrompe o turno atual (WS `interrupt`, safety net de 10s).
308
308
  - `respondApproval(approved)` → `void` — responde um pedido de aprovação do agente (WS `approval_response`).
309
309
  - `loadHistory({ limit? })` → `Promise<AgentTimelineItem[]>` — histórico persistido via REST, já no formato canônico da timeline (renderizou o streaming, renderizou o histórico).
@@ -329,7 +329,7 @@ session.send('Analise estas vendas e gere um resumo');
329
329
 
330
330
  ### Credenciais do agente — `manageAgentCredentialMitra`
331
331
 
332
- Função única, toda HTTP **via BFF** (`/agentAiShortcut/listProviders`, `saveCredential`, `oauthStart`...). Providers: `'anthropic'`, `'openai'`, `'google'`. API key via `save`/`remove`; OAuth via `auth`/`connect`; device flow via `device_auth`/`device_poll`.
332
+ Função única, toda HTTP **via BFF** (`/agentAiShortcut/listProviders`, `saveCredential`, `oauthStart`...). Providers: `'anthropic'` e `'openai'`. API key via `save`/`remove` (ambos); **OAuth (`auth`/`connect`) é exclusivo do anthropic; device flow (`device_auth`/`device_poll`) é exclusivo do openai** — fluxo trocado falha rápido com erro claro.
333
333
 
334
334
  **`projectId` é obrigatório** em todas as actions (opcional na chamada se já veio do `configureSdkMitra`) — é ele que define de qual app é a credencial; o BFF resolve `projectId → appId` e cunha o token de app.
335
335
 
@@ -344,14 +344,16 @@ const { providers } = await manageAgentCredentialMitra({ action: 'list_providers
344
344
 
345
345
  // Modelos selecionáveis → use o agentType em getAgentTaskMitra
346
346
  const { models } = await manageAgentCredentialMitra({ action: 'list_models' });
347
- // AgentModel[]: { model, name, provider, agentType }
347
+ // AgentModel[]: { model, name, provider, agentType, reasoningOptions }
348
+ // reasoningOptions = registro das intensidades válidas por modelo (variam por
349
+ // harness) — monte o seletor de reasoning a partir DAQUI, nunca hardcode
348
350
 
349
351
  // API key
350
352
  await manageAgentCredentialMitra({ action: 'save', target: 'openai', key: 'sk-...' });
351
353
  await manageAgentCredentialMitra({ action: 'remove', target: 'anthropic' });
352
354
  ```
353
355
 
354
- OAuth (ex.: Anthropic) — `auth` devolve o que mostrar, `connect` finaliza:
356
+ OAuth (só Anthropic) — `auth` devolve o que mostrar, `connect` finaliza:
355
357
 
356
358
  ```typescript
357
359
  const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', target: 'anthropic' });
@@ -359,7 +361,31 @@ const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', ta
359
361
  const { connected, email } = await manageAgentCredentialMitra({ action: 'connect', target: 'anthropic', code, state });
360
362
  ```
361
363
 
362
- Device flow (ex.: OpenAI) — mostre `userCode` + `verificationUri` e faça polling:
364
+ ### Connections do app — `manageAgentConnectionMitra`
365
+
366
+ 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`).
367
+
368
+ 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.
369
+
370
+ ```typescript
371
+ import { manageAgentConnectionMitra } from 'mitra-interactions-sdk';
372
+
373
+ const { connections } = await manageAgentConnectionMitra({ action: 'list' });
374
+ const conn = await manageAgentConnectionMitra({ action: 'create', provider: 'anthropic', name: 'shared' });
375
+
376
+ // API key
377
+ await manageAgentConnectionMitra({ action: 'save', connectionId: conn.id, key: 'sk-...' });
378
+
379
+ // OAuth (anthropic)
380
+ const { authUrl, state } = await manageAgentConnectionMitra({ action: 'auth', connectionId: conn.id });
381
+ await manageAgentConnectionMitra({ action: 'connect', connectionId: conn.id, code, state });
382
+
383
+ // Device flow (openai)
384
+ const { deviceAuthId, userCode, verificationUri } = await manageAgentConnectionMitra({ action: 'device_auth', connectionId: conn.id });
385
+ await manageAgentConnectionMitra({ action: 'device_poll', connectionId: conn.id, deviceAuthId });
386
+ ```
387
+
388
+ Device flow (só OpenAI) — mostre `userCode` + `verificationUri` e faça polling:
363
389
 
364
390
  ```typescript
365
391
  const { deviceAuthId, userCode, verificationUri, intervalSeconds } =
package/dist/index.d.mts CHANGED
@@ -197,9 +197,9 @@ interface StopServerFunctionExecutionResponse {
197
197
  }
198
198
  /**
199
199
  * Tipo/modelo do agente (enum do copilot — vem de list_models).
200
- * Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5', 'GOOGLE_GEMINI_PRO'.
200
+ * Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5'.
201
201
  */
202
- type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' | 'GOOGLE_GEMINI_PRO' | (string & {});
202
+ type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' | (string & {});
203
203
  /** Task/chat do copilot (TaskResponse). `name` espelha o `title` do backend. */
204
204
  interface AgentChat {
205
205
  id: string;
@@ -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' = reservado pra ambientes serverless — o backend ainda não expõe
281
- * o prompt por HTTP; hoje lança erro claro.
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
  /**
@@ -318,10 +324,26 @@ interface QueuedItem {
318
324
  seq: number;
319
325
  createdAt: number;
320
326
  status: 'pending' | 'sending';
327
+ /** Opções da mensagem preservadas na fila (enviadas quando o item despachar). */
328
+ reasoningEffort?: string;
329
+ agentType?: AgentType;
321
330
  }
322
331
  interface SendOptions {
323
- /** Reservado (o modelo/agentType é fixado na criação da task). */
324
- _reserved?: never;
332
+ /**
333
+ * Intensidade de reasoning DESTA mensagem. Valores válidos vêm SEMPRE do
334
+ * registro `reasoningOptions` do modelo em list_models (variam por harness) —
335
+ * nunca invente: valor fora do registro é recusado pelo copilot
336
+ * (INVALID_REASONING_EFFORT). Sobrescreve o default da session; a SDK envia
337
+ * em maiúsculo. Omitido = herda o default da abertura (ou o do backend).
338
+ */
339
+ reasoningEffort?: string;
340
+ /**
341
+ * Troca o modelo NESTA mensagem (value de list_models). O copilot reinicia a
342
+ * sessão retomando o mesmo chat com os parâmetros novos. Só dentro do MESMO
343
+ * harness — trocar Claude↔Codex numa conversa iniciada é recusado
344
+ * (HARNESS_SWITCH).
345
+ */
346
+ agentType?: AgentType;
325
347
  }
326
348
  interface AgentDeltaEvent {
327
349
  delta: string;
@@ -400,7 +422,7 @@ interface AgentTaskSession {
400
422
  close(): void;
401
423
  }
402
424
  /** Providers do copilot. */
403
- type AgentProvider = 'anthropic' | 'openai' | 'google';
425
+ type AgentProvider = 'anthropic' | 'openai';
404
426
  type CredentialAction = 'list_providers' | 'list_models' | 'save' | 'remove' | 'auth' | 'connect' | 'device_auth' | 'device_poll';
405
427
  /** GET /credentials — status por provider. */
406
428
  interface AgentCredentialStatus {
@@ -416,6 +438,12 @@ interface AgentModel {
416
438
  name: string;
417
439
  provider: string;
418
440
  agentType: AgentType;
441
+ /**
442
+ * Registro das intensidades de reasoning válidas pra este modelo (variam por
443
+ * harness — ex.: claude low..max; codex none..ultra). A UI monta o seletor a
444
+ * partir DAQUI; valor fora do registro é recusado pelo copilot.
445
+ */
446
+ reasoningOptions?: string[];
419
447
  }
420
448
  interface ListAgentProvidersResult {
421
449
  providers: AgentCredentialStatus[];
@@ -458,24 +486,61 @@ type ManageAgentCredentialOptions = {
458
486
  projectId?: number | string;
459
487
  } | {
460
488
  action: 'auth';
461
- target: AgentProvider;
489
+ target: 'anthropic';
462
490
  projectId?: number | string;
463
491
  } | {
464
492
  action: 'connect';
465
- target: AgentProvider;
493
+ target: 'anthropic';
466
494
  code: string;
467
495
  state: string;
468
496
  projectId?: number | string;
469
497
  } | {
470
498
  action: 'device_auth';
471
- target: AgentProvider;
499
+ target: 'openai';
472
500
  projectId?: number | string;
473
501
  } | {
474
502
  action: 'device_poll';
475
- target: AgentProvider;
503
+ target: 'openai';
476
504
  deviceAuthId: string;
477
505
  projectId?: number | string;
478
506
  };
507
+ /** Connection do app (shape do copilot; campos extras passam intactos). */
508
+ interface AgentConnection {
509
+ id: string;
510
+ provider?: string;
511
+ name?: string;
512
+ connected?: boolean;
513
+ [key: string]: unknown;
514
+ }
515
+ type ManageAgentConnectionOptions = {
516
+ action: 'list';
517
+ } | {
518
+ action: 'create';
519
+ provider: AgentProvider;
520
+ name?: string;
521
+ } | {
522
+ action: 'save';
523
+ connectionId: string;
524
+ key: string;
525
+ } | {
526
+ action: 'auth';
527
+ connectionId: string;
528
+ } | {
529
+ action: 'connect';
530
+ connectionId: string;
531
+ code: string;
532
+ state: string;
533
+ } | {
534
+ action: 'device_auth';
535
+ connectionId: string;
536
+ } | {
537
+ action: 'device_poll';
538
+ connectionId: string;
539
+ deviceAuthId: string;
540
+ };
541
+ interface ListAgentConnectionsResult {
542
+ connections: AgentConnection[];
543
+ }
479
544
 
480
545
  /**
481
546
  * Mitra Interactions SDK - Instance
@@ -659,28 +724,88 @@ declare function manageAgentCredentialMitra(options: {
659
724
  }): Promise<void>;
660
725
  declare function manageAgentCredentialMitra(options: {
661
726
  action: 'auth';
662
- target: AgentProvider;
727
+ target: 'anthropic';
663
728
  projectId?: number | string;
664
729
  }): Promise<AuthAgentCredentialResult>;
665
730
  declare function manageAgentCredentialMitra(options: {
666
731
  action: 'connect';
667
- target: AgentProvider;
732
+ target: 'anthropic';
668
733
  code: string;
669
734
  state: string;
670
735
  projectId?: number | string;
671
736
  }): Promise<ConnectAgentCredentialResult>;
672
737
  declare function manageAgentCredentialMitra(options: {
673
738
  action: 'device_auth';
674
- target: AgentProvider;
739
+ target: 'openai';
675
740
  projectId?: number | string;
676
741
  }): Promise<DeviceAuthAgentCredentialResult>;
677
742
  declare function manageAgentCredentialMitra(options: {
678
743
  action: 'device_poll';
679
- target: AgentProvider;
744
+ target: 'openai';
680
745
  deviceAuthId: string;
681
746
  projectId?: number | string;
682
747
  }): Promise<ConnectAgentCredentialResult>;
683
748
 
749
+ /**
750
+ * Mitra Interactions SDK — Agent Connections
751
+ *
752
+ * Management de credencial de agente COMPARTILHADA (connection do app,
753
+ * tenant+app) — espelho do management de credencial de user
754
+ * (agent-credentials.ts), apontando um connectionId. Pra sistemas montarem
755
+ * a tela de auth do agente.
756
+ *
757
+ * REST direto no copilot ({origin}/copilot/api/v1/connections):
758
+ * - list → GET /connections
759
+ * - create → POST /connections
760
+ * - save → PUT /connections/{id}/api-key
761
+ * - auth → POST /connections/{id}/oauth/start
762
+ * - connect → POST /connections/{id}/oauth/exchange
763
+ * - device_auth → POST /connections/{id}/device-authorizations
764
+ * - device_poll → POST /connections/{id}/device-authorizations/{deviceAuthId}/poll
765
+ *
766
+ * Auth: Authorization Bearer com o token da config — funciona com token de
767
+ * user (app-scoped, roles EDIT/OWNER/ADMIN) E com chave de SF
768
+ * (CONNECTION_READ/WRITE). O caminho por chave é aditivo: nada aqui exige
769
+ * tipo específico de credencial — o servidor decide. Só sessão de CONSOLE
770
+ * (JWT token_use=session, sem app_id) é barrada no client, com causa clara.
771
+ *
772
+ * SEGURANÇA: a credencial nunca sai do servidor — as respostas trazem só
773
+ * status/metadados da connection.
774
+ */
775
+
776
+ declare function manageAgentConnectionMitra(options: {
777
+ action: 'list';
778
+ }): Promise<ListAgentConnectionsResult>;
779
+ declare function manageAgentConnectionMitra(options: {
780
+ action: 'create';
781
+ provider: 'anthropic' | 'openai';
782
+ name?: string;
783
+ }): Promise<AgentConnection>;
784
+ declare function manageAgentConnectionMitra(options: {
785
+ action: 'save';
786
+ connectionId: string;
787
+ key: string;
788
+ }): Promise<void>;
789
+ declare function manageAgentConnectionMitra(options: {
790
+ action: 'auth';
791
+ connectionId: string;
792
+ }): Promise<AuthAgentCredentialResult>;
793
+ declare function manageAgentConnectionMitra(options: {
794
+ action: 'connect';
795
+ connectionId: string;
796
+ code: string;
797
+ state: string;
798
+ }): Promise<ConnectAgentCredentialResult>;
799
+ declare function manageAgentConnectionMitra(options: {
800
+ action: 'device_auth';
801
+ connectionId: string;
802
+ }): Promise<DeviceAuthAgentCredentialResult>;
803
+ declare function manageAgentConnectionMitra(options: {
804
+ action: 'device_poll';
805
+ connectionId: string;
806
+ deviceAuthId: string;
807
+ }): Promise<ConnectAgentCredentialResult>;
808
+
684
809
  /**
685
810
  * Mitra Interactions SDK - Services
686
811
  */
@@ -736,4 +861,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
736
861
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
737
862
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
738
863
 
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 };
864
+ 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
@@ -197,9 +197,9 @@ interface StopServerFunctionExecutionResponse {
197
197
  }
198
198
  /**
199
199
  * Tipo/modelo do agente (enum do copilot — vem de list_models).
200
- * Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5', 'GOOGLE_GEMINI_PRO'.
200
+ * Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5'.
201
201
  */
202
- type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' | 'GOOGLE_GEMINI_PRO' | (string & {});
202
+ type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' | (string & {});
203
203
  /** Task/chat do copilot (TaskResponse). `name` espelha o `title` do backend. */
204
204
  interface AgentChat {
205
205
  id: string;
@@ -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' = reservado pra ambientes serverless — o backend ainda não expõe
281
- * o prompt por HTTP; hoje lança erro claro.
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
  /**
@@ -318,10 +324,26 @@ interface QueuedItem {
318
324
  seq: number;
319
325
  createdAt: number;
320
326
  status: 'pending' | 'sending';
327
+ /** Opções da mensagem preservadas na fila (enviadas quando o item despachar). */
328
+ reasoningEffort?: string;
329
+ agentType?: AgentType;
321
330
  }
322
331
  interface SendOptions {
323
- /** Reservado (o modelo/agentType é fixado na criação da task). */
324
- _reserved?: never;
332
+ /**
333
+ * Intensidade de reasoning DESTA mensagem. Valores válidos vêm SEMPRE do
334
+ * registro `reasoningOptions` do modelo em list_models (variam por harness) —
335
+ * nunca invente: valor fora do registro é recusado pelo copilot
336
+ * (INVALID_REASONING_EFFORT). Sobrescreve o default da session; a SDK envia
337
+ * em maiúsculo. Omitido = herda o default da abertura (ou o do backend).
338
+ */
339
+ reasoningEffort?: string;
340
+ /**
341
+ * Troca o modelo NESTA mensagem (value de list_models). O copilot reinicia a
342
+ * sessão retomando o mesmo chat com os parâmetros novos. Só dentro do MESMO
343
+ * harness — trocar Claude↔Codex numa conversa iniciada é recusado
344
+ * (HARNESS_SWITCH).
345
+ */
346
+ agentType?: AgentType;
325
347
  }
326
348
  interface AgentDeltaEvent {
327
349
  delta: string;
@@ -400,7 +422,7 @@ interface AgentTaskSession {
400
422
  close(): void;
401
423
  }
402
424
  /** Providers do copilot. */
403
- type AgentProvider = 'anthropic' | 'openai' | 'google';
425
+ type AgentProvider = 'anthropic' | 'openai';
404
426
  type CredentialAction = 'list_providers' | 'list_models' | 'save' | 'remove' | 'auth' | 'connect' | 'device_auth' | 'device_poll';
405
427
  /** GET /credentials — status por provider. */
406
428
  interface AgentCredentialStatus {
@@ -416,6 +438,12 @@ interface AgentModel {
416
438
  name: string;
417
439
  provider: string;
418
440
  agentType: AgentType;
441
+ /**
442
+ * Registro das intensidades de reasoning válidas pra este modelo (variam por
443
+ * harness — ex.: claude low..max; codex none..ultra). A UI monta o seletor a
444
+ * partir DAQUI; valor fora do registro é recusado pelo copilot.
445
+ */
446
+ reasoningOptions?: string[];
419
447
  }
420
448
  interface ListAgentProvidersResult {
421
449
  providers: AgentCredentialStatus[];
@@ -458,24 +486,61 @@ type ManageAgentCredentialOptions = {
458
486
  projectId?: number | string;
459
487
  } | {
460
488
  action: 'auth';
461
- target: AgentProvider;
489
+ target: 'anthropic';
462
490
  projectId?: number | string;
463
491
  } | {
464
492
  action: 'connect';
465
- target: AgentProvider;
493
+ target: 'anthropic';
466
494
  code: string;
467
495
  state: string;
468
496
  projectId?: number | string;
469
497
  } | {
470
498
  action: 'device_auth';
471
- target: AgentProvider;
499
+ target: 'openai';
472
500
  projectId?: number | string;
473
501
  } | {
474
502
  action: 'device_poll';
475
- target: AgentProvider;
503
+ target: 'openai';
476
504
  deviceAuthId: string;
477
505
  projectId?: number | string;
478
506
  };
507
+ /** Connection do app (shape do copilot; campos extras passam intactos). */
508
+ interface AgentConnection {
509
+ id: string;
510
+ provider?: string;
511
+ name?: string;
512
+ connected?: boolean;
513
+ [key: string]: unknown;
514
+ }
515
+ type ManageAgentConnectionOptions = {
516
+ action: 'list';
517
+ } | {
518
+ action: 'create';
519
+ provider: AgentProvider;
520
+ name?: string;
521
+ } | {
522
+ action: 'save';
523
+ connectionId: string;
524
+ key: string;
525
+ } | {
526
+ action: 'auth';
527
+ connectionId: string;
528
+ } | {
529
+ action: 'connect';
530
+ connectionId: string;
531
+ code: string;
532
+ state: string;
533
+ } | {
534
+ action: 'device_auth';
535
+ connectionId: string;
536
+ } | {
537
+ action: 'device_poll';
538
+ connectionId: string;
539
+ deviceAuthId: string;
540
+ };
541
+ interface ListAgentConnectionsResult {
542
+ connections: AgentConnection[];
543
+ }
479
544
 
480
545
  /**
481
546
  * Mitra Interactions SDK - Instance
@@ -659,28 +724,88 @@ declare function manageAgentCredentialMitra(options: {
659
724
  }): Promise<void>;
660
725
  declare function manageAgentCredentialMitra(options: {
661
726
  action: 'auth';
662
- target: AgentProvider;
727
+ target: 'anthropic';
663
728
  projectId?: number | string;
664
729
  }): Promise<AuthAgentCredentialResult>;
665
730
  declare function manageAgentCredentialMitra(options: {
666
731
  action: 'connect';
667
- target: AgentProvider;
732
+ target: 'anthropic';
668
733
  code: string;
669
734
  state: string;
670
735
  projectId?: number | string;
671
736
  }): Promise<ConnectAgentCredentialResult>;
672
737
  declare function manageAgentCredentialMitra(options: {
673
738
  action: 'device_auth';
674
- target: AgentProvider;
739
+ target: 'openai';
675
740
  projectId?: number | string;
676
741
  }): Promise<DeviceAuthAgentCredentialResult>;
677
742
  declare function manageAgentCredentialMitra(options: {
678
743
  action: 'device_poll';
679
- target: AgentProvider;
744
+ target: 'openai';
680
745
  deviceAuthId: string;
681
746
  projectId?: number | string;
682
747
  }): Promise<ConnectAgentCredentialResult>;
683
748
 
749
+ /**
750
+ * Mitra Interactions SDK — Agent Connections
751
+ *
752
+ * Management de credencial de agente COMPARTILHADA (connection do app,
753
+ * tenant+app) — espelho do management de credencial de user
754
+ * (agent-credentials.ts), apontando um connectionId. Pra sistemas montarem
755
+ * a tela de auth do agente.
756
+ *
757
+ * REST direto no copilot ({origin}/copilot/api/v1/connections):
758
+ * - list → GET /connections
759
+ * - create → POST /connections
760
+ * - save → PUT /connections/{id}/api-key
761
+ * - auth → POST /connections/{id}/oauth/start
762
+ * - connect → POST /connections/{id}/oauth/exchange
763
+ * - device_auth → POST /connections/{id}/device-authorizations
764
+ * - device_poll → POST /connections/{id}/device-authorizations/{deviceAuthId}/poll
765
+ *
766
+ * Auth: Authorization Bearer com o token da config — funciona com token de
767
+ * user (app-scoped, roles EDIT/OWNER/ADMIN) E com chave de SF
768
+ * (CONNECTION_READ/WRITE). O caminho por chave é aditivo: nada aqui exige
769
+ * tipo específico de credencial — o servidor decide. Só sessão de CONSOLE
770
+ * (JWT token_use=session, sem app_id) é barrada no client, com causa clara.
771
+ *
772
+ * SEGURANÇA: a credencial nunca sai do servidor — as respostas trazem só
773
+ * status/metadados da connection.
774
+ */
775
+
776
+ declare function manageAgentConnectionMitra(options: {
777
+ action: 'list';
778
+ }): Promise<ListAgentConnectionsResult>;
779
+ declare function manageAgentConnectionMitra(options: {
780
+ action: 'create';
781
+ provider: 'anthropic' | 'openai';
782
+ name?: string;
783
+ }): Promise<AgentConnection>;
784
+ declare function manageAgentConnectionMitra(options: {
785
+ action: 'save';
786
+ connectionId: string;
787
+ key: string;
788
+ }): Promise<void>;
789
+ declare function manageAgentConnectionMitra(options: {
790
+ action: 'auth';
791
+ connectionId: string;
792
+ }): Promise<AuthAgentCredentialResult>;
793
+ declare function manageAgentConnectionMitra(options: {
794
+ action: 'connect';
795
+ connectionId: string;
796
+ code: string;
797
+ state: string;
798
+ }): Promise<ConnectAgentCredentialResult>;
799
+ declare function manageAgentConnectionMitra(options: {
800
+ action: 'device_auth';
801
+ connectionId: string;
802
+ }): Promise<DeviceAuthAgentCredentialResult>;
803
+ declare function manageAgentConnectionMitra(options: {
804
+ action: 'device_poll';
805
+ connectionId: string;
806
+ deviceAuthId: string;
807
+ }): Promise<ConnectAgentCredentialResult>;
808
+
684
809
  /**
685
810
  * Mitra Interactions SDK - Services
686
811
  */
@@ -736,4 +861,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
736
861
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
737
862
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
738
863
 
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 };
864
+ 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 };