@@ -122,7 +122,7 @@ Twist tools provide capabilities to twists. They are usually unopinionated and d
122122- ** Plot** - Manage activities and priorities
123123- ** Store** - Persistent key-value storage
124124- ** AI** - Language models with structured output
125- - ** Integrations** - OAuth authentication
125+ - ** Integrations** - OAuth authentication and channel lifecycle
126126- ** Network** - HTTP access and webhooks
127127- ** Tasks** - Background task execution
128128- ** Callbacks** - Persistent function references
@@ -243,27 +243,33 @@ export default class WelcomeTwist extends Twist<WelcomeTwist> {
243243}
244244```
245245
246- ### GitHub Integration
246+ ### GitHub Source
247247
248248``` typescript
249- export default class GitHubTwist extends Twist <GitHubTwist > {
250- build(build : ToolBuilder ) {
249+ import { Source , type SourceBuilder , type Channel } from " @plotday/twister" ;
250+ import { Integrations } from " @plotday/twister/tools/integrations" ;
251+
252+ export default class GitHubSource extends Source <GitHubSource > {
253+ build(build : SourceBuilder ) {
251254 return {
252- plot: build (Plot ),
253- network: build (Network , {
254- urls: [" https://api.github.com/*" ],
255- }),
255+ integrations: build (Integrations ),
256256 };
257257 }
258258
259- async activate(priority : Pick <Priority , " id" >) {
260- // Set up webhook for issue updates
261- const webhookUrl = await this .tools .network .createWebhook (" onIssueUpdate" );
262- await this .set (" webhook_url" , webhookUrl );
259+ async getChannels(): Promise <Channel []> {
260+ // Return repositories the user can sync
261+ return repos .map ((repo ) => ({
262+ id: repo .id ,
263+ name: repo .full_name ,
264+ }));
265+ }
266+
267+ async onChannelEnabled(channel : Channel ) {
268+ // Start syncing issues from this repository
263269 }
264270
265- async onIssueUpdate( request : WebhookRequest ) {
266- // Sync GitHub issues to Plot activities
271+ async onChannelDisabled( channel : Channel ) {
272+ // Stop syncing and clean up
267273 }
268274}
269275```
0 commit comments