@mitralab.io/sdk-core 0.2.13 → 0.2.15
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/CHANGELOG.md +39 -0
- package/README.md +5 -2
- package/contracts/README.md +10 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.2.14/sdk-parity.json +2902 -0
- package/contracts/v0.2.15/sdk-parity.json +2902 -0
- package/dist/index.cjs +154 -2
- package/dist/index.d.cts +116 -4
- package/dist/index.d.ts +116 -4
- package/dist/index.js +154 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.2.15
|
|
6
|
+
|
|
7
|
+
- `messenger` manages the current app's account email templates on Messenger's
|
|
8
|
+
`/api/v1/email/templates` and `/api/v1/email/template-types` routes: `listEmailTemplates()`,
|
|
9
|
+
`getEmailTemplateType(type)`, `getEmailTemplate(type)`, `upsertEmailTemplate(type, input)`,
|
|
10
|
+
`previewEmailTemplate(type)` and `deleteEmailTemplate(type)`. `EmailTemplateType` is the four
|
|
11
|
+
types an app token may edit: `SIGN_IN`, `SSO_GUIDANCE`, `APP_USER_INVITED` and
|
|
12
|
+
`APP_ACCESS_REQUIRED`.
|
|
13
|
+
- The `appId` comes from `getAppId`, now passed to the messenger module too, never from the
|
|
14
|
+
caller; without it the app calls fail with `SdkCoreConfigurationError` before any request. The
|
|
15
|
+
`PUT` body is built field by field, so an untyped `appId` or `senderIdentityId` is dropped, and
|
|
16
|
+
`textBody` is left out when absent, which clears the saved one.
|
|
17
|
+
- `upsertEmailTemplate` saves and then renders the preview. A preview failure after a successful
|
|
18
|
+
save resolves with `preview: null` and the error in `previewError` instead of rejecting.
|
|
19
|
+
- Messenger refusals (`400` `TEMPLATE_MISSING_VARIABLE` or `VALIDATION_FAILED` for a blank
|
|
20
|
+
subject or HTML body, `403` `ACCESS_DENIED` for another app, no edit access or a type outside the
|
|
21
|
+
four, `404` on a delete without an app row) come from the transport unchanged.
|
|
22
|
+
- In responses `type` is a string, not `EmailTemplateType`: a console token also lists the
|
|
23
|
+
platform's other types, and a type Messenger opens later must not break the list.
|
|
24
|
+
|
|
25
|
+
## 0.2.14
|
|
26
|
+
|
|
27
|
+
- `messenger.sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` sends an email through
|
|
28
|
+
Messenger's `POST /api/v1/messages/send` as a `RAW` payload on the `EMAIL` channel and resolves
|
|
29
|
+
with the `messageId` of the accepted message. There is no `from`: Messenger sends with the
|
|
30
|
+
sender of the app in the token, so only the app's backend sends (a token exchanged from an api
|
|
31
|
+
key or the Server Function token). `to`, `cc` and `bcc` are lists with one address per entry;
|
|
32
|
+
absent optional fields are left out of the body.
|
|
33
|
+
- Recipient limits, the app's daily quota and the token check stay on Messenger. Their errors
|
|
34
|
+
(`400` above Messenger's recipient cap, `429` with `Retry-After` above the quota, `403` for an
|
|
35
|
+
app end-user token) come from the transport unchanged.
|
|
36
|
+
- `apps.update()` takes `emailLoginEnabled` and `passwordLoginEnabled`, sent on Code Studio's
|
|
37
|
+
`PATCH /api/v1/apps/{id}` only when supplied, so omission keeps the current value. Code Studio
|
|
38
|
+
rejects `passwordLoginEnabled: true` while the app inherits the platform login, with a `400`
|
|
39
|
+
and `PASSWORD_LOGIN_REQUIRES_EXCLUSIVE_MODE`, which comes from the transport unchanged.
|
|
40
|
+
- `AppDefinition` and `AppSummary` carry both fields when Code Studio returns them. The response
|
|
41
|
+
validator accepts their absence, as a Code Studio that predates them sends, and rejects a value
|
|
42
|
+
that is not a boolean.
|
|
43
|
+
|
|
5
44
|
## 0.2.13
|
|
6
45
|
|
|
7
46
|
- `AgentTurnUsage` gains `contextTokens` and `contextWindow`. `contextTokens` is the number of
|
package/README.md
CHANGED
|
@@ -66,7 +66,8 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
66
66
|
- `functions`, `publicFunctions`, `functionsAdmin` e `workflows`: executar e administrar Server Functions e workflows.
|
|
67
67
|
- `integration`, `integrationAdmin`, `integrationResources` e `integrationTemplates`: chamadas a APIs externas e a configuração delas.
|
|
68
68
|
- `agentTasks`, com `createAgentTaskSessionManager` e `withAgentTaskSessions`: chats de agente com `send`, `sendAndWait`, `cancel` e eventos. O gerenciador recebe `tasks`, o `eventSource` do seu SDK e `directChannel`, com o `apiUrl` do gateway e, se quiser, `WebSocket` e `fetch`.
|
|
69
|
-
- `apps`, `context`, `agents`, `agentConnections`, `agentCredentials`, `members`, `
|
|
69
|
+
- `apps`, `context`, `agents`, `agentConnections`, `agentCredentials`, `members`, `imports`, `dataSources` e `auth`: o app em si, a configuração de agentes e os demais recursos.
|
|
70
|
+
- `messenger`: `notify` avisa o usuário autenticado, `sendEmail` manda e-mail com o remetente do app, e `listEmailTemplates`, `getEmailTemplateType`, `getEmailTemplate`, `upsertEmailTemplate`, `previewEmailTemplate` e `deleteEmailTemplate` cuidam dos templates de e-mail de conta do app.
|
|
70
71
|
- `resolveApiKeyToken`, `readTokenAppId` e `tokenAuthorizesApp`: contrato da troca de API key por token, para o SDK que autentica por chave.
|
|
71
72
|
|
|
72
73
|
## Configuração
|
|
@@ -76,7 +77,7 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
76
77
|
| `transports.auth`, `dataManager`, `functions`, `integration` | sim | um `Transport` para cada serviço |
|
|
77
78
|
| `transports.codeStudio`, `copilot`, `messenger` | não | sem eles falham com `SdkCoreConfigurationError`, antes de sair a requisição: `apps` (`codeStudio`); `agentTasks`, `agentConnections`, `agentCredentials` e `agents.listModels` (`copilot`); `messenger`. O resto de `agents` usa `functions` |
|
|
78
79
|
| `transports.publicFunctions` | não | transporte anônimo de `publicFunctions`, sem `Authorization` nem `X-App-Id` |
|
|
79
|
-
| `getAppId` | não | devolve o app fixado pelo seu SDK; usado por `context`
|
|
80
|
+
| `getAppId` | não | devolve o app fixado pelo seu SDK; usado por `context` e pelos templates de e-mail do `messenger` |
|
|
80
81
|
| `functions.executeInvocationType` | não | `sync` ou `async` em `functions.execute`; sem valor, vale o padrão do servidor |
|
|
81
82
|
| `functions.emptyInput` | não | `empty-object` manda `{ "input": {} }` quando não há input; `omit-body` não manda corpo |
|
|
82
83
|
| `errors` | não | `SdkCoreErrorFactory` para o seu SDK lançar as próprias classes no lugar de `SdkCoreConfigurationError` e `SdkCoreResponseError` |
|
|
@@ -95,6 +96,8 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
95
96
|
- Fixe o app no adaptador: `getAppId` e o header `X-App-Id` vêm do valor configurado no seu SDK, nunca de um argumento de quem chama. Aplique as credenciais depois dos headers de `options`, como no exemplo, para que eles não as substituam.
|
|
96
97
|
- O Core não repete requisição nem renova token. Se o seu transporte repetir, repita só o que não grava.
|
|
97
98
|
- `publicFunctions` precisa de um transporte sem credencial. O Core não usa o transporte autenticado no lugar dele.
|
|
99
|
+
- `sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` não tem `from`: o Messenger usa o remetente do app do token. Por isso só o backend do app manda e-mail, com o token trocado pela API key ou o token da Server Function; token de usuário final do app recebe `403`. `to`, `cc` e `bcc` são listas com um endereço por item. Os limites ficam no Messenger e chegam como erro do seu `Transport`: `400` acima do limite de destinatários dele somando os três campos e `429` acima da cota diária do app, com o header `Retry-After` e `retry_after_seconds` no corpo.
|
|
100
|
+
- Templates de e-mail: os métodos do `messenger` cobrem os quatro tipos de conta que o app reescreve com o próprio token (`EmailTemplateType`: `SIGN_IN`, `SSO_GUIDANCE`, `APP_USER_INVITED` e `APP_ACCESS_REQUIRED`). O `appId` vem do `getAppId`, sem argumento de quem chama; sem ele, os métodos do app falham com `SdkCoreConfigurationError` antes da requisição. O Messenger aceita o token de app quando ele é do mesmo app e tem edição no app (`FUNCTION_WRITE`). `listEmailTemplates()` traz a linha do app e a da plataforma (`platformDefault: true`), então um tipo pode vir duas vezes; `getEmailTemplate(type)` devolve a do app ou, sem ela, a da plataforma. `getEmailTemplateType(type)` lista as variáveis, usadas como `$nome`; toda variável obrigatória precisa estar no assunto ou no HTML. `upsertEmailTemplate(type, { subject, htmlBody, textBody? })` substitui o template inteiro (sem `textBody`, o texto salvo antes some) e devolve `{ template, preview }`; se só o preview falhar, a promise resolve com `preview: null` e o erro em `previewError`, porque o template já está salvo. O preview mostra o template salvo (ou o da plataforma) com os valores de exemplo do catálogo; ele não prova qual HTML sai no envio, porque isso depende do remetente do app e da política de marca. `deleteEmailTemplate(type)` volta ao texto da plataforma. As recusas chegam como erro do seu `Transport`, com o `error_code` do Messenger: `400` `TEMPLATE_MISSING_VARIABLE` (variável obrigatória faltando) ou `VALIDATION_FAILED` (assunto ou HTML em branco), `403` `ACCESS_DENIED` (outro app, sem edição no app ou tipo fora dos quatro) e, no delete sem versão do app, `404`. Na resposta, `type` vem como string: com token de console a lista traz também os outros tipos da plataforma.
|
|
98
101
|
- `sendAndWait` com `timeoutMs` ou `signal` só para de esperar; o turno continua no servidor. Para interromper, chame `cancel()`.
|
|
99
102
|
- `cancel()` chamado antes de a box aceitar o prompt espera esse aceite e só então manda o stop; a promise resolve depois disso. Se o prompt não chegar a virar turno, nada é enviado e o status não passa por `cancelled`.
|
|
100
103
|
- O `open()` do seu `eventSource` só deve resolver depois que o stream estiver conectado, para nenhum evento do turno se perder.
|
package/contracts/README.md
CHANGED
|
@@ -24,6 +24,16 @@ publishes.
|
|
|
24
24
|
|
|
25
25
|
## Versions
|
|
26
26
|
|
|
27
|
+
- `0.2.15` is the `0.2.14` parity surface republished with the app email template methods of
|
|
28
|
+
`messenger` (`listEmailTemplates`, `getEmailTemplate`, `getEmailTemplateType`, `upsertEmailTemplate`,
|
|
29
|
+
`previewEmailTemplate` and `deleteEmailTemplate`), which the parity cases do not cover. Same parity
|
|
30
|
+
cases; the version exists so a consumer pinning the package can pin a corpus with the same number.
|
|
31
|
+
|
|
32
|
+
- `0.2.14` is the `0.2.13` parity surface republished with `messenger.sendEmail()` and the
|
|
33
|
+
`emailLoginEnabled` and `passwordLoginEnabled` fields of `apps.update()`, which the parity cases do
|
|
34
|
+
not cover. Same parity cases; the version exists so a consumer pinning the package can pin a corpus
|
|
35
|
+
with the same number.
|
|
36
|
+
|
|
27
37
|
- `0.2.13` is the `0.2.12` parity surface republished with the occupied context of the chat:
|
|
28
38
|
`contextTokens` and `contextWindow` on `AgentTurnUsage`, which the parity cases do not cover.
|
|
29
39
|
Same parity cases; the version exists so a consumer pinning the package can pin a corpus with
|
package/contracts/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contract": "SDK-PARITY-001",
|
|
3
|
-
"current": "0.2.
|
|
3
|
+
"current": "0.2.15",
|
|
4
4
|
"versions": [
|
|
5
5
|
{
|
|
6
6
|
"version": "0.1.0",
|
|
@@ -120,6 +120,16 @@
|
|
|
120
120
|
"version": "0.2.13",
|
|
121
121
|
"path": "v0.2.13/sdk-parity.json",
|
|
122
122
|
"sha256": "36a1dd5b8d0ab604a8baa68ce19823c9b2f2745cdf57fad9000917b83c60be20"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"version": "0.2.14",
|
|
126
|
+
"path": "v0.2.14/sdk-parity.json",
|
|
127
|
+
"sha256": "112e7eb52bd4362737ef03efff2cad4f529e41d5ac8ccda442e57c09b2e3c459"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"version": "0.2.15",
|
|
131
|
+
"path": "v0.2.15/sdk-parity.json",
|
|
132
|
+
"sha256": "3105726d7e2363f6ad2bc8abe5d0f1ac3407c5bab8a3c0ab44d72d517309b016"
|
|
123
133
|
}
|
|
124
134
|
]
|
|
125
135
|
}
|