mitra-interactions-sdk 1.0.60-beta.32 → 1.0.60-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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'
|
|
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)
|
|
@@ -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'
|
|
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
|
|
|
@@ -351,7 +351,7 @@ await manageAgentCredentialMitra({ action: 'save', target: 'openai', key: 'sk-..
|
|
|
351
351
|
await manageAgentCredentialMitra({ action: 'remove', target: 'anthropic' });
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
OAuth (
|
|
354
|
+
OAuth (só Anthropic) — `auth` devolve o que mostrar, `connect` finaliza:
|
|
355
355
|
|
|
356
356
|
```typescript
|
|
357
357
|
const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', target: 'anthropic' });
|
|
@@ -359,7 +359,7 @@ const { authUrl, state } = await manageAgentCredentialMitra({ action: 'auth', ta
|
|
|
359
359
|
const { connected, email } = await manageAgentCredentialMitra({ action: 'connect', target: 'anthropic', code, state });
|
|
360
360
|
```
|
|
361
361
|
|
|
362
|
-
Device flow (
|
|
362
|
+
Device flow (só OpenAI) — mostre `userCode` + `verificationUri` e faça polling:
|
|
363
363
|
|
|
364
364
|
```typescript
|
|
365
365
|
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'
|
|
200
|
+
* Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5'.
|
|
201
201
|
*/
|
|
202
|
-
type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' |
|
|
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;
|
|
@@ -400,7 +400,7 @@ interface AgentTaskSession {
|
|
|
400
400
|
close(): void;
|
|
401
401
|
}
|
|
402
402
|
/** Providers do copilot. */
|
|
403
|
-
type AgentProvider = 'anthropic' | 'openai'
|
|
403
|
+
type AgentProvider = 'anthropic' | 'openai';
|
|
404
404
|
type CredentialAction = 'list_providers' | 'list_models' | 'save' | 'remove' | 'auth' | 'connect' | 'device_auth' | 'device_poll';
|
|
405
405
|
/** GET /credentials — status por provider. */
|
|
406
406
|
interface AgentCredentialStatus {
|
|
@@ -458,21 +458,21 @@ type ManageAgentCredentialOptions = {
|
|
|
458
458
|
projectId?: number | string;
|
|
459
459
|
} | {
|
|
460
460
|
action: 'auth';
|
|
461
|
-
target:
|
|
461
|
+
target: 'anthropic';
|
|
462
462
|
projectId?: number | string;
|
|
463
463
|
} | {
|
|
464
464
|
action: 'connect';
|
|
465
|
-
target:
|
|
465
|
+
target: 'anthropic';
|
|
466
466
|
code: string;
|
|
467
467
|
state: string;
|
|
468
468
|
projectId?: number | string;
|
|
469
469
|
} | {
|
|
470
470
|
action: 'device_auth';
|
|
471
|
-
target:
|
|
471
|
+
target: 'openai';
|
|
472
472
|
projectId?: number | string;
|
|
473
473
|
} | {
|
|
474
474
|
action: 'device_poll';
|
|
475
|
-
target:
|
|
475
|
+
target: 'openai';
|
|
476
476
|
deviceAuthId: string;
|
|
477
477
|
projectId?: number | string;
|
|
478
478
|
};
|
|
@@ -659,24 +659,24 @@ declare function manageAgentCredentialMitra(options: {
|
|
|
659
659
|
}): Promise<void>;
|
|
660
660
|
declare function manageAgentCredentialMitra(options: {
|
|
661
661
|
action: 'auth';
|
|
662
|
-
target:
|
|
662
|
+
target: 'anthropic';
|
|
663
663
|
projectId?: number | string;
|
|
664
664
|
}): Promise<AuthAgentCredentialResult>;
|
|
665
665
|
declare function manageAgentCredentialMitra(options: {
|
|
666
666
|
action: 'connect';
|
|
667
|
-
target:
|
|
667
|
+
target: 'anthropic';
|
|
668
668
|
code: string;
|
|
669
669
|
state: string;
|
|
670
670
|
projectId?: number | string;
|
|
671
671
|
}): Promise<ConnectAgentCredentialResult>;
|
|
672
672
|
declare function manageAgentCredentialMitra(options: {
|
|
673
673
|
action: 'device_auth';
|
|
674
|
-
target:
|
|
674
|
+
target: 'openai';
|
|
675
675
|
projectId?: number | string;
|
|
676
676
|
}): Promise<DeviceAuthAgentCredentialResult>;
|
|
677
677
|
declare function manageAgentCredentialMitra(options: {
|
|
678
678
|
action: 'device_poll';
|
|
679
|
-
target:
|
|
679
|
+
target: 'openai';
|
|
680
680
|
deviceAuthId: string;
|
|
681
681
|
projectId?: number | string;
|
|
682
682
|
}): Promise<ConnectAgentCredentialResult>;
|
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'
|
|
200
|
+
* Ex.: 'ANTHROPIC_CLAUDE_OPUS', 'OPENAI_GPT5'.
|
|
201
201
|
*/
|
|
202
|
-
type AgentType = 'ANTHROPIC_CLAUDE_OPUS' | 'OPENAI_GPT5' |
|
|
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;
|
|
@@ -400,7 +400,7 @@ interface AgentTaskSession {
|
|
|
400
400
|
close(): void;
|
|
401
401
|
}
|
|
402
402
|
/** Providers do copilot. */
|
|
403
|
-
type AgentProvider = 'anthropic' | 'openai'
|
|
403
|
+
type AgentProvider = 'anthropic' | 'openai';
|
|
404
404
|
type CredentialAction = 'list_providers' | 'list_models' | 'save' | 'remove' | 'auth' | 'connect' | 'device_auth' | 'device_poll';
|
|
405
405
|
/** GET /credentials — status por provider. */
|
|
406
406
|
interface AgentCredentialStatus {
|
|
@@ -458,21 +458,21 @@ type ManageAgentCredentialOptions = {
|
|
|
458
458
|
projectId?: number | string;
|
|
459
459
|
} | {
|
|
460
460
|
action: 'auth';
|
|
461
|
-
target:
|
|
461
|
+
target: 'anthropic';
|
|
462
462
|
projectId?: number | string;
|
|
463
463
|
} | {
|
|
464
464
|
action: 'connect';
|
|
465
|
-
target:
|
|
465
|
+
target: 'anthropic';
|
|
466
466
|
code: string;
|
|
467
467
|
state: string;
|
|
468
468
|
projectId?: number | string;
|
|
469
469
|
} | {
|
|
470
470
|
action: 'device_auth';
|
|
471
|
-
target:
|
|
471
|
+
target: 'openai';
|
|
472
472
|
projectId?: number | string;
|
|
473
473
|
} | {
|
|
474
474
|
action: 'device_poll';
|
|
475
|
-
target:
|
|
475
|
+
target: 'openai';
|
|
476
476
|
deviceAuthId: string;
|
|
477
477
|
projectId?: number | string;
|
|
478
478
|
};
|
|
@@ -659,24 +659,24 @@ declare function manageAgentCredentialMitra(options: {
|
|
|
659
659
|
}): Promise<void>;
|
|
660
660
|
declare function manageAgentCredentialMitra(options: {
|
|
661
661
|
action: 'auth';
|
|
662
|
-
target:
|
|
662
|
+
target: 'anthropic';
|
|
663
663
|
projectId?: number | string;
|
|
664
664
|
}): Promise<AuthAgentCredentialResult>;
|
|
665
665
|
declare function manageAgentCredentialMitra(options: {
|
|
666
666
|
action: 'connect';
|
|
667
|
-
target:
|
|
667
|
+
target: 'anthropic';
|
|
668
668
|
code: string;
|
|
669
669
|
state: string;
|
|
670
670
|
projectId?: number | string;
|
|
671
671
|
}): Promise<ConnectAgentCredentialResult>;
|
|
672
672
|
declare function manageAgentCredentialMitra(options: {
|
|
673
673
|
action: 'device_auth';
|
|
674
|
-
target:
|
|
674
|
+
target: 'openai';
|
|
675
675
|
projectId?: number | string;
|
|
676
676
|
}): Promise<DeviceAuthAgentCredentialResult>;
|
|
677
677
|
declare function manageAgentCredentialMitra(options: {
|
|
678
678
|
action: 'device_poll';
|
|
679
|
-
target:
|
|
679
|
+
target: 'openai';
|
|
680
680
|
deviceAuthId: string;
|
|
681
681
|
projectId?: number | string;
|
|
682
682
|
}): Promise<ConnectAgentCredentialResult>;
|
package/dist/index.js
CHANGED
|
@@ -983,6 +983,13 @@ function providerParam(target) {
|
|
|
983
983
|
async function manageAgentCredentialMitra(options) {
|
|
984
984
|
var _a, _b, _c;
|
|
985
985
|
const projectId = resolveProjectId(options.projectId);
|
|
986
|
+
const target = options.target;
|
|
987
|
+
if ((options.action === "auth" || options.action === "connect") && target !== "anthropic") {
|
|
988
|
+
throw new Error(`manageAgentCredentialMitra(${options.action}): OAuth \xE9 exclusivo do provider 'anthropic'. Pra OpenAI use o device flow (device_auth/device_poll).`);
|
|
989
|
+
}
|
|
990
|
+
if ((options.action === "device_auth" || options.action === "device_poll") && target !== "openai") {
|
|
991
|
+
throw new Error(`manageAgentCredentialMitra(${options.action}): device flow \xE9 exclusivo do provider 'openai'. Pra Anthropic use OAuth (auth/connect).`);
|
|
992
|
+
}
|
|
986
993
|
switch (options.action) {
|
|
987
994
|
case "list_providers": {
|
|
988
995
|
const env = await http.get("/agentAiShortcut/listProviders", { projectId });
|