Bizwings Plugin SDK
Build plugins that extend the Bizwings platform.
Overview
A Bizwings plugin is a TypeScript module that implements the BizwingsPlugin interface. Plugins extend the platform with new agent behaviours - custom tools, event subscriptions, external integrations - without touching the core codebase.
The flow is simple: implement the interface, submit the bundled code via the submission API, the Bizwings team reviews it and runs it through the sandbox, and once approved it becomes available for tenants to install.
The BizwingsPlugin Interface
This is the contract every plugin must implement:
import { z } from 'zod'
export type AgentCategory =
| 'communication'
| 'lead_generation'
| 'marketing'
| 'support'
| 'analytics'
| 'productivity'
| 'integration'
| 'custom'
export interface ToolDefinition {
name: string
description: string
parameters: z.ZodSchema
execute: (params: unknown, context: PluginContext) => Promise<unknown>
}
export interface EventDefinition {
type: string
description: string
payloadSchema: z.ZodSchema
}
export interface EventSubscription {
eventType: string
handler: (payload: unknown, context: PluginContext) => Promise<void>
}
export interface ResourceRequirement {
type: 'llm' | 'voice' | 'sms' | 'email' | 'storage' | 'webhook'
required: boolean
description: string
}
export interface PluginContext {
tenantId: string
agentId: string
runId: string
config: Record<string, unknown>
logger: {
info: (msg: string, meta?: Record<string, unknown>) => void
warn: (msg: string, meta?: Record<string, unknown>) => void
error: (msg: string, meta?: Record<string, unknown>) => void
}
db: {
query: (sql: string, params?: unknown[]) => Promise<unknown[]>
}
http: {
get: (url: string, headers?: Record<string, string>) => Promise<{ status: number; body: unknown }>
post: (url: string, body: unknown, headers?: Record<string, string>) => Promise<{ status: number; body: unknown }>
}
emit: (eventType: string, payload: unknown) => Promise<void>
trackUsage: (metric: string, quantity: number) => void
}
export interface AgentInput {
trigger: string
payload: Record<string, unknown>
conversationHistory?: Array<{ role: 'user' | 'assistant'; content: string }>
}
export interface AgentResult {
success: boolean
output?: Record<string, unknown>
error?: string
tokensUsed?: number
costCents?: number
metadata?: Record<string, unknown>
}
export type HealthCheckFunction = () => Promise<{
healthy: boolean
message?: string
latencyMs?: number
}>
export interface MetricsDefinition {
name: string
type: 'counter' | 'gauge' | 'histogram'
description: string
labels?: string[]
}
export interface TestDefinition {
name: string
input: AgentInput
expectedOutput?: Partial<AgentResult>
timeoutMs?: number
}
// Every third-party plugin MUST implement this interface.
export interface BizwingsPlugin {
// Identity
readonly id: string // unique slug, e.g. "my-company-crm-sync"
readonly version: string // semver, e.g. "1.0.0"
readonly displayName: string
readonly description: string
readonly category: AgentCategory
readonly author: {
name: string
email: string
url?: string
}
// Schema
getConfigSchema(): z.ZodSchema
getDefaultConfig(): Record<string, unknown>
// Capabilities
getRequiredResources(): ResourceRequirement[]
getProvidedTools(): ToolDefinition[]
getEmittedEvents(): EventDefinition[]
getSubscribedEvents(): EventSubscription[]
// Lifecycle
onInstall?: (tenantId: string, config: Record<string, unknown>) => Promise<void>
onUninstall?: (tenantId: string) => Promise<void>
onConfigChange?: (tenantId: string, oldConfig: Record<string, unknown>, newConfig: Record<string, unknown>) => Promise<void>
// Execution
execute(context: PluginContext, input: AgentInput): Promise<AgentResult>
// Observability
getHealthCheck(): HealthCheckFunction
getMetrics(): MetricsDefinition[]
getTestSuite(): TestDefinition[]
}Example Plugin
A minimal plugin that logs its input and returns a greeting. Notice the module export default - the sandbox resolves the plugin instance from module.exports.default or the module itself.
import { z } from 'zod'
export default {
id: 'my-company-hello-world',
version: '1.0.0',
displayName: 'Hello World Plugin',
description: 'A minimal example plugin',
category: 'custom',
author: { name: 'Your Name', email: 'you@example.com' },
getConfigSchema: () => z.object({ greeting: z.string().default('Hello') }),
getDefaultConfig: () => ({ greeting: 'Hello' }),
getRequiredResources: () => [],
getProvidedTools: () => [],
getEmittedEvents: () => [],
getSubscribedEvents: () => [],
execute: async (context, input) => {
context.logger.info('Plugin executed', { input })
return { success: true, output: { message: `${context.config.greeting}, world!` } }
},
getHealthCheck: () => async () => ({ healthy: true, latencyMs: 0 }),
getMetrics: () => [],
getTestSuite: () => [
{
name: 'basic execution',
input: { trigger: 'manual', payload: {} },
expectedOutput: { success: true },
timeoutMs: 5000,
}
],
}Because the sandbox evaluates plugin code via new Function("exports", "require", code), you must ship your plugin as a single CommonJS-compatible string with all dependencies bundled in. require() is disabled in the sandbox - inline any small helpers you need.
Submitting Your Plugin
POST to /api/plugins while signed in. The endpoint is rate-limited to 10 submissions per minute per user.
curl -X POST https://bizwingsai.com/api/plugins \
-H "Content-Type: application/json" \
-H "Cookie: <your session cookie>" \
-H "x-bizwings-csrf: 1" \
-d '{
"slug": "my-company-hello-world",
"name": "Hello World Plugin",
"description": "A minimal example plugin",
"version": "1.0.0",
"author_name": "Your Name",
"author_email": "you@example.com",
"plugin_code": "<your bundled plugin code as a single CommonJS string>",
"config_schema": {}
}'A successful submission returns 201 with the new plugin record. Your plugin enters the pending state and waits for review. If the slug you pick is already taken the endpoint returns 409 SLUG_CONFLICT.
Sandbox Testing
After submission the Bizwings team runs your plugin through the sandbox from the admin panel. The sandbox executes the plugin’s test suite - the getTestSuite() array - in isolation, and calls your getHealthCheck() first to confirm the plugin starts cleanly.
During a sandbox run, the fake PluginContext blocks real infrastructure access:
context.db.query()throws - no database access during sandbox.context.http.get() / context.http.post()throw - no outbound HTTP during sandbox.context.logger.*andcontext.emit()still work and are captured for inspection.- Each test has a 10-second default timeout (override with
timeoutMson the test definition).
Write tests that cover your plugin’s happy path and one or two edge cases. Plugins whose sandbox runs fail or error are unlikely to be approved.
Plugin Lifecycle
- submitted - developer POSTs to /api/plugins. Record created with status
pending. - reviewed - Bizwings team reads the plugin code in the admin panel.
- sandbox tested - admin runs
POST /api/plugins/[id]/sandbox. Health check + test suite must all pass. - approved or rejected - admin PATCHes the plugin’s status. Rejections include a reason in
review_notes. - installable - approved plugins can be installed by any tenant (tenant-facing install UI is shipping alongside the open marketplace).
- suspended - an approved plugin can be suspended at any time if it misbehaves in production. Existing installations are paused until the suspension is lifted.