Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions integrations/notion/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import filesReadonly from './bp_modules/files-readonly'
import { actions, configuration, configurations, identifier, secrets, states, user } from './definitions'

export const INTEGRATION_NAME = 'notion'
export const INTEGRATION_VERSION = '2.2.1'
export const INTEGRATION_VERSION = '2.2.2'

export default new sdk.IntegrationDefinition({
name: INTEGRATION_NAME,
Expand All @@ -19,9 +19,6 @@ export default new sdk.IntegrationDefinition({
secrets,
states,
user,
__advanced: {
useLegacyZuiTransformer: true,
},
}).extend(filesReadonly, ({}) => ({
entities: {},
actions: {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cli",
"version": "5.0.0",
"version": "5.0.1",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
Expand All @@ -27,7 +27,7 @@
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"@botpress/chat": "0.5.4",
"@botpress/client": "1.27.2",
"@botpress/sdk": "5.0.0",
"@botpress/sdk": "5.0.1",
"@bpinternal/const": "^0.1.0",
"@bpinternal/tunnel": "^0.1.1",
"@bpinternal/verel": "^0.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/linter/base-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export abstract class BaseLinter<TDefinition> {

public logResults(logger: Logger) {
for (const result of this.getSortedResults()) {
const message = `${result.path}: ${result.message}`
const resultPath = result.path.trim() || '{root}'
const message = `${resultPath}: ${result.message}`

this._logResultMessage(logger, message, result.severity)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.27.2",
"@botpress/sdk": "5.0.0"
"@botpress/sdk": "5.0.1"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.27.2",
"@botpress/sdk": "5.0.0"
"@botpress/sdk": "5.0.1"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/sdk": "5.0.0"
"@botpress/sdk": "5.0.1"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.27.2",
"@botpress/sdk": "5.0.0"
"@botpress/sdk": "5.0.1"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/webhook-message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.27.2",
"@botpress/sdk": "5.0.0",
"@botpress/sdk": "5.0.1",
"axios": "^1.6.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cognitive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@botpress/cli": "workspace:*",
"@botpress/client": "workspace:*",
"@botpress/common": "workspace:*",
"@bpinternal/zui": "1.3.0",
"@bpinternal/zui": "1.3.1",
"@size-limit/file": "^11.1.6",
"@types/axios": "^0.14.4",
"@types/debug": "^4.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/llmz/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@botpress/client": "workspace:^",
"@botpress/zai": "^2.0.8",
"@bpinternal/zui": "1.3.0",
"@bpinternal/zui": "1.3.1",
"chalk": "^4.1.2",
"llmz": "link:..",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/llmz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@botpress/client": "1.27.2",
"@botpress/cognitive": "0.3.1",
"@bpinternal/thicktoken": "^1.0.5",
"@bpinternal/zui": "1.3.0"
"@bpinternal/zui": "1.3.1"
},
"dependenciesMeta": {
"@bpinternal/zui": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/sdk",
"version": "5.0.0",
"version": "5.0.1",
"description": "Botpress SDK",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -30,7 +30,7 @@
"tsup": "^8.0.2"
},
"peerDependencies": {
"@bpinternal/zui": "1.3.0",
"@bpinternal/zui": "1.3.1",
"esbuild": "^0.16.12"
},
"peerDependenciesMeta": {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/plugin/conversation-proxy/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const proxyConversations = <TPlugin extends BasePlugin>(props: {
list(listProps): any {
const integrationName =
props.plugin?.interfaces[interfaceOrIntegrationAlias]?.integrationAlias ??
props.plugin?.integrations[interfaceOrIntegrationAlias]?.integrationAlias!
props.plugin?.integrations[interfaceOrIntegrationAlias]?.integrationAlias

const actualChannelName =
props.plugin?.interfaces[interfaceOrIntegrationAlias]?.channels?.[channel]?.name ?? channel
Expand All @@ -35,8 +35,8 @@ export const proxyConversations = <TPlugin extends BasePlugin>(props: {
props.client
.listConversations({
...prefixTagsIfNeeded(listProps ?? {}, { alias: props.plugin?.alias }),
channel: actualChannelName,
integrationName,
channel: actualChannelName === '*' ? undefined : actualChannelName,
integrationName: integrationName === '*' ? undefined : integrationName,
nextToken,
})
.then(({ meta, conversations }) => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/vai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"peerDependencies": {
"@botpress/client": "1.27.2",
"@bpinternal/thicktoken": "^1.0.1",
"@bpinternal/zui": "1.3.0",
"@bpinternal/zui": "1.3.1",
"lodash": "^4.17.21",
"vitest": "^2 || ^3 || ^4 || ^5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/zai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"peerDependencies": {
"@bpinternal/thicktoken": "^1.0.0",
"@bpinternal/zui": "^1.3.0"
"@bpinternal/zui": "^1.3.1"
},
"engines": {
"node": ">=18.0.0"
Expand Down
3 changes: 0 additions & 3 deletions plugins/analytics/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ export default new sdk.PluginDefinition({
},
},
},
__advanced: {
useLegacyZuiTransformer: true,
},
})
2 changes: 1 addition & 1 deletion plugins/conversation-insights/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PluginDefinition, z } from '@botpress/sdk'

export default new PluginDefinition({
name: 'conversation-insights',
version: '0.4.6',
version: '0.4.8',
configuration: {
schema: z.object({
aiEnabled: z.boolean().default(true).describe('Set to true to enable title, summary and sentiment ai generation'),
Expand Down
9 changes: 9 additions & 0 deletions plugins/conversation-insights/src/error-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BotLogger } from '@botpress/sdk'

export const handleError =
(props: { context: string; logger: BotLogger }) =>
async (thrown: unknown): Promise<undefined> => {
const error = thrown instanceof Error ? thrown : new Error(String(thrown))
const message = `An error occured in the conversation-insights plugin while ${props.context}: ${error.message}`
props.logger.error(message)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as onNewMessageHandler from '../onNewMessageHandler'
import * as bp from '.botpress'

const HOUR_MILLISECONDS = 60 * 60 * 1000

export const handleAfterIncomingMessage: bp.HookHandlers['after_incoming_message']['*'] = async (props) => {
const conversation = await props.conversations['*']['*'].getById({ id: props.data.conversationId })
await onNewMessageHandler.onNewMessage({ ...props, conversation })

if (props.configuration.aiEnabled) {
const events = await props.events.updateAiInsight.list({ status: 'scheduled' }).take(1)
if (events.length === 0) {
const dateTime = new Date(Date.now() + HOUR_MILLISECONDS).toISOString()
await props.events.updateAiInsight.schedule({}, { dateTime })
}
}

return undefined
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as onNewMessageHandler from '../onNewMessageHandler'
import * as bp from '.botpress'

export const handleAfterOutgoingMessage: bp.HookHandlers['after_outgoing_message']['*'] = async (props) => {
const conversation = await props.conversations['*']['*'].getById({ id: props.data.message.conversationId })
await onNewMessageHandler.onNewMessage({ ...props, conversation })
return undefined
}
4 changes: 4 additions & 0 deletions plugins/conversation-insights/src/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './after-incoming-message'
export * from './after-outgoing-message'
export * from './update-ai-insight'
export * from './update-all-conversations'
11 changes: 11 additions & 0 deletions plugins/conversation-insights/src/handlers/update-ai-insight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as bp from '.botpress'

export const handleUpdateAiInsight: bp.EventHandlers['updateAiInsight'] = async (props) => {
const workflows = await props.workflows.updateAllConversations
.listInstances({ statuses: ['pending', 'cancelled', 'listening', 'paused'] })
.take(1)

if (workflows.length === 0) {
await props.workflows.updateAllConversations.startNewInstance({ input: {} })
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { updateAllConversations } from '../updateAllConversations'
import * as bp from '.botpress'

export const handleStartUpdateAllConversations: bp.WorkflowHandlers['updateAllConversations'] = async (props) => {
props.logger.info('Starting updateAllConversations workflow')
await updateAllConversations(props)

return undefined
}
export const handleContinueUpdateAllConversations: bp.WorkflowHandlers['updateAllConversations'] = async (props) => {
await updateAllConversations(props)

return undefined
}

export const handleTimeoutUpdateAllConversations: bp.WorkflowHandlers['updateAllConversations'] = async (props) => {
await props.workflow.setFailed({ failureReason: 'Workflow timed out' })
}
59 changes: 23 additions & 36 deletions plugins/conversation-insights/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { isBrowser } from 'browser-or-node'
import * as onNewMessageHandler from './onNewMessageHandler'
import { updateAllConversations } from './updateAllConversations'
import { handleError } from './error-handler'
import * as handlers from './handlers'
import * as bp from '.botpress'

const HOUR_MILLISECONDS = 60 * 60 * 1000

const plugin = new bp.Plugin({
actions: {},
})
Expand All @@ -13,60 +11,49 @@ plugin.on.afterIncomingMessage('*', async (props) => {
if (isBrowser) {
return
}
const conversation = await props.conversations['*']['*'].getById({ id: props.data.conversationId })
await onNewMessageHandler.onNewMessage({ ...props, conversation })

if (props.configuration.aiEnabled) {
const events = await props.events.updateAiInsight.list().take(1)

if (events.length === 0) {
const dateTime = new Date(Date.now() + HOUR_MILLISECONDS).toISOString()
await props.events.updateAiInsight.schedule({}, { dateTime })
}
}

return undefined
return await handlers
.handleAfterIncomingMessage(props)
.catch(handleError({ context: 'trying to process an incoming message', logger: props.logger }))
})

plugin.on.afterOutgoingMessage('*', async (props) => {
if (isBrowser) {
return
}
const conversation = await props.conversations['*']['*'].getById({ id: props.data.message.conversationId })
await onNewMessageHandler.onNewMessage({ ...props, conversation })
return undefined
return await handlers
.handleAfterOutgoingMessage(props)
.catch(handleError({ context: 'trying to process an outgoing message', logger: props.logger }))
})

plugin.on.event('updateAiInsight', async (props) => {
if (isBrowser) {
props.logger.error('This event is not supported by the browser')
return
}

const workflows = await props.workflows.updateAllConversations
.listInstances({ statuses: ['pending', 'cancelled', 'listening', 'paused'] })
.take(1)

if (workflows.length === 0) {
await props.workflows.updateAllConversations.startNewInstance({ input: {} })
}
return await handlers
.handleUpdateAiInsight(props)
.catch(handleError({ context: 'trying to update an AI insight', logger: props.logger }))
})

plugin.on.workflowStart('updateAllConversations', async (props) => {
props.logger.info('Starting updateAllConversations workflow')
await updateAllConversations(props)

return undefined
return await handlers
.handleStartUpdateAllConversations(props)
.catch(handleError({ context: 'trying to start the updateAllConversations workflow', logger: props.logger }))
})

plugin.on.workflowContinue('updateAllConversations', async (props) => {
await updateAllConversations(props)

return undefined
return await handlers
.handleContinueUpdateAllConversations(props)
.catch(handleError({ context: 'trying to continue the updateAllConversations workflow', logger: props.logger }))
})

plugin.on.workflowTimeout('updateAllConversations', async (props) => {
await props.workflow.setFailed({ failureReason: 'Workflow timed out' })
return await handlers.handleTimeoutUpdateAllConversations(props).catch(
handleError({
context: 'trying to process the timeout of the updateAllConversations workflow',
logger: props.logger,
})
)
})

export default plugin
3 changes: 0 additions & 3 deletions plugins/knowledge/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ export default new sdk.PluginDefinition({
interfaces: {
llm: sdk.version.allWithinMajorOf(llm),
},
__advanced: {
useLegacyZuiTransformer: true,
},
})
3 changes: 0 additions & 3 deletions plugins/logger/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ export default new sdk.PluginDefinition({
name: 'logger',
version: '0.0.1',
configuration: { schema: sdk.z.object({}) },
__advanced: {
useLegacyZuiTransformer: true,
},
})
3 changes: 0 additions & 3 deletions plugins/personality/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ export default new sdk.PluginDefinition({
interfaces: {
llm: sdk.version.allWithinMajorOf(llm),
},
__advanced: {
useLegacyZuiTransformer: true,
},
})
3 changes: 0 additions & 3 deletions plugins/synchronizer/plugin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,4 @@ export default new sdk.PluginDefinition({
listable: sdk.version.allWithinMajorOf(listable),
deletable: sdk.version.allWithinMajorOf(deletable),
},
__advanced: {
useLegacyZuiTransformer: true,
},
})
Loading
Loading