mitra-interactions-sdk 1.0.60-beta.44 → 1.0.60-beta.46
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 +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +9 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -301,7 +301,7 @@ const existing = getAgentTaskMitra({ taskId: 'uuid-da-task' });
|
|
|
301
301
|
await existing.loadHistory({ limit: 50 });
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
`getAgentTaskMitra({ create: true, agentType?, name?, agentId?, reasoningEffort?, transport?, userId? })` ou `getAgentTaskMitra({ taskId, transport
|
|
304
|
+
`getAgentTaskMitra({ create: true, agentType?, name?, agentId?, reasoningEffort?, transport?, userId? })` ou `getAgentTaskMitra({ taskId, transport? })`.
|
|
305
305
|
|
|
306
306
|
**Agente autônomo**: a autonomia é **propriedade do AGENTE** (`autonomous` em `createAgentMitra`/`updateAgentMitra`, no `mitra-sdk`) — não existe flag na criação do chat. Ao criar um chat contra um agente autônomo (`getAgentTaskMitra({ create: true, agentId })`), o copilot deriva a autonomia do agente e o chat já nasce **sem dono** (`user_id NULL` — a dona é o agente), usando a connection anexada ao agente como credencial. Exige auth `AGENT_WRITE` (chave de SF ou token de app EDIT) — usuário business comum não abre chat autônomo. Depois de criado, dirigir/listar é igual ao chat normal (`getAgentTaskMitra({ taskId })`, `send`, `manageAgentChatMitra({ list, agentId })`).
|
|
307
307
|
|
|
@@ -313,11 +313,11 @@ await existing.loadHistory({ limit: 50 });
|
|
|
313
313
|
```typescript
|
|
314
314
|
// SF reagindo a webhook: continua a thread da pessoa atendida
|
|
315
315
|
const task = getAgentTaskMitra({ create: true, agentId, userId: 'uuid-do-usuario' }); // chat nasce DELE
|
|
316
|
-
const dela = await manageAgentChatMitra({ action: 'list', userId: 'uuid-do-usuario' }); // chats DELA
|
|
317
|
-
const mesma = getAgentTaskMitra({ taskId
|
|
316
|
+
const dela = await manageAgentChatMitra({ action: 'list', userId: 'uuid-do-usuario' }); // chats DELA (debug/observabilidade)
|
|
317
|
+
const mesma = getAgentTaskMitra({ taskId }); // depois do create, SÓ taskId — o dono é inferido dele
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
Erros nomeados: `403` sem `AGENT_WRITE`; `400 AUTONOMOUS_TASK_HAS_NO_OWNER` (userId + agente autônomo é contradição); `
|
|
320
|
+
**`userId` é atributo do CHAT, não argumento das operações**: só o `create` (e o `list`, pra observabilidade) aceitam — prompt, histórico, eventos e `readChat` continuam só com `taskId`, e o backend não aceita `userId` neles. Erros nomeados: `403` sem `AGENT_WRITE`; `400 AUTONOMOUS_TASK_HAS_NO_OWNER` (userId + agente autônomo é contradição); `400 ANONYMOUS_CALLER_REQUIRES_OWNER` (contexto anônimo criando chat de agente normal exige userId). Nunca invente `userId` de texto do usuário — use o id do vínculo canal→usuário da sua aplicação.
|
|
321
321
|
|
|
322
322
|
#### Propriedades (somente leitura)
|
|
323
323
|
|
package/dist/index.d.mts
CHANGED
|
@@ -343,12 +343,6 @@ interface GetAgentTaskOpenOptions {
|
|
|
343
343
|
projectId?: number | string;
|
|
344
344
|
/** Transporte do prompt (default 'ws'). */
|
|
345
345
|
transport?: AgentTaskTransport;
|
|
346
|
-
/**
|
|
347
|
-
* Validação defensiva ao agir em nome do dono (AGENT_WRITE): viaja no
|
|
348
|
-
* readChat e nos inputs — o backend devolve 404 se o chat não pertencer a
|
|
349
|
-
* esse usuário. Omitido = contexto do caller.
|
|
350
|
-
*/
|
|
351
|
-
userId?: string;
|
|
352
346
|
}
|
|
353
347
|
type GetAgentTaskOptions = GetAgentTaskCreateOptions | GetAgentTaskOpenOptions;
|
|
354
348
|
type AgentTaskStatus = 'opening' | 'idle' | 'streaming' | 'cancelled' | 'error' | 'closed';
|
package/dist/index.d.ts
CHANGED
|
@@ -343,12 +343,6 @@ interface GetAgentTaskOpenOptions {
|
|
|
343
343
|
projectId?: number | string;
|
|
344
344
|
/** Transporte do prompt (default 'ws'). */
|
|
345
345
|
transport?: AgentTaskTransport;
|
|
346
|
-
/**
|
|
347
|
-
* Validação defensiva ao agir em nome do dono (AGENT_WRITE): viaja no
|
|
348
|
-
* readChat e nos inputs — o backend devolve 404 se o chat não pertencer a
|
|
349
|
-
* esse usuário. Omitido = contexto do caller.
|
|
350
|
-
*/
|
|
351
|
-
userId?: string;
|
|
352
346
|
}
|
|
353
347
|
type GetAgentTaskOptions = GetAgentTaskCreateOptions | GetAgentTaskOpenOptions;
|
|
354
348
|
type AgentTaskStatus = 'opening' | 'idle' | 'streaming' | 'cancelled' | 'error' | 'closed';
|
package/dist/index.js
CHANGED
|
@@ -67,9 +67,11 @@ var SSO_AUTH_PAGE_URL = "https://beta.infusion.cloud/sdk-auth.html";
|
|
|
67
67
|
async function fetchSsoAuthPageUrl(_baseURL) {
|
|
68
68
|
const config = isConfigured() ? getConfig() : null;
|
|
69
69
|
if (config == null ? void 0 : config.authPageUrl) return config.authPageUrl;
|
|
70
|
+
const injected = readInjectedEnv().authPageUrl;
|
|
71
|
+
if (injected) return injected;
|
|
70
72
|
return SSO_AUTH_PAGE_URL;
|
|
71
73
|
}
|
|
72
|
-
var SSO_ENABLED_PROVIDERS = ["google"];
|
|
74
|
+
var SSO_ENABLED_PROVIDERS = ["google", "microsoft"];
|
|
73
75
|
function providerLabel(provider) {
|
|
74
76
|
return provider === "microsoft" ? "Microsoft" : provider === "google" ? "Google" : provider;
|
|
75
77
|
}
|
|
@@ -505,8 +507,8 @@ var AgentTaskSession = class {
|
|
|
505
507
|
this._isNew = init.kind === "new";
|
|
506
508
|
this._transport = (_a = init.transport) != null ? _a : "ws";
|
|
507
509
|
this._projectId = init.projectId;
|
|
508
|
-
this._userId = init.userId;
|
|
509
510
|
if (init.kind === "new") {
|
|
511
|
+
this._userId = init.userId;
|
|
510
512
|
this._agentType = (_b = init.agentType) != null ? _b : DEFAULT_AGENT_TYPE;
|
|
511
513
|
this._initialName = init.name;
|
|
512
514
|
this._agentId = init.agentId;
|
|
@@ -544,7 +546,7 @@ var AgentTaskSession = class {
|
|
|
544
546
|
// ── Abertura de chat existente ─────────
|
|
545
547
|
async _openExisting(taskId) {
|
|
546
548
|
try {
|
|
547
|
-
const t = await readChatTask(taskId, this._projectId
|
|
549
|
+
const t = await readChatTask(taskId, this._projectId);
|
|
548
550
|
this._task = toAgentChat(t);
|
|
549
551
|
this._agentType = this._task.agentType;
|
|
550
552
|
if (this._status === "opening") this._setStatus("idle");
|
|
@@ -748,7 +750,6 @@ var AgentTaskSession = class {
|
|
|
748
750
|
throw new Error("AgentTaskSession: sem taskId \u2014 task ainda n\xE3o criada.");
|
|
749
751
|
}
|
|
750
752
|
if (isTokenExpiring()) await tryRefreshToken();
|
|
751
|
-
const payload = this._userId ? { ...body, userId: this._userId } : body;
|
|
752
753
|
const doPost = async () => fetch(
|
|
753
754
|
`${getTaskHttpBase()}/${encodeURIComponent(this._taskId)}/inputs`,
|
|
754
755
|
{
|
|
@@ -757,7 +758,7 @@ var AgentTaskSession = class {
|
|
|
757
758
|
"Content-Type": "application/json",
|
|
758
759
|
Authorization: `Bearer ${getRawToken()}`
|
|
759
760
|
},
|
|
760
|
-
body: JSON.stringify(
|
|
761
|
+
body: JSON.stringify(body)
|
|
761
762
|
}
|
|
762
763
|
);
|
|
763
764
|
let res = await doPost();
|
|
@@ -1107,13 +1108,10 @@ async function createChatTask(options) {
|
|
|
1107
1108
|
});
|
|
1108
1109
|
return env.result;
|
|
1109
1110
|
}
|
|
1110
|
-
async function readChatTask(taskId, projectId
|
|
1111
|
+
async function readChatTask(taskId, projectId) {
|
|
1111
1112
|
const env = await http.get("/agentAiShortcut/readChat", {
|
|
1112
1113
|
projectId: resolveProjectId(projectId),
|
|
1113
|
-
taskId
|
|
1114
|
-
// Validação defensiva: com userId, o backend devolve 404 se o chat não
|
|
1115
|
-
// pertencer àquele dono.
|
|
1116
|
-
...userId ? { userId } : {}
|
|
1114
|
+
taskId
|
|
1117
1115
|
});
|
|
1118
1116
|
return env.result;
|
|
1119
1117
|
}
|
|
@@ -1178,8 +1176,7 @@ function getAgentTaskMitra(options) {
|
|
|
1178
1176
|
kind: "existing",
|
|
1179
1177
|
taskId: options.taskId,
|
|
1180
1178
|
projectId: options.projectId,
|
|
1181
|
-
transport: options.transport
|
|
1182
|
-
userId: options.userId
|
|
1179
|
+
transport: options.transport
|
|
1183
1180
|
});
|
|
1184
1181
|
}
|
|
1185
1182
|
if ("create" in options && options.create) {
|