mitra-interactions-sdk 1.0.60-beta.35 → 1.0.60-beta.37

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
@@ -363,30 +363,6 @@ const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', ta
363
363
  const { connected, email } = await manageAgentCredentialMitra({ action: 'connect', target: 'anthropic', code, state });
364
364
  ```
365
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
-
390
366
  Device flow (só OpenAI) — mostre `userCode` + `verificationUri` e faça polling:
391
367
 
392
368
  ```typescript
package/dist/index.d.mts CHANGED
@@ -449,9 +449,15 @@ interface AgentModel {
449
449
  provider: string;
450
450
  agentType: AgentType;
451
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.
452
+ * Registro das intensidades de reasoning válidas pra este modelo. Variam por
453
+ * harness — ex. (ilustrativo, sempre leia daqui): claude
454
+ * ['low','medium','high','xhigh','max']; codex
455
+ * ['none','minimal','low','medium','high','xhigh','max','ultra'].
456
+ * A UI monta o seletor a partir DAQUI; valor fora do registro é recusado
457
+ * pelo copilot (INVALID_REASONING_EFFORT).
458
+ * ATENÇÃO: a lista de models vem VAZIA enquanto nenhuma credencial/connection
459
+ * estiver conectada (o catálogo é escopado pelo que dá pra rodar) — o seletor
460
+ * só existe depois de conectar um provider e escolher um modelo.
455
461
  */
456
462
  reasoningOptions?: string[];
457
463
  }
@@ -514,43 +520,6 @@ type ManageAgentCredentialOptions = {
514
520
  deviceAuthId: string;
515
521
  projectId?: number | string;
516
522
  };
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
- }
554
523
 
555
524
  /**
556
525
  * Mitra Interactions SDK - Instance
@@ -756,66 +725,6 @@ declare function manageAgentCredentialMitra(options: {
756
725
  projectId?: number | string;
757
726
  }): Promise<ConnectAgentCredentialResult>;
758
727
 
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
-
819
728
  /**
820
729
  * Mitra Interactions SDK - Services
821
730
  */
@@ -871,4 +780,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
871
780
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
872
781
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
873
782
 
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 };
783
+ 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 };
package/dist/index.d.ts CHANGED
@@ -449,9 +449,15 @@ interface AgentModel {
449
449
  provider: string;
450
450
  agentType: AgentType;
451
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.
452
+ * Registro das intensidades de reasoning válidas pra este modelo. Variam por
453
+ * harness — ex. (ilustrativo, sempre leia daqui): claude
454
+ * ['low','medium','high','xhigh','max']; codex
455
+ * ['none','minimal','low','medium','high','xhigh','max','ultra'].
456
+ * A UI monta o seletor a partir DAQUI; valor fora do registro é recusado
457
+ * pelo copilot (INVALID_REASONING_EFFORT).
458
+ * ATENÇÃO: a lista de models vem VAZIA enquanto nenhuma credencial/connection
459
+ * estiver conectada (o catálogo é escopado pelo que dá pra rodar) — o seletor
460
+ * só existe depois de conectar um provider e escolher um modelo.
455
461
  */
456
462
  reasoningOptions?: string[];
457
463
  }
@@ -514,43 +520,6 @@ type ManageAgentCredentialOptions = {
514
520
  deviceAuthId: string;
515
521
  projectId?: number | string;
516
522
  };
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
- }
554
523
 
555
524
  /**
556
525
  * Mitra Interactions SDK - Instance
@@ -756,66 +725,6 @@ declare function manageAgentCredentialMitra(options: {
756
725
  projectId?: number | string;
757
726
  }): Promise<ConnectAgentCredentialResult>;
758
727
 
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
-
819
728
  /**
820
729
  * Mitra Interactions SDK - Services
821
730
  */
@@ -871,4 +780,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
871
780
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
872
781
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
873
782
 
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 };
783
+ 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 };
package/dist/index.js CHANGED
@@ -1602,96 +1602,6 @@ function resolveProjectId(projectId) {
1602
1602
  throw new Error("projectId \xE9 obrigat\xF3rio. Passe nas options ou configure via configureSdkMitra({ projectId }).");
1603
1603
  }
1604
1604
 
1605
- // src/agent-connections.ts
1606
- function getConnectionsBase() {
1607
- const config = getConfig();
1608
- if (!config.baseURL) {
1609
- throw new Error("Agent Connections: baseURL n\xE3o configurada. Configure via configureSdkMitra({ baseURL }).");
1610
- }
1611
- const token = config.token;
1612
- if (token) {
1613
- const payload = decodeJwtPayload(token);
1614
- if (payload && payload.token_use === "session" && !payload.app_id) {
1615
- throw new Error("Agent Connections: o token configurado \xE9 uma sess\xE3o do console \u2014 use token de app (loginMitra) ou chave de SF.");
1616
- }
1617
- }
1618
- return `${new URL(config.baseURL).origin}/copilot/api/v1/connections`;
1619
- }
1620
- async function connectionsFetch(method, path, body) {
1621
- var _a, _b, _c;
1622
- if (isTokenExpiring()) await tryRefreshToken();
1623
- const config = getConfig();
1624
- if (!config.token) {
1625
- throw new Error("Agent Connections: token n\xE3o configurado. Fa\xE7a login ou configure a chave de SF em configureSdkMitra({ token }).");
1626
- }
1627
- const doFetch = async () => fetch(`${getConnectionsBase()}${path}`, {
1628
- method,
1629
- headers: {
1630
- "Content-Type": "application/json",
1631
- "Authorization": `Bearer ${stripBearer(getConfig().token)}`
1632
- },
1633
- body: body !== void 0 ? JSON.stringify(body) : void 0
1634
- });
1635
- let response = await doFetch();
1636
- if (response.status === 401 && await tryRefreshToken()) {
1637
- response = await doFetch();
1638
- }
1639
- const text = await response.text();
1640
- const { data, isJson } = parseBody(text);
1641
- if (!response.ok) {
1642
- const fallback = !isJson && text ? `HTTP ${response.status} \u2014 ${text}` : `HTTP ${response.status}`;
1643
- const msg = isJson && ((data == null ? void 0 : data.message) || ((_a = data == null ? void 0 : data.error) == null ? void 0 : _a.message) || (data == null ? void 0 : data.error)) || fallback;
1644
- throw { message: typeof msg === "string" ? msg : fallback, status: response.status, code: (_c = data == null ? void 0 : data.code) != null ? _c : (_b = data == null ? void 0 : data.error) == null ? void 0 : _b.code, details: data };
1645
- }
1646
- return data;
1647
- }
1648
- async function manageAgentConnectionMitra(options) {
1649
- var _a;
1650
- switch (options.action) {
1651
- case "list": {
1652
- const connections = await connectionsFetch("GET", "");
1653
- return { connections: connections != null ? connections : [] };
1654
- }
1655
- case "create": {
1656
- return connectionsFetch("POST", "", {
1657
- provider: String(options.provider).toUpperCase(),
1658
- ...options.name ? { name: options.name } : {}
1659
- });
1660
- }
1661
- case "save": {
1662
- if (!((_a = options.key) == null ? void 0 : _a.trim())) throw new Error("manageAgentConnectionMitra(save): key obrigat\xF3ria.");
1663
- await connectionsFetch("PUT", `/${encodeURIComponent(options.connectionId)}/api-key`, { apiKey: options.key });
1664
- return;
1665
- }
1666
- case "auth": {
1667
- return connectionsFetch("POST", `/${encodeURIComponent(options.connectionId)}/oauth/start`);
1668
- }
1669
- case "connect": {
1670
- if (!options.code || !options.state) {
1671
- throw new Error("manageAgentConnectionMitra(connect): code e state obrigat\xF3rios.");
1672
- }
1673
- return connectionsFetch("POST", `/${encodeURIComponent(options.connectionId)}/oauth/exchange`, {
1674
- code: options.code,
1675
- state: options.state
1676
- });
1677
- }
1678
- case "device_auth": {
1679
- return connectionsFetch("POST", `/${encodeURIComponent(options.connectionId)}/device-authorizations`);
1680
- }
1681
- case "device_poll": {
1682
- if (!options.deviceAuthId) {
1683
- throw new Error("manageAgentConnectionMitra(device_poll): deviceAuthId obrigat\xF3rio.");
1684
- }
1685
- return connectionsFetch(
1686
- "POST",
1687
- `/${encodeURIComponent(options.connectionId)}/device-authorizations/${encodeURIComponent(options.deviceAuthId)}/poll`
1688
- );
1689
- }
1690
- default:
1691
- throw new Error(`manageAgentConnectionMitra: action inv\xE1lida (${options.action}).`);
1692
- }
1693
- }
1694
-
1695
1605
  // src/services.ts
1696
1606
  async function executeServerFunctionMitra(options) {
1697
1607
  const body = {
@@ -1845,7 +1755,6 @@ exports.loginMitra = loginMitra;
1845
1755
  exports.loginWithGoogleMitra = loginWithGoogleMitra;
1846
1756
  exports.loginWithMicrosoftMitra = loginWithMicrosoftMitra;
1847
1757
  exports.manageAgentChatMitra = manageAgentChatMitra;
1848
- exports.manageAgentConnectionMitra = manageAgentConnectionMitra;
1849
1758
  exports.manageAgentCredentialMitra = manageAgentCredentialMitra;
1850
1759
  exports.patchRecordMitra = patchRecordMitra;
1851
1760
  exports.refreshTokenSilently = refreshTokenSilently;