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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ tilt_config.json
hubspot.config.yml
AGENTS.md
CLAUDE.md
lefthook.yml
.claude
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": "6.2.5",
"version": "6.2.6",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
Expand Down Expand Up @@ -28,7 +28,7 @@
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"@botpress/chat": "0.5.5",
"@botpress/client": "1.38.2",
"@botpress/sdk": "6.4.1",
"@botpress/sdk": "6.4.2",
"@bpinternal/const": "^0.1.0",
"@bpinternal/tunnel": "^0.1.1",
"@bpinternal/verel": "^0.2.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/utils/require-utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as sdk from '@botpress/sdk'
import Module from 'module'
import pathlib from 'path'

Expand All @@ -20,6 +21,12 @@ export const requireJsCode = <T>(code: string): T => {
return m.exports
} catch (thrown: unknown) {
const error = thrown instanceof Error ? thrown : new Error(`${thrown}`)
// sdk.errors.isDefinitionError() handles cross-bundle detection: esbuild inlines a separate
// copy of @botpress/sdk into the compiled definition artifact, so instanceof alone is
// unreliable. See the isDefinitionError() docstring in the SDK for the full explanation.
if (sdk.errors.isDefinitionError(thrown)) {
throw error
}
throw _injectStackTrace(error, code, filename)
}
}
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.38.2",
"@botpress/sdk": "6.4.1"
"@botpress/sdk": "6.4.2"
},
"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.38.2",
"@botpress/sdk": "6.4.1"
"@botpress/sdk": "6.4.2"
},
"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": "6.4.1"
"@botpress/sdk": "6.4.2"
},
"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.38.2",
"@botpress/sdk": "6.4.1"
"@botpress/sdk": "6.4.2"
},
"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.38.2",
"@botpress/sdk": "6.4.1",
"@botpress/sdk": "6.4.2",
"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
@@ -1,6 +1,6 @@
{
"name": "@botpress/cognitive",
"version": "0.4.5",
"version": "0.4.6",
"description": "Wrapper around the Botpress Client to call LLMs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/llmz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "llmz",
"type": "module",
"description": "LLMz - An LLM-native Typescript VM built on top of Zui",
"version": "0.0.63",
"version": "0.0.64",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -72,7 +72,7 @@
},
"peerDependencies": {
"@botpress/client": "1.38.2",
"@botpress/cognitive": "0.4.5",
"@botpress/cognitive": "0.4.6",
"@bpinternal/thicktoken": "^2.0.0",
"@bpinternal/zui": "^2.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/sdk",
"version": "6.4.1",
"version": "6.4.2",
"description": "Botpress SDK",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
11 changes: 6 additions & 5 deletions packages/sdk/src/bot/definition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Table } from '@botpress/client'
import { SchemaTransformOptions } from '../common/types'
import * as consts from '../consts'
import { DefinitionError } from '../errors'
import { IntegrationPackage, PluginPackage } from '../package'
import { PluginInterfaceExtension, PluginIntegrationExtension } from '../plugin'
import { SchemaDefinition } from '../schema'
Expand Down Expand Up @@ -272,7 +273,7 @@ export class BotDefinition<
const integrationAlias = config?.alias ?? integrationPkg.name

if (self.integrations[integrationAlias]) {
throw new Error(`Another integration with alias "${integrationAlias}" is already installed in the bot`)
throw new DefinitionError(`Another integration with alias "${integrationAlias}" is already installed in the bot`)
}

self.integrations[integrationAlias] = {
Expand All @@ -295,7 +296,7 @@ export class BotDefinition<
const pluginAlias = config.alias ?? pluginPkg.name

if (self.plugins[pluginAlias]) {
throw new Error(`Another plugin with alias "${pluginAlias}" is already installed in the bot`)
throw new DefinitionError(`Another plugin with alias "${pluginAlias}" is already installed in the bot`)
}
// Resolve backing integrations for plugin interfaces:
const interfaces: Record<string, PluginInterfaceExtension> = Object.fromEntries(
Expand All @@ -307,7 +308,7 @@ export class BotDefinition<
if (!integrationInstance) {
const availableIntegrations = Object.keys(this.integrations ?? {}).join(', ') || '(none)'

throw new Error(
throw new DefinitionError(
`Interface with alias "${pluginIfaceAlias}" of plugin with alias "${pluginAlias}" ` +
`references integration with alias "${pluginIfaceConfig.integrationAlias}" which is not installed. ` +
'Please make sure to add the integration via addIntegration() before calling addPlugin().\n' +
Expand All @@ -322,7 +323,7 @@ export class BotDefinition<
const availableInterfaces =
Object.keys(integrationInstance.definition.interfaces ?? {}).join(', ') || '(none)'

throw new Error(
throw new DefinitionError(
`Interface with alias "${pluginIfaceConfig.integrationInterfaceAlias}" does not exist in integration ` +
`"${integrationInstance.name}" referenced by interface with alias "${pluginIfaceAlias}" of plugin ` +
`with alias "${pluginAlias}".\nAvailable interface aliases: ${availableInterfaces}`
Expand Down Expand Up @@ -562,7 +563,7 @@ export class BotDefinition<
const backingIntegration = this.integrations?.[pluginInterfaceExtension.integrationAlias]

if (!backingIntegration) {
throw new Error(
throw new DefinitionError(
`Interface with alias "${interfaceAlias}" of plugin with alias "${pluginAlias}" references integration "${pluginInterfaceExtension.name}" which is not installed`
)
}
Expand Down
27 changes: 27 additions & 0 deletions packages/sdk/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Thrown by SDK definition classes (BotDefinition, IntegrationDefinition, PluginDefinition, etc.)
* for intentional validation errors whose message is already clear.
*
* The CLI detects this class to suppress the "Offending code:" section that it normally
* appends to errors thrown during definition file evaluation.
*/
export class DefinitionError extends Error {
/** @internal Marker used by {@link isDefinitionError} to survive esbuild bundle boundaries. */
public readonly __IS_SDK_ERROR__ = true as const
public readonly type = 'definition_error' as const
}

/**
* Type guard to detect {@link DefinitionError} across esbuild bundle boundaries.
*
* Tries `instanceof` first (same bundle), then falls back to the `__IS_SDK_ERROR__` marker
* and `type` field for cross-bundle cases where esbuild inlines a separate copy of the SDK class.
*/
export const isDefinitionError = (error: unknown): error is DefinitionError =>
error instanceof DefinitionError ||
(typeof error === 'object' &&
error !== null &&
'__IS_SDK_ERROR__' in error &&
error.__IS_SDK_ERROR__ === true &&
'type' in error &&
error.type === 'definition_error')
2 changes: 2 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export {

export * as version from './version-utils'

export * as errors from './errors'

export {
//
IntegrationPackage,
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/integration/definition/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as esbuild from 'esbuild'
import { SchemaTransformOptions } from '../../common/types'
import { DefinitionError } from '../../errors'
import { resolveInterface } from '../../interface/resolve'
import { InterfacePackage } from '../../package'
import * as utils from '../../utils'
Expand Down Expand Up @@ -316,7 +317,7 @@ export class IntegrationDefinition<
const unbrandedEntity = utils.records.pairs(extensionBuilderOutput.entities).find(([_k, e]) => !isBranded(e))
if (unbrandedEntity) {
// this means the user tried providing a plain schema without referencing an entity from the integration
throw new Error(
throw new DefinitionError(
`Cannot extend interface "${interfacePkg.name}" with entity "${unbrandedEntity[0]}"; the provided schema is not part of the integration's entities.`
)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/plugin/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
WorkflowDefinition,
} from '../bot/definition'
import { SchemaTransformOptions } from '../common/types'
import { DefinitionError } from '../errors'
import { IntegrationPackage, InterfacePackage } from '../package'
import * as typeUtils from '../utils/type-utils'
import { SDK_VERSION } from '../version'
Expand Down Expand Up @@ -254,7 +255,7 @@ export class PluginDefinition<

for (const alias of [...Object.keys(props.integrations ?? {}), ...Object.keys(props.interfaces ?? {})]) {
if (aliases.has(alias)) {
throw new Error(
throw new DefinitionError(
`Duplicate interface or integration alias detected in plugin definition: '${alias}'. ` +
'Please use unique aliases for each interface and integration.'
)
Expand Down
2 changes: 1 addition & 1 deletion packages/vai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/vai",
"version": "0.0.23",
"version": "0.0.24",
"description": "Vitest AI (vai) – a vitest extension for testing with LLMs",
"types": "./dist/index.d.ts",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/zai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@botpress/zai",
"description": "Zui AI (zai) – An LLM utility library written on top of Zui and the Botpress API",
"version": "2.6.10",
"version": "2.6.11",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@botpress/cognitive": "0.4.5",
"@botpress/cognitive": "0.4.6",
"json5": "^2.2.3",
"jsonrepair": "^3.10.0",
"lodash-es": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion plugins/conversation-insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"private": true,
"dependencies": {
"@botpress/cognitive": "0.4.5",
"@botpress/cognitive": "0.4.6",
"@botpress/sdk": "workspace:*",
"browser-or-node": "^2.1.1",
"jsonrepair": "^3.10.0"
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading