mitra-interactions-sdk 1.0.66 → 1.0.68-beta.0

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/dist/index.d.mts CHANGED
@@ -756,8 +756,13 @@ interface AgentTaskSession {
756
756
  readonly history: ReadonlyArray<AgentMessage>;
757
757
  readonly content: string;
758
758
  readonly queue: ReadonlyArray<QueuedItem>;
759
+ /**
760
+ * `userId`: dono da task, para um token ou chave dev/admin ler o historico de um chat de outro
761
+ * usuario do mesmo projeto. Ignorado para qualquer outro token.
762
+ */
759
763
  loadHistory(options?: {
760
764
  limit?: number;
765
+ userId?: string | number;
761
766
  }): Promise<AgentMessage[]>;
762
767
  close(): void;
763
768
  send(prompt: string, options?: SendOptions): void;
@@ -1408,4 +1413,27 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
1408
1413
  */
1409
1414
  declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
1410
1415
 
1411
- export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteFileOptions, type DeleteFileResponse, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type DownloadFileOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type FileLinkOptions, type FileLinkResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type RunActionOptions, type RunActionResponse, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
1416
+ /**
1417
+ * Prova de execução de Server Function (TKT-ecc38de6 / TKT-000a0394).
1418
+ *
1419
+ * O contrato de anexos privados manda a tela de usuário final pedir o arquivo a uma Server
1420
+ * Function, que valida o registro dono e só então pede o link/download ao backend. O backend
1421
+ * libera o acesso por chave quando a requisição traz o header `X-SF-Execution-Token` — um token
1422
+ * assinado que SÓ o sandbox da execução recebe, como variável de ambiente
1423
+ * `MITRA_SF_EXECUTION_TOKEN`. Até aqui nenhuma SDK repassava esse token, então o caminho não
1424
+ * funcionava e quem precisava de tela com anexo caía no upload público.
1425
+ *
1426
+ * Regras:
1427
+ * - só em Node (sem `window`): no navegador a variável não existe e o header nunca deve sair;
1428
+ * - só quando a variável está preenchida; vazio/ausente = nada muda;
1429
+ * - só para o backend principal (baseURL). O serviço de integrações não recebe a prova.
1430
+ */
1431
+ declare const SF_EXECUTION_TOKEN_ENV = "MITRA_SF_EXECUTION_TOKEN";
1432
+ declare const SF_EXECUTION_TOKEN_HEADER = "X-SF-Execution-Token";
1433
+ type EnvLike = Record<string, string | undefined> | undefined;
1434
+ /**
1435
+ * Token de prova da execução corrente, ou null quando não estamos dentro de uma Server Function.
1436
+ */
1437
+ declare function readServerFunctionProof(env?: EnvLike, hasWindow?: boolean): string | null;
1438
+
1439
+ export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteFileOptions, type DeleteFileResponse, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type DownloadFileOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type FileLinkOptions, type FileLinkResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type RunActionOptions, type RunActionResponse, SF_EXECUTION_TOKEN_ENV, SF_EXECUTION_TOKEN_HEADER, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, readServerFunctionProof, refreshTokenSilently, resetPasswordMitra, resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
package/dist/index.d.ts CHANGED
@@ -756,8 +756,13 @@ interface AgentTaskSession {
756
756
  readonly history: ReadonlyArray<AgentMessage>;
757
757
  readonly content: string;
758
758
  readonly queue: ReadonlyArray<QueuedItem>;
759
+ /**
760
+ * `userId`: dono da task, para um token ou chave dev/admin ler o historico de um chat de outro
761
+ * usuario do mesmo projeto. Ignorado para qualquer outro token.
762
+ */
759
763
  loadHistory(options?: {
760
764
  limit?: number;
765
+ userId?: string | number;
761
766
  }): Promise<AgentMessage[]>;
762
767
  close(): void;
763
768
  send(prompt: string, options?: SendOptions): void;
@@ -1408,4 +1413,27 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
1408
1413
  */
1409
1414
  declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
1410
1415
 
1411
- export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteFileOptions, type DeleteFileResponse, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type DownloadFileOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type FileLinkOptions, type FileLinkResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type RunActionOptions, type RunActionResponse, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
1416
+ /**
1417
+ * Prova de execução de Server Function (TKT-ecc38de6 / TKT-000a0394).
1418
+ *
1419
+ * O contrato de anexos privados manda a tela de usuário final pedir o arquivo a uma Server
1420
+ * Function, que valida o registro dono e só então pede o link/download ao backend. O backend
1421
+ * libera o acesso por chave quando a requisição traz o header `X-SF-Execution-Token` — um token
1422
+ * assinado que SÓ o sandbox da execução recebe, como variável de ambiente
1423
+ * `MITRA_SF_EXECUTION_TOKEN`. Até aqui nenhuma SDK repassava esse token, então o caminho não
1424
+ * funcionava e quem precisava de tela com anexo caía no upload público.
1425
+ *
1426
+ * Regras:
1427
+ * - só em Node (sem `window`): no navegador a variável não existe e o header nunca deve sair;
1428
+ * - só quando a variável está preenchida; vazio/ausente = nada muda;
1429
+ * - só para o backend principal (baseURL). O serviço de integrações não recebe a prova.
1430
+ */
1431
+ declare const SF_EXECUTION_TOKEN_ENV = "MITRA_SF_EXECUTION_TOKEN";
1432
+ declare const SF_EXECUTION_TOKEN_HEADER = "X-SF-Execution-Token";
1433
+ type EnvLike = Record<string, string | undefined> | undefined;
1434
+ /**
1435
+ * Token de prova da execução corrente, ou null quando não estamos dentro de uma Server Function.
1436
+ */
1437
+ declare function readServerFunctionProof(env?: EnvLike, hasWindow?: boolean): string | null;
1438
+
1439
+ export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteFileOptions, type DeleteFileResponse, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type DownloadFileOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type FileLinkOptions, type FileLinkResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type RunActionOptions, type RunActionResponse, SF_EXECUTION_TOKEN_ENV, SF_EXECUTION_TOKEN_HEADER, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, readServerFunctionProof, refreshTokenSilently, resetPasswordMitra, resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
package/dist/index.js CHANGED
@@ -361,6 +361,28 @@ async function resetPasswordMitra(options) {
361
361
  });
362
362
  }
363
363
 
364
+ // src/sf-proof.ts
365
+ var SF_EXECUTION_TOKEN_ENV = "MITRA_SF_EXECUTION_TOKEN";
366
+ var SF_EXECUTION_TOKEN_HEADER = "X-SF-Execution-Token";
367
+ function defaultEnv() {
368
+ const proc = globalThis.process;
369
+ return proc == null ? void 0 : proc.env;
370
+ }
371
+ function defaultHasWindow() {
372
+ return typeof globalThis.window !== "undefined";
373
+ }
374
+ function readServerFunctionProof(env = defaultEnv(), hasWindow = defaultHasWindow()) {
375
+ if (hasWindow) return null;
376
+ const raw = env == null ? void 0 : env[SF_EXECUTION_TOKEN_ENV];
377
+ if (typeof raw !== "string") return null;
378
+ const token = raw.trim();
379
+ return token.length > 0 ? token : null;
380
+ }
381
+ function withServerFunctionProof(headers, proof = readServerFunctionProof()) {
382
+ if (!proof) return headers;
383
+ return { ...headers, [SF_EXECUTION_TOKEN_HEADER]: proof };
384
+ }
385
+
364
386
  // src/client.ts
365
387
  function getFetch2() {
366
388
  if (typeof globalThis.fetch === "function") {
@@ -375,7 +397,7 @@ function buildHeaders() {
375
397
  const config = getConfig();
376
398
  const headers = { "Content-Type": "application/json" };
377
399
  if (config.token) headers["Authorization"] = formatToken(config.token);
378
- return headers;
400
+ return withServerFunctionProof(headers);
379
401
  }
380
402
  function buildUrl(endpoint, params) {
381
403
  const config = getConfig();
@@ -483,7 +505,7 @@ var http = {
483
505
  if (config.token) headers["Authorization"] = formatToken(config.token);
484
506
  return fetchWithRefresh(buildUrl(endpoint), {
485
507
  method: "POST",
486
- headers,
508
+ headers: withServerFunctionProof(headers),
487
509
  body: formData
488
510
  });
489
511
  },
@@ -1066,6 +1088,7 @@ var AgentTaskSession = class {
1066
1088
  const payload = { taskId: this._taskId };
1067
1089
  if (this._projectId != null) payload.projectId = this._projectId;
1068
1090
  if ((options == null ? void 0 : options.limit) != null) payload.limit = options.limit;
1091
+ if ((options == null ? void 0 : options.userId) != null && options.userId !== "") payload.userId = options.userId;
1069
1092
  const msgs = await this._transport.request("get_history", payload);
1070
1093
  this._history = msgs;
1071
1094
  this._emit("historyLoaded", msgs);
@@ -2310,6 +2333,8 @@ function resolveProjectId2(projectId) {
2310
2333
  throw new Error("projectId \xE9 obrigat\xF3rio. Passe nas options ou configure via configureSdkMitra({ projectId }).");
2311
2334
  }
2312
2335
 
2336
+ exports.SF_EXECUTION_TOKEN_ENV = SF_EXECUTION_TOKEN_ENV;
2337
+ exports.SF_EXECUTION_TOKEN_HEADER = SF_EXECUTION_TOKEN_HEADER;
2313
2338
  exports.callIntegrationMitra = callIntegrationMitra;
2314
2339
  exports.closeChatMitra = closeChatMitra;
2315
2340
  exports.configureSdkMitra = configureSdkMitra;
@@ -2350,6 +2375,7 @@ exports.manageAgentChatMitra = manageAgentChatMitra;
2350
2375
  exports.manageAgentCredentialMitra = manageAgentCredentialMitra;
2351
2376
  exports.openChatMitra = openChatMitra;
2352
2377
  exports.patchRecordMitra = patchRecordMitra;
2378
+ exports.readServerFunctionProof = readServerFunctionProof;
2353
2379
  exports.refreshTokenSilently = refreshTokenSilently;
2354
2380
  exports.resetPasswordMitra = resetPasswordMitra;
2355
2381
  exports.resolveProjectId = resolveProjectId2;