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: 1 addition & 1 deletion .github/workflows/deploy-integrations-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: ./.github/actions/deploy-plugins
with:
environment: 'production'
extra_filter: "-F '!analytics' -F '!logger' -F '!personality' -F '!synchronizer' -F '!knowledge'"
extra_filter: "-F '!analytics' -F '!logger' -F '!personality' -F '!synchronizer' -F '!knowledge' -F '!conversation-insights'"
force: ${{ github.event.inputs.force == 'true' }}
token_cloud_ops_account: ${{ secrets.PRODUCTION_TOKEN_CLOUD_OPS_ACCOUNT }}
cloud_ops_workspace_id: ${{ secrets.PRODUCTION_CLOUD_OPS_WORKSPACE_ID }}
9 changes: 7 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import tsParser from "@typescript-eslint/parser";
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin'
import oxlint from 'eslint-plugin-oxlint';
import path from "path"

const oxlintFile = path.join(import.meta.dirname, '.oxlintrc.json');

const ignores = [
".git/",
Expand Down Expand Up @@ -77,7 +80,9 @@ export default [{
avoidEscape: true,
}],

"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-floating-promises": ["error", {
checkThenables: true
}],
"@typescript-eslint/no-misused-promises": "error",
"@stylistic/semi": ["error", "never"],
"@stylistic/type-annotation-spacing": "error",
Expand Down Expand Up @@ -112,7 +117,7 @@ export default [{
"@typescript-eslint/explicit-member-accessibility": "warn",

// Disable every rule already covered by oxlint:
...oxlint.buildFromOxlintConfigFile('./.oxlintrc.json')
...oxlint.buildFromOxlintConfigFile(oxlintFile)
.map(config => config.rules)
.reduce((acc, rules) => ({ ...acc, ...rules }), {}),
},
Expand Down
1 change: 0 additions & 1 deletion integrations/email/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const register: bp.IntegrationProps['register'] = async (props) => {
await getMessages({ page: 0, perPage: 1 }, props)
} catch (thrown: unknown) {
const err = thrown instanceof Error ? thrown : new Error(`${thrown}`)
console.log(err.message)
throw new sdk.RuntimeError(
`An error occured when registering the integration: ${err.message} Verify your configuration.`
)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/command-implementations/init-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class InitCommand extends GlobalCommand<InitCommandDefinition> {
if (!destinationCanBeUsed) {
throw new errors.AbortedOperationError()
}
await fs.promises.rm(destination, { recursive: true, force: true })

await fs.promises.cp(srcDir, destination, { recursive: true })

Expand Down
5 changes: 3 additions & 2 deletions packages/zai/src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class Response<T = any, S = T> implements PromiseLike<S> {

signal.addEventListener('abort', () => signalAbort())

this.once('complete', () => signal.removeEventListener('abort', signalAbort))
this.once('error', () => signal.removeEventListener('abort', signalAbort))
void this.once('complete', () => signal.removeEventListener('abort', signalAbort))
void this.once('error', () => signal.removeEventListener('abort', signalAbort))

return this
}
Expand All @@ -78,6 +78,7 @@ export class Response<T = any, S = T> implements PromiseLike<S> {
this._context.controller.abort(reason)
}

// oxlint-disable-next-line no-thenable
public then<TResult1 = S, TResult2 = never>(
onfulfilled?: ((value: S) => TResult1 | PromiseLike<TResult1>) | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
Expand Down
2 changes: 1 addition & 1 deletion plugins/analytics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
11 changes: 11 additions & 0 deletions plugins/conversation-insights/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@botpresshub/conversation-insights",
"scripts": {
"check:type": "tsc --noEmit",
"build": "bp build"
},
"private": true,
"dependencies": {
"@botpress/sdk": "workspace:*"
}
}
29 changes: 29 additions & 0 deletions plugins/conversation-insights/plugin.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PluginDefinition, z } from '@botpress/sdk'

export default new PluginDefinition({
name: 'conversation-insights',
version: '0.1.3',
conversation: {
tags: {
title: { title: 'Title', description: 'The title of the conversation.' },
summary: {
title: 'Summary',
description: 'A summary of the current conversation. ',
},
message_count: {
title: 'Message count',
description: 'The count of messages sent in the conversation by both the bot and user(s). Type: int',
},
participant_count: {
title: 'Participant count',
description: 'The count of users having participated in the conversation, including the bot. Type: int',
},
isDirty: {
title: 'Dirty',
description: 'Signifies whether the conversation has had a new message since last refresh',
},
},
},
// TODO: replace this event with a workflow
events: { updateTitleAndSummary: { schema: z.object({}) } },
})
74 changes: 74 additions & 0 deletions plugins/conversation-insights/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import * as bp from '.botpress'

const plugin = new bp.Plugin({
actions: {},
})

// TODO: generate a type for CommonProps in the CLI / SDK
type CommonProps =
| bp.HookHandlerProps['after_incoming_message']
| bp.HookHandlerProps['after_outgoing_message']
| bp.EventHandlerProps

plugin.on.afterIncomingMessage('*', async (props) => {
const { conversation } = await props.client.getConversation({ id: props.data.conversationId })
await _onNewMessage({ ...props, conversation, isDirty: true })
return undefined
})

plugin.on.afterOutgoingMessage('*', async (props) => {
const { conversation } = await props.client.getConversation({ id: props.data.message.conversationId })
await _onNewMessage({ ...props, conversation, isDirty: false })
return undefined
})

plugin.on.event('updateTitleAndSummary', async (props) => {
const conversations = await props.client.listConversations({ tags: { isDirty: 'true' } })

for (const conversation of conversations.conversations) {
const messages = await props.client.listMessages({ conversationId: conversation.id })
const newMessages = messages.messages.map((message) => message.payload.text)
await _updateTitleAndSummary({ ...props, conversationId: conversation.id, messages: newMessages })
}
})

type OnNewMessageProps = CommonProps & {
conversation: bp.ClientOutputs['getConversation']['conversation']
isDirty: boolean
}
const _onNewMessage = async (props: OnNewMessageProps) => {
const message_count = props.conversation.tags.message_count ? parseInt(props.conversation.tags.message_count) + 1 : 1

const participant_count = await props.client
.listParticipants({ id: props.conversation.id })
.then(({ participants }) => participants.length)

const tags = {
message_count: message_count.toString(),
participant_count: participant_count.toString(),
isDirty: props.isDirty ? 'true' : 'false',
}

await props.client.updateConversation({
id: props.conversation.id,
tags,
})
}

type UpdateTitleAndSummaryProps = CommonProps & {
conversationId: string
messages: string[]
}
const _updateTitleAndSummary = async (props: UpdateTitleAndSummaryProps) => {
await props.client.updateConversation({
id: props.conversationId,
tags: {
// TODO: use the cognitive client / service to generate a title and summary
title: 'The conversation title!',
summary: 'This is normally where the conversation summary would be.',
isDirty: 'false',
},
})
}

export default plugin
8 changes: 8 additions & 0 deletions plugins/conversation-insights/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/file-synchronizer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/hitl/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/knowledge/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/logger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/personality/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*", "plugin.definition.ts"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
2 changes: 1 addition & 1 deletion plugins/synchronizer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"baseUrl": ".",
"outDir": "dist"
},
"include": [".botpress/**/*", "src/**/*"]
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "plugin.definition.ts"]
}
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

Loading