@meetopenbot/plugin-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/helpers.d.ts +31 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +50 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +56 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +4 -0
- package/dist/plugin.js.map +1 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -0
- package/dist/storage.d.ts +164 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +2 -0
- package/dist/storage.js.map +1 -0
- package/dist/ui.d.ts +71 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +2 -0
- package/dist/ui.js.map +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# OpenBot Plugin SDK
|
|
2
|
+
|
|
3
|
+
The official SDK for building plugins for [OpenBot](https://meetopenbot.com). This SDK provides the types and helpers needed to create plugins that can handle events, interact with storage, and render UI widgets within the OpenBot ecosystem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @meetopenbot/plugin-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## How it Works
|
|
12
|
+
|
|
13
|
+
OpenBot plugins operate on an event-driven architecture powered by [Melony](https://github.com/meetopenbot/melony).
|
|
14
|
+
|
|
15
|
+
1. **Registration**: The host loads your plugin and calls the `factory` function with a `PluginContext`.
|
|
16
|
+
2. **Subscription**: Your `factory` function uses the `MelonyBuilder` to subscribe to specific events (e.g., `agent:invoke`).
|
|
17
|
+
3. **Processing**: When an event occurs, your handler is called. You can perform logic, interact with `storage`, or call external APIs.
|
|
18
|
+
4. **Publication**: Your handler can publish new events back to the bus (e.g., `agent:output` or `client:ui:widget`) to communicate with the user or other plugins.
|
|
19
|
+
|
|
20
|
+
## Core Concepts
|
|
21
|
+
|
|
22
|
+
### Plugin
|
|
23
|
+
|
|
24
|
+
A plugin is defined by the `Plugin` interface. It requires an `id`, `name`, `description`, and a `factory` function.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { Plugin, PluginContext, MelonyPlugin, OpenBotState, OpenBotEvent } from '@meetopenbot/plugin-sdk';
|
|
28
|
+
|
|
29
|
+
export const myPlugin: Plugin = {
|
|
30
|
+
id: 'my-plugin',
|
|
31
|
+
name: 'My Plugin',
|
|
32
|
+
description: 'A simple example plugin',
|
|
33
|
+
configSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
apiKey: { type: 'string', description: 'Your API Key', format: 'password' }
|
|
37
|
+
},
|
|
38
|
+
required: ['apiKey']
|
|
39
|
+
},
|
|
40
|
+
toolDefinitions: {
|
|
41
|
+
'get_weather': {
|
|
42
|
+
description: 'Get the current weather',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
location: { type: 'string' }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
factory: (context: PluginContext): MelonyPlugin<OpenBotState, OpenBotEvent> => {
|
|
52
|
+
return (builder) => {
|
|
53
|
+
// Handle events here
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Configuration & Tools
|
|
60
|
+
|
|
61
|
+
- **`configSchema`**: Defines the configuration options for your plugin. The host uses this to validate the configuration provided in `AGENT.md`.
|
|
62
|
+
- **`toolDefinitions`**: Defines the tools your plugin provides. Other plugins (like a runtime plugin) can use these definitions to call your plugin's tools.
|
|
63
|
+
|
|
64
|
+
### Events
|
|
65
|
+
|
|
66
|
+
Plugins communicate via an event bus. Common event types include:
|
|
67
|
+
|
|
68
|
+
- `agent:invoke`: Dispatched when a user sends a message to the agent.
|
|
69
|
+
- `agent:output`: Emitted by the agent to send a message back to the user.
|
|
70
|
+
- `client:ui:widget`: Used to render a UI widget in the client.
|
|
71
|
+
- `action:<toolName>`: Dispatched when a runtime requests a tool call.
|
|
72
|
+
- `action:<toolName>:result`: Emitted when a tool handler finishes.
|
|
73
|
+
|
|
74
|
+
### Storage
|
|
75
|
+
|
|
76
|
+
The `PluginContext` provides access to the `storage` interface, allowing plugins to interact with:
|
|
77
|
+
|
|
78
|
+
- **Channels & Threads**: Manage conversation contexts.
|
|
79
|
+
- **Agents**: Access and update agent details.
|
|
80
|
+
- **Variables**: Store configuration or secrets.
|
|
81
|
+
- **Files**: Read and list files in the channel's workspace.
|
|
82
|
+
- **Memories**: Store and retrieve long-term memory records.
|
|
83
|
+
|
|
84
|
+
### UI Widgets
|
|
85
|
+
|
|
86
|
+
Plugins can render interactive UI widgets using the `uiWidget` helper. Supported widget types include:
|
|
87
|
+
|
|
88
|
+
- `message`: Simple text message with optional actions.
|
|
89
|
+
- `choice`: A set of buttons for the user to choose from.
|
|
90
|
+
- `form`: A form with various field types (text, number, select, etc.).
|
|
91
|
+
- `list`: A list of items with status indicators.
|
|
92
|
+
|
|
93
|
+
## Example: Hello World Plugin
|
|
94
|
+
|
|
95
|
+
This plugin responds to any message with "Hello, World!".
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { Plugin, shouldHandleInvoke, agentOutput } from '@meetopenbot/plugin-sdk';
|
|
99
|
+
|
|
100
|
+
export const helloWorldPlugin: Plugin = {
|
|
101
|
+
id: 'hello-world',
|
|
102
|
+
name: 'Hello World',
|
|
103
|
+
description: 'Responds with Hello World',
|
|
104
|
+
factory: (context) => (builder) => {
|
|
105
|
+
builder.on('agent:invoke', async (event, { bus }) => {
|
|
106
|
+
if (shouldHandleInvoke(event, context.agentId)) {
|
|
107
|
+
await bus.publish(agentOutput({
|
|
108
|
+
agentId: context.agentId,
|
|
109
|
+
content: 'Hello, World!',
|
|
110
|
+
threadId: event.meta?.threadId,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## API Reference
|
|
119
|
+
|
|
120
|
+
- [Plugin & Context](./src/plugin.ts)
|
|
121
|
+
- [Events & State](./src/events.ts)
|
|
122
|
+
- [Storage Interface](./src/storage.ts)
|
|
123
|
+
- [UI Widget Specs](./src/ui.ts)
|
|
124
|
+
- [Helpers](./src/helpers.ts)
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { AgentDetails, ChannelDetails, ThreadDetails } from './storage.js';
|
|
2
|
+
import type { UIWidgetSpec } from './ui.js';
|
|
3
|
+
export type EventMeta = {
|
|
4
|
+
agentId?: string;
|
|
5
|
+
threadId?: string;
|
|
6
|
+
toolCallId?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type BaseEvent = {
|
|
10
|
+
id?: string;
|
|
11
|
+
type: string;
|
|
12
|
+
meta?: EventMeta;
|
|
13
|
+
};
|
|
14
|
+
export type AgentInvokeEvent = BaseEvent & {
|
|
15
|
+
type: 'agent:invoke';
|
|
16
|
+
data: {
|
|
17
|
+
role?: 'user' | 'assistant' | 'system';
|
|
18
|
+
content: string;
|
|
19
|
+
agentId?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type AgentOutputEvent = BaseEvent & {
|
|
23
|
+
type: 'agent:output';
|
|
24
|
+
data: {
|
|
25
|
+
content: string;
|
|
26
|
+
};
|
|
27
|
+
meta: EventMeta & {
|
|
28
|
+
agentId: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type UIWidgetEvent = BaseEvent & {
|
|
32
|
+
type: 'client:ui:widget';
|
|
33
|
+
data: UIWidgetSpec;
|
|
34
|
+
meta: EventMeta & {
|
|
35
|
+
agentId: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type UIWidgetResponseEvent = BaseEvent & {
|
|
39
|
+
type: 'client:ui:widget:response';
|
|
40
|
+
data: {
|
|
41
|
+
widgetId: string;
|
|
42
|
+
actionId: string;
|
|
43
|
+
values?: Record<string, unknown>;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/** `action:<toolName>` dispatched when a runtime requests a tool call. */
|
|
48
|
+
export type ToolActionEvent<TData = unknown> = BaseEvent & {
|
|
49
|
+
type: `action:${string}`;
|
|
50
|
+
data: TData;
|
|
51
|
+
meta?: EventMeta;
|
|
52
|
+
};
|
|
53
|
+
/** `action:<toolName>:result` emitted when a tool handler finishes. */
|
|
54
|
+
export type ToolResultEvent<TData = unknown> = BaseEvent & {
|
|
55
|
+
type: `action:${string}:result`;
|
|
56
|
+
data: TData;
|
|
57
|
+
meta?: EventMeta;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Narrow event union for common plugin authoring paths.
|
|
61
|
+
* The host bus accepts additional event types at runtime.
|
|
62
|
+
*/
|
|
63
|
+
export type PluginEvent = AgentInvokeEvent | AgentOutputEvent | UIWidgetEvent | UIWidgetResponseEvent | ToolActionEvent | ToolResultEvent;
|
|
64
|
+
export type OpenBotEvent = PluginEvent | (BaseEvent & {
|
|
65
|
+
data?: unknown;
|
|
66
|
+
});
|
|
67
|
+
export type ShortTermMessage = {
|
|
68
|
+
role: 'system';
|
|
69
|
+
content: string;
|
|
70
|
+
} | {
|
|
71
|
+
role: 'user';
|
|
72
|
+
content: string;
|
|
73
|
+
} | {
|
|
74
|
+
role: 'assistant';
|
|
75
|
+
content: string;
|
|
76
|
+
toolCalls?: unknown[];
|
|
77
|
+
} | {
|
|
78
|
+
role: 'tool';
|
|
79
|
+
content: string;
|
|
80
|
+
toolCallId: string;
|
|
81
|
+
toolName: string;
|
|
82
|
+
};
|
|
83
|
+
/** Runtime state available on Melony handler contexts. */
|
|
84
|
+
export interface OpenBotState {
|
|
85
|
+
agentId: string;
|
|
86
|
+
runId: string;
|
|
87
|
+
channelId: string;
|
|
88
|
+
threadId?: string;
|
|
89
|
+
agentDetails?: AgentDetails;
|
|
90
|
+
channelDetails?: ChannelDetails;
|
|
91
|
+
threadDetails?: ThreadDetails;
|
|
92
|
+
triggerEvent?: OpenBotEvent;
|
|
93
|
+
shortTermMessages?: ShortTermMessage[];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG;IACzC,IAAI,EAAE,cAAc,CAA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
|
|
|
1
|
+
import type { AgentInvokeEvent, AgentOutputEvent, EventMeta, ToolResultEvent, UIWidgetEvent } from './events.js';
|
|
2
|
+
import type { UIWidgetSpec } from './ui.js';
|
|
3
|
+
/** Return true when this agent should handle an `agent:invoke` event. */
|
|
4
|
+
export declare function shouldHandleInvoke(event: AgentInvokeEvent, agentId: string): boolean;
|
|
5
|
+
/** Build an `agent:output` event. */
|
|
6
|
+
export declare function agentOutput(args: {
|
|
7
|
+
agentId: string;
|
|
8
|
+
content: string;
|
|
9
|
+
threadId?: string;
|
|
10
|
+
meta?: EventMeta;
|
|
11
|
+
}): AgentOutputEvent;
|
|
12
|
+
/** Build an `action:<toolName>:result` event while preserving request meta. */
|
|
13
|
+
export declare function toolResult<TData>(toolName: string, request: {
|
|
14
|
+
meta?: EventMeta;
|
|
15
|
+
}, data: TData): ToolResultEvent<TData>;
|
|
16
|
+
/** Build a `client:ui:widget` event. */
|
|
17
|
+
export declare function uiWidget(args: {
|
|
18
|
+
agentId: string;
|
|
19
|
+
widget: UIWidgetSpec;
|
|
20
|
+
threadId?: string;
|
|
21
|
+
meta?: EventMeta;
|
|
22
|
+
}): UIWidgetEvent;
|
|
23
|
+
/** Copy `meta` from a source bus event onto a new event payload. */
|
|
24
|
+
export declare function withMeta<T extends {
|
|
25
|
+
meta?: EventMeta;
|
|
26
|
+
}>(source: {
|
|
27
|
+
meta?: EventMeta;
|
|
28
|
+
}, event: T): T & {
|
|
29
|
+
meta?: EventMeta;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpF;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,GAAG,gBAAgB,CAUnB;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,EAC7B,IAAI,EAAE,KAAK,GACV,eAAe,CAAC,KAAK,CAAC,CAMxB;AAED,wCAAwC;AACxC,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,GAAG,aAAa,CAUhB;AAED,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,EACrD,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,EAC5B,KAAK,EAAE,CAAC,GACP,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAS1B"}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Return true when this agent should handle an `agent:invoke` event. */
|
|
2
|
+
export function shouldHandleInvoke(event, agentId) {
|
|
3
|
+
const routedTo = event.data?.agentId;
|
|
4
|
+
return !(typeof routedTo === 'string' && routedTo && routedTo !== agentId);
|
|
5
|
+
}
|
|
6
|
+
/** Build an `agent:output` event. */
|
|
7
|
+
export function agentOutput(args) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'agent:output',
|
|
10
|
+
data: { content: args.content },
|
|
11
|
+
meta: {
|
|
12
|
+
...(args.meta ?? {}),
|
|
13
|
+
agentId: args.agentId,
|
|
14
|
+
...(args.threadId ? { threadId: args.threadId } : {}),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Build an `action:<toolName>:result` event while preserving request meta. */
|
|
19
|
+
export function toolResult(toolName, request, data) {
|
|
20
|
+
return {
|
|
21
|
+
type: `action:${toolName}:result`,
|
|
22
|
+
data,
|
|
23
|
+
meta: request.meta,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Build a `client:ui:widget` event. */
|
|
27
|
+
export function uiWidget(args) {
|
|
28
|
+
return {
|
|
29
|
+
type: 'client:ui:widget',
|
|
30
|
+
data: args.widget,
|
|
31
|
+
meta: {
|
|
32
|
+
...(args.meta ?? {}),
|
|
33
|
+
agentId: args.agentId,
|
|
34
|
+
...(args.threadId ? { threadId: args.threadId } : {}),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Copy `meta` from a source bus event onto a new event payload. */
|
|
39
|
+
export function withMeta(source, event) {
|
|
40
|
+
if (!source.meta)
|
|
41
|
+
return event;
|
|
42
|
+
return {
|
|
43
|
+
...event,
|
|
44
|
+
meta: {
|
|
45
|
+
...source.meta,
|
|
46
|
+
...(event.meta ?? {}),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AASA,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,KAAuB,EAAE,OAAe;IACzE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;IACrC,OAA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IAC/B,OAAO;QACL,GAAG,KAAK;QACR,IAAI,EAAE;YACJ,GAAG,MAAM,CAAC,IAAI;YACd,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;SACtB;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AgentDetails } from './storage.js';
|
|
2
|
+
import type { Storage } from './storage.js';
|
|
3
|
+
import type { PluginFactory } from './runtime.js';
|
|
4
|
+
/** Plugin reference from AGENT.md frontmatter. */
|
|
5
|
+
export interface PluginRef {
|
|
6
|
+
id: string;
|
|
7
|
+
config?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** JSON-schema-like description of per-plugin config in AGENT.md. */
|
|
10
|
+
export type ConfigSchema = {
|
|
11
|
+
type: 'object';
|
|
12
|
+
properties: {
|
|
13
|
+
[key: string]: {
|
|
14
|
+
type: 'string' | 'number' | 'boolean' | 'integer';
|
|
15
|
+
description?: string;
|
|
16
|
+
default?: unknown;
|
|
17
|
+
enum?: unknown[];
|
|
18
|
+
minimum?: number;
|
|
19
|
+
maximum?: number;
|
|
20
|
+
format?: 'password' | 'url' | 'email';
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
required?: string[];
|
|
24
|
+
};
|
|
25
|
+
/** Tool metadata merged across plugins and exposed to runtime plugins. */
|
|
26
|
+
export interface ToolDefinition {
|
|
27
|
+
description: string;
|
|
28
|
+
inputSchema: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** Context passed to `factory` when the host wires a plugin onto the bus. */
|
|
31
|
+
export interface PluginContext {
|
|
32
|
+
agentId: string;
|
|
33
|
+
agentDetails: AgentDetails;
|
|
34
|
+
config: Record<string, unknown>;
|
|
35
|
+
storage: Storage;
|
|
36
|
+
tools: Record<string, ToolDefinition>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Plugin contract expected by the OpenBot host.
|
|
40
|
+
* Roles (runtime, tool, middleware) are defined by which events `factory` handles.
|
|
41
|
+
*/
|
|
42
|
+
export interface Plugin {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
image?: string;
|
|
47
|
+
configSchema?: ConfigSchema;
|
|
48
|
+
toolDefinitions?: Record<string, ToolDefinition>;
|
|
49
|
+
factory: (context: PluginContext) => PluginFactory;
|
|
50
|
+
}
|
|
51
|
+
/** Community plugin module export. The host assigns `id` from the npm package name. */
|
|
52
|
+
export type PluginModule = Omit<Plugin, 'id'>;
|
|
53
|
+
/** Define a plugin with full OpenBot typing. */
|
|
54
|
+
export declare function definePlugin<T extends PluginModule>(definition: T): T;
|
|
55
|
+
export declare function definePlugin<T extends Plugin>(definition: T): T;
|
|
56
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],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B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACjD,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,aAAa,CAAC;CACpD;AAED,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE9C,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;AACvE,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AA8DA,MAAM,UAAU,YAAY,CAAkC,UAAa;IACzE,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MelonyBuilder, MelonyPlugin, RuntimeContext } from 'melony';
|
|
2
|
+
import type { OpenBotEvent, OpenBotState } from './events.js';
|
|
3
|
+
/** Context passed to plugin event handlers. */
|
|
4
|
+
export type PluginHandlerContext = RuntimeContext<OpenBotState, OpenBotEvent>;
|
|
5
|
+
/** Fluent builder surface exposed to plugin factories. */
|
|
6
|
+
export type PluginBuilder = MelonyBuilder<OpenBotState, OpenBotEvent>;
|
|
7
|
+
/** Function returned from `Plugin.factory` to register handlers on the bus. */
|
|
8
|
+
export type PluginFactory = MelonyPlugin<OpenBotState, OpenBotEvent>;
|
|
9
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAE9E,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAEtE,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { PluginRef } from './plugin.js';
|
|
2
|
+
export type Agent = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
image?: string;
|
|
7
|
+
plugins: string[];
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
};
|
|
11
|
+
export type AgentDetails = Agent & {
|
|
12
|
+
instructions: string;
|
|
13
|
+
pluginRefs: PluginRef[];
|
|
14
|
+
};
|
|
15
|
+
export type Channel = {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
cwd?: string;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
};
|
|
23
|
+
export type Thread = {
|
|
24
|
+
id: string;
|
|
25
|
+
title: string;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
};
|
|
29
|
+
export type ThreadDetails = {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
spec: string;
|
|
33
|
+
state: unknown;
|
|
34
|
+
};
|
|
35
|
+
export type ChannelDetails = {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
spec: string;
|
|
39
|
+
state: unknown;
|
|
40
|
+
cwd?: string;
|
|
41
|
+
threads?: Thread[];
|
|
42
|
+
};
|
|
43
|
+
export type MemoryRecord = {
|
|
44
|
+
id: string;
|
|
45
|
+
scope: string;
|
|
46
|
+
content: string;
|
|
47
|
+
tags?: string[];
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
};
|
|
51
|
+
export type ListMemoriesArgs = {
|
|
52
|
+
scopes?: string[];
|
|
53
|
+
query?: string;
|
|
54
|
+
tag?: string;
|
|
55
|
+
limit?: number;
|
|
56
|
+
};
|
|
57
|
+
/** Storage surface available on `PluginContext.storage`. */
|
|
58
|
+
export interface Storage {
|
|
59
|
+
getChannels: () => Promise<Channel[]>;
|
|
60
|
+
createChannel: (args: {
|
|
61
|
+
channelId: string;
|
|
62
|
+
spec?: string;
|
|
63
|
+
initialState?: Record<string, unknown>;
|
|
64
|
+
cwd?: string;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
createThread: (args: {
|
|
67
|
+
channelId: string;
|
|
68
|
+
threadId: string;
|
|
69
|
+
threadTitle?: string;
|
|
70
|
+
spec?: string;
|
|
71
|
+
initialState?: Record<string, unknown>;
|
|
72
|
+
}) => Promise<void>;
|
|
73
|
+
getThreads: (args: {
|
|
74
|
+
channelId: string;
|
|
75
|
+
}) => Promise<Thread[]>;
|
|
76
|
+
getThreadDetails: (args: {
|
|
77
|
+
channelId: string;
|
|
78
|
+
threadId: string;
|
|
79
|
+
}) => Promise<ThreadDetails>;
|
|
80
|
+
getAgents: () => Promise<Agent[]>;
|
|
81
|
+
getAgentDetails: (args: {
|
|
82
|
+
agentId: string;
|
|
83
|
+
}) => Promise<AgentDetails>;
|
|
84
|
+
createAgent: (args: {
|
|
85
|
+
agentId: string;
|
|
86
|
+
name: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
instructions: string;
|
|
89
|
+
plugins: PluginRef[];
|
|
90
|
+
}) => Promise<void>;
|
|
91
|
+
updateAgent: (args: {
|
|
92
|
+
agentId: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
instructions?: string;
|
|
96
|
+
plugins?: PluginRef[];
|
|
97
|
+
}) => Promise<void>;
|
|
98
|
+
deleteAgent: (args: {
|
|
99
|
+
agentId: string;
|
|
100
|
+
}) => Promise<void>;
|
|
101
|
+
getEvents: (args: {
|
|
102
|
+
channelId: string;
|
|
103
|
+
threadId?: string;
|
|
104
|
+
}) => Promise<unknown[]>;
|
|
105
|
+
getChannelDetails: (args: {
|
|
106
|
+
channelId: string;
|
|
107
|
+
}) => Promise<ChannelDetails>;
|
|
108
|
+
patchChannelState: (args: {
|
|
109
|
+
channelId: string;
|
|
110
|
+
state: unknown;
|
|
111
|
+
}) => Promise<void>;
|
|
112
|
+
patchThreadState: (args: {
|
|
113
|
+
channelId: string;
|
|
114
|
+
threadId: string;
|
|
115
|
+
state: unknown;
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
patchChannelSpec: (args: {
|
|
118
|
+
channelId: string;
|
|
119
|
+
spec: string;
|
|
120
|
+
}) => Promise<void>;
|
|
121
|
+
patchThreadSpec: (args: {
|
|
122
|
+
channelId: string;
|
|
123
|
+
threadId: string;
|
|
124
|
+
spec: string;
|
|
125
|
+
}) => Promise<void>;
|
|
126
|
+
getVariables: () => Promise<Record<string, string | {
|
|
127
|
+
value: string;
|
|
128
|
+
secret: boolean;
|
|
129
|
+
}>>;
|
|
130
|
+
createVariable: (args: {
|
|
131
|
+
key: string;
|
|
132
|
+
value: string;
|
|
133
|
+
secret?: boolean;
|
|
134
|
+
}) => Promise<void>;
|
|
135
|
+
deleteVariable: (args: {
|
|
136
|
+
key: string;
|
|
137
|
+
}) => Promise<void>;
|
|
138
|
+
listFiles: (args: {
|
|
139
|
+
channelId: string;
|
|
140
|
+
path?: string;
|
|
141
|
+
}) => Promise<Array<{
|
|
142
|
+
name: string;
|
|
143
|
+
isDirectory: boolean;
|
|
144
|
+
}>>;
|
|
145
|
+
readFile: (args: {
|
|
146
|
+
channelId: string;
|
|
147
|
+
path: string;
|
|
148
|
+
}) => Promise<string>;
|
|
149
|
+
appendMemory: (args: {
|
|
150
|
+
scope: string;
|
|
151
|
+
content: string;
|
|
152
|
+
tags?: string[];
|
|
153
|
+
}) => Promise<MemoryRecord>;
|
|
154
|
+
listMemories: (args?: ListMemoriesArgs) => Promise<MemoryRecord[]>;
|
|
155
|
+
deleteMemory: (args: {
|
|
156
|
+
id: string;
|
|
157
|
+
}) => Promise<boolean>;
|
|
158
|
+
updateMemory: (args: {
|
|
159
|
+
id: string;
|
|
160
|
+
content?: string;
|
|
161
|
+
tags?: string[];
|
|
162
|
+
}) => Promise<boolean>;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,MA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D,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7F"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":""}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type UIWidgetAction = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value?: unknown;
|
|
5
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type UIWidgetField = {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date';
|
|
12
|
+
description?: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
options?: Array<{
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}>;
|
|
19
|
+
defaultValue?: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type UIWidgetListItem = {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
status?: 'pending' | 'in_progress' | 'done' | 'error' | 'cancelled';
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
export type UIWidgetBase = {
|
|
29
|
+
widgetId: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
body?: string;
|
|
33
|
+
state?: 'open' | 'submitted' | 'cancelled' | 'error';
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
export type UIMessageWidget = UIWidgetBase & {
|
|
37
|
+
kind: 'message';
|
|
38
|
+
actions?: UIWidgetAction[];
|
|
39
|
+
};
|
|
40
|
+
export type UIChoiceWidget = UIWidgetBase & {
|
|
41
|
+
kind: 'choice';
|
|
42
|
+
actions: UIWidgetAction[];
|
|
43
|
+
};
|
|
44
|
+
export type UIFormWidget = UIWidgetBase & {
|
|
45
|
+
kind: 'form';
|
|
46
|
+
fields: UIWidgetField[];
|
|
47
|
+
submitLabel?: string;
|
|
48
|
+
actions?: UIWidgetAction[];
|
|
49
|
+
};
|
|
50
|
+
export type UIListWidget = UIWidgetBase & {
|
|
51
|
+
kind: 'list';
|
|
52
|
+
items: UIWidgetListItem[];
|
|
53
|
+
actions?: UIWidgetAction[];
|
|
54
|
+
};
|
|
55
|
+
export type UIWidgetSpec = UIMessageWidget | UIChoiceWidget | UIFormWidget | UIListWidget;
|
|
56
|
+
export type RenderUIWidgetData = (Omit<UIMessageWidget, 'widgetId'> & {
|
|
57
|
+
widgetId?: string;
|
|
58
|
+
}) | (Omit<UIChoiceWidget, 'widgetId'> & {
|
|
59
|
+
widgetId?: string;
|
|
60
|
+
}) | (Omit<UIFormWidget, 'widgetId'> & {
|
|
61
|
+
widgetId?: string;
|
|
62
|
+
}) | (Omit<UIListWidget, 'widgetId'> & {
|
|
63
|
+
widgetId?: string;
|
|
64
|
+
}) | {
|
|
65
|
+
kind: 'approval' | 'todo_list';
|
|
66
|
+
widgetId?: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
props?: Record<string, unknown>;
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC"}
|
package/dist/ui.js
ADDED
package/dist/ui.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meetopenbot/plugin-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Types and helpers for building OpenBot plugins on the event bus.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"melony": "^0.3.7",
|
|
26
|
+
"zod": "^4.3.5"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"melony": "^0.3.7",
|
|
30
|
+
"typescript": "^5.0.0",
|
|
31
|
+
"zod": "^4.3.5",
|
|
32
|
+
"@types/node": "^20.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|