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
2 changes: 2 additions & 0 deletions bots/hit-looper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bot.on.message('*', async (props) => {
userId: upstreamUser.id,
},
})

return
}

Expand All @@ -73,6 +74,7 @@ bot.on.message('*', async (props) => {
conversationId: upstreamConversation.id,
},
})

return
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "^3.564.0",
"@botpress/api": "1.34.0",
"@botpress/api": "1.37.0",
"@botpress/cli": "workspace:*",
"@botpress/client": "workspace:*",
"@botpress/sdk": "workspace:*",
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": "4.16.2",
"version": "4.17.0",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run bundle && pnpm run template:gen",
Expand All @@ -21,7 +21,7 @@
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"@botpress/chat": "0.5.1",
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@botpress/sdk": "4.15.2",
"@bpinternal/const": "^0.1.0",
"@bpinternal/tunnel": "^0.1.1",
Expand Down
53 changes: 10 additions & 43 deletions packages/cli/src/api/bot-body.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as client from '@botpress/client'
import * as sdk from '@botpress/sdk'
import { PluginTagNames } from '../command-implementations/project-command'
import * as utils from '../utils'
import * as types from './types'

Expand Down Expand Up @@ -47,65 +46,33 @@ export const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<type
})

export const prepareUpdateBotBody = (
localBot: types.UpdateBotRequestBody & PluginTagNames,
localBot: types.UpdateBotRequestBody,
remoteBot: client.Bot
): types.UpdateBotRequestBody => ({
...localBot,
shouldMergePlugins: true,
states: _setNullOnMissingValuesAndOmitPluginDefs(localBot.states, remoteBot.states),
recurringEvents: _setNullOnMissingValuesAndOmitPluginDefs(localBot.recurringEvents, remoteBot.recurringEvents),
states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),
recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),
events: utils.attributes.prepareAttributeUpdateBody({
localItems: _setNullOnMissingValuesAndOmitPluginDefs(localBot.events, remoteBot.events),
localItems: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),
remoteItems: remoteBot.events,
}),
actions: utils.attributes.prepareAttributeUpdateBody({
localItems: _setNullOnMissingValuesAndOmitPluginDefs(localBot.actions, remoteBot.actions),
localItems: utils.records.setNullOnMissingValues(localBot.actions, remoteBot.actions),
remoteItems: remoteBot.actions,
}),
user: {
...localBot.user,
tags: _setNullOnMissingValuesAndOmitImmutableTags(
localBot.user?.tags,
remoteBot.user?.tags,
localBot.immutableTags.user
),
tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags),
},
conversation: {
...localBot.conversation,
tags: _setNullOnMissingValuesAndOmitImmutableTags(
localBot.conversation?.tags,
remoteBot.conversation?.tags,
localBot.immutableTags.conversation
),
tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags),
},
message: {
...localBot.message,
tags: _setNullOnMissingValuesAndOmitImmutableTags(
localBot.message?.tags,
remoteBot.message?.tags,
localBot.immutableTags.message
),
tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags),
},
integrations: _setNullOnMissingValuesAndOmitPluginDefs(localBot.integrations, remoteBot.integrations),
plugins: _setNullOnMissingValuesAndOmitPluginDefs(localBot.plugins, remoteBot.plugins),
integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),
plugins: utils.records.setNullOnMissingValues(localBot.plugins, remoteBot.plugins),
tags: localBot.tags, // TODO: allow removing bot tags (aka attributes) by setting to null
})

export const _setNullOnMissingValuesAndOmitPluginDefs: typeof utils.records.setNullOnMissingValues = (
record,
oldRecord = {}
) =>
utils.records.setNullOnMissingValues(
record,
Object.fromEntries(Object.entries(oldRecord).filter(([key]) => !key.includes('#')))
)

export const _setNullOnMissingValuesAndOmitImmutableTags = <A, B>(
record: Record<string, A> = {},
oldRecord: Record<string, B> = {},
immutableTags: string[] = []
): Record<string, A | null> =>
utils.records.setNullOnMissingValues(
record,
Object.fromEntries(Object.entries(oldRecord).filter(([key]) => !immutableTags.includes(key)))
)
5 changes: 5 additions & 0 deletions packages/cli/src/command-implementations/add-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export class AddCommand extends GlobalCommand<AddCommandDefinition> {
await this._uninstall(installPath)
}

if (ref.type === 'name') {
// Preserve the semver version expression in the generated code:
targetPackage.pkg.version = ref.version
}

let files: codegen.File[]
if (targetPackage.type === 'integration') {
files = await codegen.generateIntegrationPackage(targetPackage.pkg)
Expand Down
30 changes: 1 addition & 29 deletions packages/cli/src/command-implementations/project-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export type ProjectDefinition = LintIgnoredConfig &
| { type: 'plugin'; definition: sdk.PluginDefinition }
)

export type PluginTagNames = {
immutableTags: { user: string[]; conversation: string[]; message: string[] }
}

class ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {
public constructor(argv: CommandArgv<ProjectCommandDefinition>) {
const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)
Expand Down Expand Up @@ -345,7 +341,7 @@ export abstract class ProjectCommand<C extends ProjectCommandDefinition> extends
protected async prepareBotDependencies(
botDef: sdk.BotDefinition,
api: apiUtils.ApiClient
): Promise<Partial<apiUtils.UpdateBotRequestBody> & PluginTagNames> {
): Promise<Partial<apiUtils.UpdateBotRequestBody>> {
const integrations = await this._fetchDependencies(botDef.integrations ?? {}, ({ name, version }) =>
api.getPublicOrPrivateIntegration({ type: 'name', name, version })
)
Expand Down Expand Up @@ -383,30 +379,6 @@ export abstract class ProjectCommand<C extends ProjectCommandDefinition> extends
integrationId: iface.id,
})),
})),
// Tags that are defined by plugins and that cannot be updated:
immutableTags: {
user: [
...new Set(
Object.values(pluginsWithBackingIntegrations).flatMap((plugin) =>
Object.keys(plugin.definition.user?.tags ?? {})
)
),
],
conversation: [
...new Set(
Object.values(pluginsWithBackingIntegrations).flatMap((plugin) =>
Object.keys(plugin.definition.conversation?.tags ?? {})
)
),
],
message: [
...new Set(
Object.values(pluginsWithBackingIntegrations).flatMap((plugin) =>
Object.keys(plugin.definition.message?.tags ?? {})
)
),
],
},
}
}

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 @@ -5,7 +5,7 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
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 @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
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 @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
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 @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@botpress/sdk": "4.15.2",
"axios": "^1.6.8"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/client",
"version": "1.21.0",
"version": "1.22.0",
"description": "Botpress Client",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/llmz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/standalone": "^7.26.4",
"@babel/traverse": "^7.26.4",
"@babel/types": "^7.26.3",
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"bytes": "^3.1.2",
"exponential-backoff": "^3.1.1",
"handlebars": "^4.7.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"browser-or-node": "^2.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tsup": "^8.0.2"
},
"peerDependencies": {
"@botpress/client": "1.21.0",
"@botpress/client": "1.22.0",
"@bpinternal/thicktoken": "^1.0.1",
"@bpinternal/zui": "^1.0.1",
"lodash": "^4.17.21",
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

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

Loading