chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:34:48 +08:00
commit 77bb5bf71f
3762 changed files with 353249 additions and 0 deletions
@@ -0,0 +1,47 @@
import { ActionDefinition, z } from '@botpress/sdk'
import {
sessionSchema,
getAgentJobByIdInputSchema,
getAllAgentJobsOutputSchema,
createAgentJobInputSchema,
createAgentJobOutputSchema,
} from '../schemas'
const createAgentJob: ActionDefinition = {
title: 'Create Agent job',
description: 'Creates a new agent job that can generate and edit documentation in a branch based on a prompt.',
input: {
schema: createAgentJobInputSchema,
},
output: {
schema: createAgentJobOutputSchema,
},
}
const getAllAgentJobs: ActionDefinition = {
title: 'Get All Agent Jobs',
description: 'Retrieve all agent jobs, including their status and details.',
input: {
schema: z.object({}),
},
output: {
schema: getAllAgentJobsOutputSchema,
},
}
const getAgentJobById: ActionDefinition = {
title: 'Get Agent Job by ID',
description: 'Retrieve the details and status of a specific agent job by its ID.',
input: {
schema: getAgentJobByIdInputSchema,
},
output: {
schema: sessionSchema,
},
}
export const actions = {
createAgentJob,
getAllAgentJobs,
getAgentJobById,
} as const
@@ -0,0 +1,5 @@
import { actions as agentActions } from './agent'
export const actions = {
...agentActions,
} as const
@@ -0,0 +1 @@
export { actions } from './actions'
@@ -0,0 +1,48 @@
import { z } from '@botpress/sdk'
export const sessionSchema = z.object({
sessionId: z.string().title('Session ID').describe('The ID of the session.'),
subdomain: z.string().title('Subdomain').describe('The subdomain this session belongs to'),
branch: z.string().title('Branch').describe('Git branch name where changes were made.').nullable(),
haulted: z.boolean().title('Haulted').describe('Whether the session execution was halted.'),
haultReason: z.string().title('Hault reason').describe('Reason for session halt.'),
pullRequestLink: z.string().title('Pull request link').describe('Link to the created pull request.'),
messageToUser: z.string().title('Message to user').describe('Message for the user about the session outcome.'),
todos: z
.array(
z.object({
content: z.string().title('Content').describe('Brief description of the task.'),
status: z.string().title('Status').describe('Current status of the task.'),
priority: z.string().title('Priority').describe('Priority level of the task'),
id: z.string().title('ID').describe('Unique identifier for the todo item.'),
})
)
.title('Todos')
.describe('List of todo items from the session.'),
createdAt: z.string().title('Created at').describe('Timestamp when the session was created.'),
})
export const getAgentJobByIdInputSchema = z.object({
jobId: z.string().title('Job ID').describe('The unique identifier of the agent job to retrieve'),
})
export const getAllAgentJobsOutputSchema = z.object({
allSessions: z.array(sessionSchema).title('All sessions').describe('Array of all agent sessions for the domain'),
})
export const createAgentJobInputSchema = z.object({
prompt: z.string().title('Prompt').describe('The prompt to send the Mintlify agent'),
branchName: z
.string()
.title('Branch name')
.describe(
"The name of the branch the Mintlify agent will make changes on. If the branch doesn't exist, it'll automatically be created."
),
})
export const createAgentJobOutputSchema = z.object({
response: z
.string()
.title('Response')
.describe('Streaming response containing the agent job execution details and results.'),
})
+5
View File
@@ -0,0 +1,5 @@
# Mintlify integration
The Mintlify integration connects your bot to your Mintlify documentation, allowing it to create and manage [Mintlify agent](https://www.mintlify.com/docs/ai/agent) jobs. You can use the integration to automate updates to your documentation using AI and integrate Mintlify with other services.
> You need to be on a [Mintlify Pro](https://www.mintlify.com/pricing) plan to use this integration's Cards.
+7
View File
@@ -0,0 +1,7 @@
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="Mintlify--Streamline-Simple-Icons" height="24" width="24">
<desc>
Mintlify Streamline Icon: https://streamlinehq.com
</desc>
<title>Mintlify</title>
<path d="M15.158 0.002a8.807 8.807 0 0 0 -6.249 2.59l-0.062 0.063h-0.003L2.655 8.844a0.605 0.605 0 0 0 -0.062 0.058 8.838 8.838 0 0 0 -0.83 11.55l6.251 -6.249 0.065 -0.063a8.778 8.778 0 0 1 -1.758 -5.385 8.784 8.784 0 0 1 0.283 -2.151 8.993 8.993 0 0 1 2.151 -0.286 8.802 8.802 0 0 1 5.386 1.76 8.81 8.81 0 0 1 3.032 4.11 8.879 8.879 0 0 1 0.225 5.21 8.784 8.784 0 0 0 -0.341 0.082 8.846 8.846 0 0 1 -4.868 -0.303 8.679 8.679 0 0 1 -2.323 -1.25l-0.064 0.065L3.55 22.24a8.85 8.85 0 0 0 11.548 -0.83l0.06 -0.062 6.19 -6.187a8.801 8.801 0 0 1 -0.367 0.337c0.125 -0.11 0.247 -0.224 0.366 -0.341l0.063 -0.058A8.817 8.817 0 0 0 24 8.844V0.002ZM8.38 3.17Zm-0.325 0.413Zm-0.328 0.475Zm-0.31 0.518Zm-0.235 0.455Zm-0.283 0.66zm-0.156 0.447Zm14.147 9.44zm-0.43 0.343zm-1.005 0.65zm-0.533 0.274zm-0.475 0.207z" fill="#000000" stroke-width="1"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,23 @@
import { z, IntegrationDefinition } from '@botpress/sdk'
import { actions } from './definitions'
export default new IntegrationDefinition({
name: 'mintlify',
title: 'Mintlify',
description: 'Create and retrieve agent jobs in your Mintlify documentation',
version: '1.0.1',
readme: 'hub.md',
icon: 'icon.svg',
configuration: {
schema: z.object({
apiKey: z.string().title('API key').describe('Your Mintlify API key'),
projectId: z.string().title('Project ID').describe('Your Mintlify project ID'),
}),
},
actions,
attributes: {
category: 'File Management',
guideSlug: 'mintlify',
repo: 'botpress',
},
})
+19
View File
@@ -0,0 +1,19 @@
{
"name": "@botpresshub/mintlify",
"scripts": {
"check:type": "tsc --noEmit",
"build": "bp add -y && bp build",
"check:bplint": "bp lint",
"test": "vitest --run"
},
"private": true,
"dependencies": {
"@botpress/client": "workspace:*",
"@botpress/sdk": "workspace:*",
"axios": "^1.13.1"
},
"devDependencies": {
"@botpress/cli": "workspace:*",
"@botpress/sdk": "workspace:*"
}
}
@@ -0,0 +1,60 @@
import { RuntimeError } from '@botpress/sdk'
import { getAxiosClient } from 'src/utils/axiosClient'
import { extractError } from 'src/utils/errorUtils'
import * as bp from '.botpress'
export const createAgentJob: bp.IntegrationProps['actions']['createAgentJob'] = async ({
input,
client,
ctx,
logger,
}) => {
try {
const mintlifyClient = await getAxiosClient({ ctx, client })
const data = {
branch: input.branchName,
messages: [
{
role: 'system',
content: input.prompt,
},
],
}
const streamingResponse = await mintlifyClient.post('job', data)
return {
response: streamingResponse.data,
}
} catch (error) {
throw new RuntimeError(extractError(error, logger))
}
}
export const getAllAgentJobs: bp.IntegrationProps['actions']['getAllAgentJobs'] = async ({ client, ctx, logger }) => {
const mintlifyClient = await getAxiosClient({ ctx, client })
try {
const response = await mintlifyClient.get('jobs')
return response.data
} catch (error) {
throw new RuntimeError(extractError(error, logger))
}
}
export const getAgentJobById: bp.IntegrationProps['actions']['getAgentJobById'] = async ({
input,
client,
ctx,
logger,
}) => {
const mintlifyClient = await getAxiosClient({ ctx, client })
try {
const response = await mintlifyClient.get(`job/${[input.jobId]}`)
return response.data
} catch (error) {
throw new RuntimeError(extractError(error, logger))
}
}
@@ -0,0 +1,6 @@
import * as agentActions from './agent'
import * as bp from '.botpress'
export default {
...agentActions,
} as const satisfies bp.IntegrationProps['actions']
+11
View File
@@ -0,0 +1,11 @@
import actions from './actions'
import { register, unregister } from './setup'
import * as bp from '.botpress'
export default new bp.Integration({
register,
unregister,
actions,
channels: {},
handler: async () => {},
})
+27
View File
@@ -0,0 +1,27 @@
import { RuntimeError } from '@botpress/client'
import { AxiosError } from 'axios'
import { getAxiosClient } from './utils/axiosClient'
import * as bp from '.botpress'
export const register: bp.IntegrationProps['register'] = async ({ ctx, client, logger }) => {
try {
const mintlifyClient = await getAxiosClient({ ctx, client })
await mintlifyClient.get('jobs')
logger.forBot().info('Validated API key and project ID')
} catch (error: unknown) {
if (error instanceof AxiosError) {
const status = error.response?.status
if (status === 400) {
throw new RuntimeError('400 - Bad Request: Invalid project ID')
}
if (status === 401) {
throw new RuntimeError(`401 - Unauthorized: ${error.response?.data?.error || 'Unable to validate API key'}`)
}
}
const message = error instanceof Error ? error.message : String(error)
throw new RuntimeError(`Failed to validate configuration: ${message}`)
}
}
export const unregister: bp.IntegrationProps['unregister'] = async () => {}
+13
View File
@@ -0,0 +1,13 @@
import { RuntimeError } from '@botpress/client'
import * as bp from '.botpress'
export const getCredentials = async ({ ctx }: { client: bp.Client; ctx: bp.Context }) => {
const { apiKey, projectId } = ctx.configuration
if (!apiKey) {
throw new RuntimeError('API key not found')
} else if (!projectId) {
throw new RuntimeError('Project ID not found')
}
return { apiKey, projectId }
}
@@ -0,0 +1,28 @@
import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios'
import { getCredentials } from './auth'
import * as bp from '.botpress'
export const getAxiosClient = async ({
ctx,
client,
}: {
ctx: bp.Context
client: bp.Client
}): Promise<AxiosInstance> => {
const { apiKey, projectId } = await getCredentials({ ctx, client })
const baseURL = `https://api.mintlify.com/v1/agent/${projectId}`
const instance = axios.create({
baseURL,
headers: {
Authorization: `Bearer ${apiKey}`,
},
})
instance.interceptors.request.use((config: InternalAxiosRequestConfig) => {
config.headers = config.headers ?? {}
return config
})
return instance
}
@@ -0,0 +1,9 @@
import * as bp from '.botpress'
export const extractError = (error: any, logger: bp.Logger) => {
const fullErrorMsg = `${error?.errorCode || error?.message || 'Error'}`
if (error.response.data) logger.forBot().error(JSON.stringify(error.response.data))
logger.forBot().error(fullErrorMsg)
logger.forBot().error(JSON.stringify(error))
return fullErrorMsg
}
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"paths": { "*": ["./*"] },
"outDir": "dist"
},
"include": [".botpress/**/*", "definitions/**/*", "src/**/*", "*.ts"]
}
+2
View File
@@ -0,0 +1,2 @@
import config from '../../vitest.config'
export default config