diff --git a/integrations/notion/integration.definition.ts b/integrations/notion/integration.definition.ts index a19e9858bab..7268b1229a4 100644 --- a/integrations/notion/integration.definition.ts +++ b/integrations/notion/integration.definition.ts @@ -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, @@ -19,9 +19,6 @@ export default new sdk.IntegrationDefinition({ secrets, states, user, - __advanced: { - useLegacyZuiTransformer: true, - }, }).extend(filesReadonly, ({}) => ({ entities: {}, actions: { diff --git a/packages/cli/package.json b/packages/cli/package.json index be37247cd00..70a61b5988f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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", @@ -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", diff --git a/packages/cli/src/linter/base-linter.ts b/packages/cli/src/linter/base-linter.ts index 27a2714fb31..86eacd6207e 100644 --- a/packages/cli/src/linter/base-linter.ts +++ b/packages/cli/src/linter/base-linter.ts @@ -22,7 +22,8 @@ export abstract class BaseLinter { 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) } diff --git a/packages/cli/templates/empty-bot/package.json b/packages/cli/templates/empty-bot/package.json index b5f744597fd..9dd9f8c5fae 100644 --- a/packages/cli/templates/empty-bot/package.json +++ b/packages/cli/templates/empty-bot/package.json @@ -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", diff --git a/packages/cli/templates/empty-integration/package.json b/packages/cli/templates/empty-integration/package.json index b92cb548303..df59189890f 100644 --- a/packages/cli/templates/empty-integration/package.json +++ b/packages/cli/templates/empty-integration/package.json @@ -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", diff --git a/packages/cli/templates/empty-plugin/package.json b/packages/cli/templates/empty-plugin/package.json index 2b72a543034..1ea38952536 100644 --- a/packages/cli/templates/empty-plugin/package.json +++ b/packages/cli/templates/empty-plugin/package.json @@ -6,7 +6,7 @@ }, "private": true, "dependencies": { - "@botpress/sdk": "5.0.0" + "@botpress/sdk": "5.0.1" }, "devDependencies": { "@types/node": "^22.16.4", diff --git a/packages/cli/templates/hello-world/package.json b/packages/cli/templates/hello-world/package.json index 51de9a1d7aa..492fe264b3c 100644 --- a/packages/cli/templates/hello-world/package.json +++ b/packages/cli/templates/hello-world/package.json @@ -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", diff --git a/packages/cli/templates/webhook-message/package.json b/packages/cli/templates/webhook-message/package.json index c1fef2667b3..0a235fa0695 100644 --- a/packages/cli/templates/webhook-message/package.json +++ b/packages/cli/templates/webhook-message/package.json @@ -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": { diff --git a/packages/cognitive/package.json b/packages/cognitive/package.json index 51653b15b80..6056d103eba 100644 --- a/packages/cognitive/package.json +++ b/packages/cognitive/package.json @@ -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", diff --git a/packages/llmz/examples/package.json b/packages/llmz/examples/package.json index ef02553b0e4..98735889f9d 100644 --- a/packages/llmz/examples/package.json +++ b/packages/llmz/examples/package.json @@ -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", diff --git a/packages/llmz/package.json b/packages/llmz/package.json index 3ba6ae48ce3..1222fe733ff 100644 --- a/packages/llmz/package.json +++ b/packages/llmz/package.json @@ -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": { diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ebf415bca5c..44d82c6c83d 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -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", @@ -30,7 +30,7 @@ "tsup": "^8.0.2" }, "peerDependencies": { - "@bpinternal/zui": "1.3.0", + "@bpinternal/zui": "1.3.1", "esbuild": "^0.16.12" }, "peerDependenciesMeta": { diff --git a/packages/sdk/src/plugin/conversation-proxy/proxy.ts b/packages/sdk/src/plugin/conversation-proxy/proxy.ts index 1ae9c94187d..833fb599ad6 100644 --- a/packages/sdk/src/plugin/conversation-proxy/proxy.ts +++ b/packages/sdk/src/plugin/conversation-proxy/proxy.ts @@ -26,7 +26,7 @@ export const proxyConversations = (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 @@ -35,8 +35,8 @@ export const proxyConversations = (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 }) => ({ diff --git a/packages/vai/package.json b/packages/vai/package.json index 562bd59323e..ae1a7207c44 100644 --- a/packages/vai/package.json +++ b/packages/vai/package.json @@ -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" }, diff --git a/packages/zai/package.json b/packages/zai/package.json index f7ec12a7429..2b8db9778d0 100644 --- a/packages/zai/package.json +++ b/packages/zai/package.json @@ -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" diff --git a/plugins/analytics/plugin.definition.ts b/plugins/analytics/plugin.definition.ts index 0ca3d573634..a203643ad8d 100644 --- a/plugins/analytics/plugin.definition.ts +++ b/plugins/analytics/plugin.definition.ts @@ -14,7 +14,4 @@ export default new sdk.PluginDefinition({ }, }, }, - __advanced: { - useLegacyZuiTransformer: true, - }, }) diff --git a/plugins/conversation-insights/plugin.definition.ts b/plugins/conversation-insights/plugin.definition.ts index 5ec5c1bc10e..520d4b0170f 100644 --- a/plugins/conversation-insights/plugin.definition.ts +++ b/plugins/conversation-insights/plugin.definition.ts @@ -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'), diff --git a/plugins/conversation-insights/src/error-handler.ts b/plugins/conversation-insights/src/error-handler.ts new file mode 100644 index 00000000000..9ee517b10e6 --- /dev/null +++ b/plugins/conversation-insights/src/error-handler.ts @@ -0,0 +1,9 @@ +import { BotLogger } from '@botpress/sdk' + +export const handleError = + (props: { context: string; logger: BotLogger }) => + async (thrown: unknown): Promise => { + 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) + } diff --git a/plugins/conversation-insights/src/handlers/after-incoming-message.ts b/plugins/conversation-insights/src/handlers/after-incoming-message.ts new file mode 100644 index 00000000000..d09e33130e5 --- /dev/null +++ b/plugins/conversation-insights/src/handlers/after-incoming-message.ts @@ -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 +} diff --git a/plugins/conversation-insights/src/handlers/after-outgoing-message.ts b/plugins/conversation-insights/src/handlers/after-outgoing-message.ts new file mode 100644 index 00000000000..f8e75d933a0 --- /dev/null +++ b/plugins/conversation-insights/src/handlers/after-outgoing-message.ts @@ -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 +} diff --git a/plugins/conversation-insights/src/handlers/index.ts b/plugins/conversation-insights/src/handlers/index.ts new file mode 100644 index 00000000000..1bddeb82a0a --- /dev/null +++ b/plugins/conversation-insights/src/handlers/index.ts @@ -0,0 +1,4 @@ +export * from './after-incoming-message' +export * from './after-outgoing-message' +export * from './update-ai-insight' +export * from './update-all-conversations' diff --git a/plugins/conversation-insights/src/handlers/update-ai-insight.ts b/plugins/conversation-insights/src/handlers/update-ai-insight.ts new file mode 100644 index 00000000000..354b8b367c5 --- /dev/null +++ b/plugins/conversation-insights/src/handlers/update-ai-insight.ts @@ -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: {} }) + } +} diff --git a/plugins/conversation-insights/src/handlers/update-all-conversations.ts b/plugins/conversation-insights/src/handlers/update-all-conversations.ts new file mode 100644 index 00000000000..14d54b59e0f --- /dev/null +++ b/plugins/conversation-insights/src/handlers/update-all-conversations.ts @@ -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' }) +} diff --git a/plugins/conversation-insights/src/index.ts b/plugins/conversation-insights/src/index.ts index 963999a8fa0..2980a6799e7 100644 --- a/plugins/conversation-insights/src/index.ts +++ b/plugins/conversation-insights/src/index.ts @@ -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: {}, }) @@ -13,28 +11,18 @@ 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) => { @@ -42,31 +30,30 @@ plugin.on.event('updateAiInsight', async (props) => { 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 diff --git a/plugins/knowledge/plugin.definition.ts b/plugins/knowledge/plugin.definition.ts index 67ea830b76d..2ac386d52fc 100644 --- a/plugins/knowledge/plugin.definition.ts +++ b/plugins/knowledge/plugin.definition.ts @@ -8,7 +8,4 @@ export default new sdk.PluginDefinition({ interfaces: { llm: sdk.version.allWithinMajorOf(llm), }, - __advanced: { - useLegacyZuiTransformer: true, - }, }) diff --git a/plugins/logger/plugin.definition.ts b/plugins/logger/plugin.definition.ts index bdee5c86602..1eecb2da3bb 100644 --- a/plugins/logger/plugin.definition.ts +++ b/plugins/logger/plugin.definition.ts @@ -4,7 +4,4 @@ export default new sdk.PluginDefinition({ name: 'logger', version: '0.0.1', configuration: { schema: sdk.z.object({}) }, - __advanced: { - useLegacyZuiTransformer: true, - }, }) diff --git a/plugins/personality/plugin.definition.ts b/plugins/personality/plugin.definition.ts index 27b83b6037c..7bc12fe9968 100644 --- a/plugins/personality/plugin.definition.ts +++ b/plugins/personality/plugin.definition.ts @@ -18,7 +18,4 @@ export default new sdk.PluginDefinition({ interfaces: { llm: sdk.version.allWithinMajorOf(llm), }, - __advanced: { - useLegacyZuiTransformer: true, - }, }) diff --git a/plugins/synchronizer/plugin.definition.ts b/plugins/synchronizer/plugin.definition.ts index 45e8efc90d1..c2df25abc03 100644 --- a/plugins/synchronizer/plugin.definition.ts +++ b/plugins/synchronizer/plugin.definition.ts @@ -71,7 +71,4 @@ export default new sdk.PluginDefinition({ listable: sdk.version.allWithinMajorOf(listable), deletable: sdk.version.allWithinMajorOf(deletable), }, - __advanced: { - useLegacyZuiTransformer: true, - }, }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10ab52513f4..180acdc1f0d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2429,7 +2429,7 @@ importers: specifier: 1.27.2 version: link:../client '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../sdk '@bpinternal/const': specifier: ^0.1.0 @@ -2547,7 +2547,7 @@ importers: specifier: 1.27.2 version: link:../../../client '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../../../sdk devDependencies: '@types/node': @@ -2563,7 +2563,7 @@ importers: specifier: 1.27.2 version: link:../../../client '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../../../sdk devDependencies: '@types/node': @@ -2576,7 +2576,7 @@ importers: packages/cli/templates/empty-plugin: dependencies: '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../../../sdk devDependencies: '@types/node': @@ -2592,7 +2592,7 @@ importers: specifier: 1.27.2 version: link:../../../client '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../../../sdk devDependencies: '@types/node': @@ -2608,7 +2608,7 @@ importers: specifier: 1.27.2 version: link:../../../client '@botpress/sdk': - specifier: 5.0.0 + specifier: 5.0.1 version: link:../../../sdk axios: specifier: ^1.6.8 @@ -2668,8 +2668,8 @@ importers: specifier: workspace:* version: link:../common '@bpinternal/zui': - specifier: 1.3.0 - version: 1.3.0 + specifier: 1.3.1 + version: 1.3.1 '@size-limit/file': specifier: ^11.1.6 version: 11.1.6(size-limit@11.1.6) @@ -2768,8 +2768,8 @@ importers: specifier: ^1.0.5 version: 1.0.5 '@bpinternal/zui': - specifier: 1.3.0 - version: 1.3.0 + specifier: 1.3.1 + version: 1.3.1 '@jitl/quickjs-singlefile-browser-release-sync': specifier: ^0.31.0 version: 0.31.0 @@ -2871,8 +2871,8 @@ importers: specifier: 1.27.2 version: link:../client '@bpinternal/zui': - specifier: 1.3.0 - version: 1.3.0 + specifier: 1.3.1 + version: 1.3.1 browser-or-node: specifier: ^2.1.1 version: 2.1.1 @@ -2911,8 +2911,8 @@ importers: specifier: ^1.0.1 version: 1.0.2 '@bpinternal/zui': - specifier: 1.3.0 - version: 1.3.0 + specifier: 1.3.1 + version: 1.3.1 json5: specifier: ^2.2.3 version: 2.2.3 @@ -2957,8 +2957,8 @@ importers: specifier: ^1.0.0 version: 1.0.2 '@bpinternal/zui': - specifier: ^1.3.0 - version: 1.3.0 + specifier: ^1.3.1 + version: 1.3.1 json5: specifier: ^2.2.3 version: 2.2.3 @@ -3945,8 +3945,8 @@ packages: '@bpinternal/yargs-extra@0.0.3': resolution: {integrity: sha512-e/unlq0LX4CJUv1jGOv1UgwB/h2M0NCXnwD4lEw496GpkQikO668RS+BBlRhkqdGfZmvKDkXZZ96xJCn+i6Ymg==} - '@bpinternal/zui@1.3.0': - resolution: {integrity: sha512-nlLED8qkdgwqSQa4pUQuge/MDbPOs5La9LcIA6S7CA1WYaXbCa/X7yr/RqqzuWR1W7OUFxceddNzJhFpLBhoGQ==} + '@bpinternal/zui@1.3.1': + resolution: {integrity: sha512-vj0Xl5mzzNFKzt569+xAGMs3+8dJJSFq1RoLYv2xHf6XLljbPnGASYwyFspO8GQkJMLzLZUQ36TMFLVwg2yTPg==} engines: {node: '>=16.0.0', pnpm: 8.6.2} '@colors/colors@1.6.0': @@ -12934,7 +12934,7 @@ snapshots: yargs: 17.7.2 yn: 4.0.0 - '@bpinternal/zui@1.3.0': {} + '@bpinternal/zui@1.3.1': {} '@colors/colors@1.6.0': {}