ai-publish-sdk
v1.1.1
Published
SDK for embedded apps to communicate with the host environment via RPC over postMessage
Maintainers
Readme
ai-publish-sdk
SDK for embedded apps to communicate with the host environment.
Installation
npm install ai-publish-sdkCore API
getUserInfo()
Get current user info.
getUserInfo(config?: RpcConfig): Promise<UserInfo | null>
interface UserInfo {
userId: string
tenantId: string
tenantName?: string
name?: string
givenName?: string
familyName?: string
displayName?: string
email?: string
picture?: string
}getToken(appName, options?)
Get OAuth token for an integration.
getToken(appName: IntegrationAppName, options?: GetTokenOptions, config?: RpcConfig): Promise<GetTokenResult | null>
type IntegrationAppName = 'gmail' | 'jira' | 'googledrive' | 'salesforce' | 'googlecalendar' | 'slack'
interface GetTokenOptions {
interactive?: boolean // show OAuth flow if not yet authorized
}
interface GetTokenResult {
token: string
instanceUrl?: string // e.g. Salesforce instance URL
}generateMessage(prompt, options)
Generate an AI message.
generateMessage(prompt: string, options: GenerateMessageOptions, config?: RpcConfig): Promise<string | null>
interface GenerateMessageOptions {
withPageContext?: boolean // include current page content as context
systemPrompt?: string // guide AI behavior
}executeScript(code)
Execute JavaScript on the host page.
executeScript(code: string, config?: RpcConfig): Promise<void>RpcConfig
Optional config passed to any function call.
interface RpcConfig {
timeout?: number // ms, default 15000
targetOrigin?: string // postMessage target origin, default '*'
}