-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal-dev.ts
More file actions
55 lines (48 loc) · 1.61 KB
/
Copy pathlocal-dev.ts
File metadata and controls
55 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Local Development Example
*
* This example shows how to use the plugin when developing locally
* or when the repo is cloned to the plugins directory.
*
* Setup Instructions:
* 1. Clone this repo to ~/.config/opencode/plugin/opencode-webhooks/
* 2. Copy this file to ~/.config/opencode/plugin/webhook.ts
* 3. Update the WEBHOOK_URL below
* 4. Restart OpenCode
*/
import type { Plugin } from '@opencode-ai/plugin';
import { createWebhookPlugin } from './opencode-webhooks/src/index.js';
// ============================================================================
// Configuration
// ============================================================================
const WEBHOOK_URL = 'https://your-webhook-endpoint.com/api/events';
// ============================================================================
// Plugin Setup
// ============================================================================
// Export the plugin with explicit type annotation for OpenCode
const LocalDevPlugin: Plugin = createWebhookPlugin({
webhooks: [
{
url: WEBHOOK_URL,
events: [
'session.created',
'session.idle',
'session.deleted',
'session.error',
'session.resumed',
'message.updated',
'message.part.updated',
],
// Optional: Extract message content
transformPayload: (payload) => {
const messageContent = payload.content || payload.text || payload.message;
return {
...payload,
messageContent: messageContent || null,
};
},
},
],
debug: true,
});
export default LocalDevPlugin;