@mitralab.io/sdk-core 0.2.12 → 0.2.14
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 +30 -0
- package/README.md +3 -1
- package/contracts/README.md +10 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.2.13/sdk-parity.json +2902 -0
- package/contracts/v0.2.14/sdk-parity.json +2902 -0
- package/dist/index.cjs +29 -1
- package/dist/index.d.cts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +29 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -508,6 +508,9 @@ function expectAppFields(app, context, errors) {
|
|
|
508
508
|
if (!isNullableString(app.icon)) invalidField(context, "icon", errors);
|
|
509
509
|
if (!isNullableString(app.template)) invalidField(context, "template", errors);
|
|
510
510
|
if (typeof app.allowSignup !== "boolean") invalidField(context, "allowSignup", errors);
|
|
511
|
+
for (const field of ["emailLoginEnabled", "passwordLoginEnabled"]) {
|
|
512
|
+
if (field in app && typeof app[field] !== "boolean") invalidField(context, field, errors);
|
|
513
|
+
}
|
|
511
514
|
if (typeof app.externalAccessEnabled !== "boolean") {
|
|
512
515
|
invalidField(context, "externalAccessEnabled", errors);
|
|
513
516
|
}
|
|
@@ -1029,7 +1032,8 @@ var TURN_USAGE_COUNTS = [
|
|
|
1029
1032
|
"cacheReadTokens",
|
|
1030
1033
|
"cacheCreationTokens",
|
|
1031
1034
|
"requestCount",
|
|
1032
|
-
"durationMs"
|
|
1035
|
+
"durationMs",
|
|
1036
|
+
"contextTokens"
|
|
1033
1037
|
];
|
|
1034
1038
|
var TURN_USAGE_COSTS = ["costUsd", "costUsdRaw"];
|
|
1035
1039
|
var TURN_USAGE_STRINGS = [
|
|
@@ -1057,6 +1061,8 @@ function agentTurnUsageOf(value) {
|
|
|
1057
1061
|
const item = value[field];
|
|
1058
1062
|
if (isCount(item)) usage[field] = item;
|
|
1059
1063
|
}
|
|
1064
|
+
const { contextWindow } = value;
|
|
1065
|
+
if (isInteger(contextWindow) && contextWindow > 0) usage.contextWindow = contextWindow;
|
|
1060
1066
|
for (const field of TURN_USAGE_COSTS) {
|
|
1061
1067
|
const item = value[field];
|
|
1062
1068
|
if (isFiniteNumber(item)) usage[field] = item;
|
|
@@ -2929,9 +2935,31 @@ function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
|
2929
2935
|
"Notify user response",
|
|
2930
2936
|
errors
|
|
2931
2937
|
);
|
|
2938
|
+
},
|
|
2939
|
+
async sendEmail(input) {
|
|
2940
|
+
return expectMessageAccepted(
|
|
2941
|
+
await transport.request("/api/v1/messages/send", {
|
|
2942
|
+
method: "POST",
|
|
2943
|
+
body: { channel: "EMAIL", payload: rawEmailPayload(input) }
|
|
2944
|
+
}),
|
|
2945
|
+
"Send email response",
|
|
2946
|
+
errors
|
|
2947
|
+
);
|
|
2932
2948
|
}
|
|
2933
2949
|
};
|
|
2934
2950
|
}
|
|
2951
|
+
function rawEmailPayload(input) {
|
|
2952
|
+
return {
|
|
2953
|
+
type: "RAW",
|
|
2954
|
+
to: input.to,
|
|
2955
|
+
...input.cc === void 0 ? {} : { cc: input.cc },
|
|
2956
|
+
...input.bcc === void 0 ? {} : { bcc: input.bcc },
|
|
2957
|
+
...input.replyTo === void 0 ? {} : { replyTo: input.replyTo },
|
|
2958
|
+
subject: input.subject,
|
|
2959
|
+
html: input.html,
|
|
2960
|
+
...input.text === void 0 ? {} : { text: input.text }
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2935
2963
|
|
|
2936
2964
|
// src/modules/publicFunctions.ts
|
|
2937
2965
|
function createPublicFunctionsModule(transport, errors = defaultSdkCoreErrorFactory) {
|
package/dist/index.d.cts
CHANGED
|
@@ -589,6 +589,13 @@ interface AppUpdateInput {
|
|
|
589
589
|
icon?: string;
|
|
590
590
|
/** Whether users may sign up through this app. Omission preserves the current value. */
|
|
591
591
|
allowSignup?: boolean;
|
|
592
|
+
/** Whether users may sign in with a code sent by email. Omission preserves the current value. */
|
|
593
|
+
emailLoginEnabled?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Whether users may sign in with a password. Omission preserves the current value. Code Studio
|
|
596
|
+
* rejects `true` while the app inherits the platform login.
|
|
597
|
+
*/
|
|
598
|
+
passwordLoginEnabled?: boolean;
|
|
592
599
|
}
|
|
593
600
|
interface AppDomain {
|
|
594
601
|
hostname: string;
|
|
@@ -610,6 +617,10 @@ interface AppSummary {
|
|
|
610
617
|
template: string | null;
|
|
611
618
|
planId: string;
|
|
612
619
|
allowSignup: boolean;
|
|
620
|
+
/** Absent on a Code Studio that predates email login. */
|
|
621
|
+
emailLoginEnabled?: boolean;
|
|
622
|
+
/** Absent on a Code Studio that predates password login. */
|
|
623
|
+
passwordLoginEnabled?: boolean;
|
|
613
624
|
externalAccessEnabled: boolean;
|
|
614
625
|
currentVersion: AppVersion | null;
|
|
615
626
|
createdAt: string;
|
|
@@ -630,6 +641,10 @@ interface AppDefinition {
|
|
|
630
641
|
planId: string;
|
|
631
642
|
template: string | null;
|
|
632
643
|
allowSignup: boolean;
|
|
644
|
+
/** Absent on a Code Studio that predates email login. */
|
|
645
|
+
emailLoginEnabled?: boolean;
|
|
646
|
+
/** Absent on a Code Studio that predates password login. */
|
|
647
|
+
passwordLoginEnabled?: boolean;
|
|
633
648
|
externalAccessEnabled: boolean;
|
|
634
649
|
currentVersion: AppVersion | null;
|
|
635
650
|
createdAt: string;
|
|
@@ -1137,6 +1152,18 @@ interface AgentTurnUsage {
|
|
|
1137
1152
|
* the history and in a recovered turn, never in the live `turnEnd`.
|
|
1138
1153
|
*/
|
|
1139
1154
|
requestMessageId?: string;
|
|
1155
|
+
/**
|
|
1156
|
+
* Tokens occupying the chat's context window at the end of the turn: the prompt of the last
|
|
1157
|
+
* request of the main conversation, cache included, subagents excluded. Sent by the box in
|
|
1158
|
+
* `stepFinish`: live in `turnEnd` and in the history. Absent from older boxes and older turns.
|
|
1159
|
+
*/
|
|
1160
|
+
contextTokens?: number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Size of the model's context window, in tokens, always positive. Sent by the box in
|
|
1163
|
+
* `stepFinish`: live in `turnEnd` and in the history. Absent when the box does not know it, and
|
|
1164
|
+
* from older boxes and older turns.
|
|
1165
|
+
*/
|
|
1166
|
+
contextWindow?: number;
|
|
1140
1167
|
}
|
|
1141
1168
|
interface AgentMessage {
|
|
1142
1169
|
id: string;
|
|
@@ -1254,9 +1281,28 @@ interface AgentConnection {
|
|
|
1254
1281
|
customProviders?: AgentConnectionCustomProvider[];
|
|
1255
1282
|
}
|
|
1256
1283
|
interface MessageAccepted {
|
|
1257
|
-
/** Identifier assigned by Messenger to the accepted
|
|
1284
|
+
/** Identifier assigned by Messenger to the accepted message. */
|
|
1258
1285
|
messageId: string;
|
|
1259
1286
|
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Email sent with the app's sender. There is no `from` because Messenger picks the sender from
|
|
1289
|
+
* the app in the token, and only the app's backend sends: a token exchanged from an api key or
|
|
1290
|
+
* the Server Function token. An app end-user token is refused with `403`. Recipient and content
|
|
1291
|
+
* rules, such as Messenger's cap on recipients across `to`, `cc` and `bcc`, are enforced there.
|
|
1292
|
+
*/
|
|
1293
|
+
interface SendEmailInput {
|
|
1294
|
+
/** One address per entry. */
|
|
1295
|
+
to: string[];
|
|
1296
|
+
/** One address per entry. */
|
|
1297
|
+
cc?: string[];
|
|
1298
|
+
/** One address per entry. */
|
|
1299
|
+
bcc?: string[];
|
|
1300
|
+
replyTo?: string;
|
|
1301
|
+
subject: string;
|
|
1302
|
+
html: string;
|
|
1303
|
+
/** Plain-text alternative for clients that do not render HTML. */
|
|
1304
|
+
text?: string;
|
|
1305
|
+
}
|
|
1260
1306
|
interface AppContext {
|
|
1261
1307
|
appId: string;
|
|
1262
1308
|
app: AppDefinition;
|
|
@@ -1747,6 +1793,8 @@ declare function createMembersModule(transport: Transport, errors?: SdkCoreError
|
|
|
1747
1793
|
interface MessengerModule {
|
|
1748
1794
|
/** Sends plain text to the authenticated user; channel rendering may support markdown. */
|
|
1749
1795
|
notify(content: string): Promise<MessageAccepted>;
|
|
1796
|
+
/** Sends an email from the app's sender; only the app's backend token may send. */
|
|
1797
|
+
sendEmail(input: SendEmailInput): Promise<MessageAccepted>;
|
|
1750
1798
|
}
|
|
1751
1799
|
declare function createMessengerModule(transport: Transport, errors?: SdkCoreErrorFactory): MessengerModule;
|
|
1752
1800
|
|
|
@@ -2140,4 +2188,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
2140
2188
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
2141
2189
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
2142
2190
|
|
|
2143
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2191
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SendEmailInput, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
package/dist/index.d.ts
CHANGED
|
@@ -589,6 +589,13 @@ interface AppUpdateInput {
|
|
|
589
589
|
icon?: string;
|
|
590
590
|
/** Whether users may sign up through this app. Omission preserves the current value. */
|
|
591
591
|
allowSignup?: boolean;
|
|
592
|
+
/** Whether users may sign in with a code sent by email. Omission preserves the current value. */
|
|
593
|
+
emailLoginEnabled?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Whether users may sign in with a password. Omission preserves the current value. Code Studio
|
|
596
|
+
* rejects `true` while the app inherits the platform login.
|
|
597
|
+
*/
|
|
598
|
+
passwordLoginEnabled?: boolean;
|
|
592
599
|
}
|
|
593
600
|
interface AppDomain {
|
|
594
601
|
hostname: string;
|
|
@@ -610,6 +617,10 @@ interface AppSummary {
|
|
|
610
617
|
template: string | null;
|
|
611
618
|
planId: string;
|
|
612
619
|
allowSignup: boolean;
|
|
620
|
+
/** Absent on a Code Studio that predates email login. */
|
|
621
|
+
emailLoginEnabled?: boolean;
|
|
622
|
+
/** Absent on a Code Studio that predates password login. */
|
|
623
|
+
passwordLoginEnabled?: boolean;
|
|
613
624
|
externalAccessEnabled: boolean;
|
|
614
625
|
currentVersion: AppVersion | null;
|
|
615
626
|
createdAt: string;
|
|
@@ -630,6 +641,10 @@ interface AppDefinition {
|
|
|
630
641
|
planId: string;
|
|
631
642
|
template: string | null;
|
|
632
643
|
allowSignup: boolean;
|
|
644
|
+
/** Absent on a Code Studio that predates email login. */
|
|
645
|
+
emailLoginEnabled?: boolean;
|
|
646
|
+
/** Absent on a Code Studio that predates password login. */
|
|
647
|
+
passwordLoginEnabled?: boolean;
|
|
633
648
|
externalAccessEnabled: boolean;
|
|
634
649
|
currentVersion: AppVersion | null;
|
|
635
650
|
createdAt: string;
|
|
@@ -1137,6 +1152,18 @@ interface AgentTurnUsage {
|
|
|
1137
1152
|
* the history and in a recovered turn, never in the live `turnEnd`.
|
|
1138
1153
|
*/
|
|
1139
1154
|
requestMessageId?: string;
|
|
1155
|
+
/**
|
|
1156
|
+
* Tokens occupying the chat's context window at the end of the turn: the prompt of the last
|
|
1157
|
+
* request of the main conversation, cache included, subagents excluded. Sent by the box in
|
|
1158
|
+
* `stepFinish`: live in `turnEnd` and in the history. Absent from older boxes and older turns.
|
|
1159
|
+
*/
|
|
1160
|
+
contextTokens?: number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Size of the model's context window, in tokens, always positive. Sent by the box in
|
|
1163
|
+
* `stepFinish`: live in `turnEnd` and in the history. Absent when the box does not know it, and
|
|
1164
|
+
* from older boxes and older turns.
|
|
1165
|
+
*/
|
|
1166
|
+
contextWindow?: number;
|
|
1140
1167
|
}
|
|
1141
1168
|
interface AgentMessage {
|
|
1142
1169
|
id: string;
|
|
@@ -1254,9 +1281,28 @@ interface AgentConnection {
|
|
|
1254
1281
|
customProviders?: AgentConnectionCustomProvider[];
|
|
1255
1282
|
}
|
|
1256
1283
|
interface MessageAccepted {
|
|
1257
|
-
/** Identifier assigned by Messenger to the accepted
|
|
1284
|
+
/** Identifier assigned by Messenger to the accepted message. */
|
|
1258
1285
|
messageId: string;
|
|
1259
1286
|
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Email sent with the app's sender. There is no `from` because Messenger picks the sender from
|
|
1289
|
+
* the app in the token, and only the app's backend sends: a token exchanged from an api key or
|
|
1290
|
+
* the Server Function token. An app end-user token is refused with `403`. Recipient and content
|
|
1291
|
+
* rules, such as Messenger's cap on recipients across `to`, `cc` and `bcc`, are enforced there.
|
|
1292
|
+
*/
|
|
1293
|
+
interface SendEmailInput {
|
|
1294
|
+
/** One address per entry. */
|
|
1295
|
+
to: string[];
|
|
1296
|
+
/** One address per entry. */
|
|
1297
|
+
cc?: string[];
|
|
1298
|
+
/** One address per entry. */
|
|
1299
|
+
bcc?: string[];
|
|
1300
|
+
replyTo?: string;
|
|
1301
|
+
subject: string;
|
|
1302
|
+
html: string;
|
|
1303
|
+
/** Plain-text alternative for clients that do not render HTML. */
|
|
1304
|
+
text?: string;
|
|
1305
|
+
}
|
|
1260
1306
|
interface AppContext {
|
|
1261
1307
|
appId: string;
|
|
1262
1308
|
app: AppDefinition;
|
|
@@ -1747,6 +1793,8 @@ declare function createMembersModule(transport: Transport, errors?: SdkCoreError
|
|
|
1747
1793
|
interface MessengerModule {
|
|
1748
1794
|
/** Sends plain text to the authenticated user; channel rendering may support markdown. */
|
|
1749
1795
|
notify(content: string): Promise<MessageAccepted>;
|
|
1796
|
+
/** Sends an email from the app's sender; only the app's backend token may send. */
|
|
1797
|
+
sendEmail(input: SendEmailInput): Promise<MessageAccepted>;
|
|
1750
1798
|
}
|
|
1751
1799
|
declare function createMessengerModule(transport: Transport, errors?: SdkCoreErrorFactory): MessengerModule;
|
|
1752
1800
|
|
|
@@ -2140,4 +2188,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
2140
2188
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
2141
2189
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
2142
2190
|
|
|
2143
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2191
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SendEmailInput, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
package/dist/index.js
CHANGED
|
@@ -436,6 +436,9 @@ function expectAppFields(app, context, errors) {
|
|
|
436
436
|
if (!isNullableString(app.icon)) invalidField(context, "icon", errors);
|
|
437
437
|
if (!isNullableString(app.template)) invalidField(context, "template", errors);
|
|
438
438
|
if (typeof app.allowSignup !== "boolean") invalidField(context, "allowSignup", errors);
|
|
439
|
+
for (const field of ["emailLoginEnabled", "passwordLoginEnabled"]) {
|
|
440
|
+
if (field in app && typeof app[field] !== "boolean") invalidField(context, field, errors);
|
|
441
|
+
}
|
|
439
442
|
if (typeof app.externalAccessEnabled !== "boolean") {
|
|
440
443
|
invalidField(context, "externalAccessEnabled", errors);
|
|
441
444
|
}
|
|
@@ -957,7 +960,8 @@ var TURN_USAGE_COUNTS = [
|
|
|
957
960
|
"cacheReadTokens",
|
|
958
961
|
"cacheCreationTokens",
|
|
959
962
|
"requestCount",
|
|
960
|
-
"durationMs"
|
|
963
|
+
"durationMs",
|
|
964
|
+
"contextTokens"
|
|
961
965
|
];
|
|
962
966
|
var TURN_USAGE_COSTS = ["costUsd", "costUsdRaw"];
|
|
963
967
|
var TURN_USAGE_STRINGS = [
|
|
@@ -985,6 +989,8 @@ function agentTurnUsageOf(value) {
|
|
|
985
989
|
const item = value[field];
|
|
986
990
|
if (isCount(item)) usage[field] = item;
|
|
987
991
|
}
|
|
992
|
+
const { contextWindow } = value;
|
|
993
|
+
if (isInteger(contextWindow) && contextWindow > 0) usage.contextWindow = contextWindow;
|
|
988
994
|
for (const field of TURN_USAGE_COSTS) {
|
|
989
995
|
const item = value[field];
|
|
990
996
|
if (isFiniteNumber(item)) usage[field] = item;
|
|
@@ -2857,9 +2863,31 @@ function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
|
2857
2863
|
"Notify user response",
|
|
2858
2864
|
errors
|
|
2859
2865
|
);
|
|
2866
|
+
},
|
|
2867
|
+
async sendEmail(input) {
|
|
2868
|
+
return expectMessageAccepted(
|
|
2869
|
+
await transport.request("/api/v1/messages/send", {
|
|
2870
|
+
method: "POST",
|
|
2871
|
+
body: { channel: "EMAIL", payload: rawEmailPayload(input) }
|
|
2872
|
+
}),
|
|
2873
|
+
"Send email response",
|
|
2874
|
+
errors
|
|
2875
|
+
);
|
|
2860
2876
|
}
|
|
2861
2877
|
};
|
|
2862
2878
|
}
|
|
2879
|
+
function rawEmailPayload(input) {
|
|
2880
|
+
return {
|
|
2881
|
+
type: "RAW",
|
|
2882
|
+
to: input.to,
|
|
2883
|
+
...input.cc === void 0 ? {} : { cc: input.cc },
|
|
2884
|
+
...input.bcc === void 0 ? {} : { bcc: input.bcc },
|
|
2885
|
+
...input.replyTo === void 0 ? {} : { replyTo: input.replyTo },
|
|
2886
|
+
subject: input.subject,
|
|
2887
|
+
html: input.html,
|
|
2888
|
+
...input.text === void 0 ? {} : { text: input.text }
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2863
2891
|
|
|
2864
2892
|
// src/modules/publicFunctions.ts
|
|
2865
2893
|
function createPublicFunctionsModule(transport, errors = defaultSdkCoreErrorFactory) {
|