You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/src/posts/2025-05-28-building-linear-agents-in-node-js-and-rivet-full-walkthrough-and-starter-kit/page.mdx
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,11 @@ This project is built with:
17
17
-[Linear SDK](https://developers.linear.app/docs/sdk/installation) for Linear API integration
18
18
-[AI SDK](https://ai-sdk.dev) for AI-powered responses
19
19
20
-
[View Source Code on GitHub](https://github.com/rivet-gg/rivet/tree/main/examples/linear-agent-starter).
20
+
[View Source Code on GitHub →](https://github.com/rivet-gg/rivet/tree/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter).
21
21
22
22
## TL;DR
23
23
24
-
The core functionality is in [`src/actors/issue-agent.ts`](https://github.com/rivet-gg/rivet/blob/05-27-docs_add_linear-agent-starter_example/examples/linear-agent-starter/src/actors/issue-agent.ts), where the agent handles different types of Linear events and interfaces with the LLM.
24
+
The core functionality is in [`src/actors/issue-agent.ts`](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/issue-agent.ts), where the agent handles different types of Linear events and interfaces with the LLM.
25
25
26
26
## Walkthrough
27
27
@@ -34,15 +34,15 @@ The Linear integration works through the following steps:
34
34
35
35
The system exposes three endpoints:
36
36
37
-
-`GET /connect-linear`: Initiates the Linear OAuth flow
-`POST /webhook/linear`: Receives Linear webhook events
37
+
-`GET /connect-linear`: Initiates the Linear OAuth flow ([src/server/index.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/server/index.ts#L41))
-`POST /webhook/linear`: Receives Linear webhook events ([src/server/index.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/server/index.ts#L116))
40
40
41
41
And maintains state using three main [ActorCore](https://actorcore.org) actors:
42
42
43
-
1.**Issue Agent** (`src/actors/issue-agent.ts`): Handles Linear issue events and generates responses
44
-
2.**Linear App User** (`src/actors/linear-app-user.ts`): Manages authentication state for the application
45
-
3.**OAuth Session** (`src/actors/oauth-session.ts`): Handles OAuth flow state
43
+
1.**Issue Agent**: Handles Linear issue events and generates responses ([src/actors/issue-agent.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/issue-agent.ts#L11))
44
+
2.**Linear App User**: Manages authentication state for the application ([src/actors/linear-app-user.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/linear-app-user.ts#L6))
45
+
3.**OAuth Session**: Handles OAuth flow state ([src/actors/oauth-session.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/oauth-session.ts#L10))
46
46
47
47
<Tip>
48
48
You can read more about actors [in the ActorCore documentation](https://actorcore.org/concepts/overview).
@@ -56,9 +56,9 @@ Before our agent can interact with a Linear workspace, we need to set up authent
56
56
57
57
**Step 1: Initial OAuth Request**
58
58
59
-
The user is directed to `GET /connect-linear` to initiate the OAuth flow:
59
+
The user is directed to `GET /connect-linear`([src/server/index.ts](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/server/index.ts#L41)) to initiate the OAuth flow:
60
60
- We generate a secure session with a unique ID and nonce
61
-
- We store this state in an `oauthSession` ActorCore actor
61
+
- We store this state in an [`oauthSession`](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/oauth-session.ts#L10) ActorCore actor
62
62
- We redirect to Linear's authorization page with our OAuth parameters
63
63
64
64
```typescript {{"title":"src/server/index.ts"}}
@@ -113,7 +113,7 @@ When the user completes authentication, Linear redirects to our callback URL wit
113
113
- We validate the state parameter for security
114
114
- We exchange the code for an access token
115
115
- We get the app user ID for the agent in this workspace (our unique identifier for this workspace)
116
-
- We store the access token in the `linearAppUser` ActorCore actor
116
+
- We store the access token in the [`linearAppUser`](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/linear-app-user.ts#L6) ActorCore actor
@@ -156,7 +156,7 @@ After OAuth completes, our agent is fully integrated with the Linear workspace:
156
156
157
157
Once a user has authorized our application in their Linear workspace, Linear sends webhook events to our endpoint whenever something happens that involves our agent.
158
158
159
-
The server parses these events and routes them to the appropriate handlers in `src/actors/issue-agent.ts`:
159
+
The server parses these events and routes them to the appropriate handlers in [`src/actors/issue-agent.ts`](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/issue-agent.ts#L11):
160
160
161
161
-**`issueMention`**: Triggered when the agent is mentioned in an issue description
162
162
-**`issueEmojiReaction`**: Triggered when someone reacts with an emoji to an issue
@@ -365,7 +365,7 @@ Before getting started with building your own Linear agent, make sure you have:
365
365
366
366
### Adding Your Own Functionality
367
367
368
-
The core of the agent is in `src/actors/issue-agent.ts`. You can customize:
368
+
The core of the agent is in [`src/actors/issue-agent.ts`](https://github.com/rivet-gg/rivet/blob/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter/src/actors/issue-agent.ts#L11). You can customize:
369
369
370
370
1.**Event Handlers**: Modify actions for different Linear events:
371
371
@@ -441,5 +441,5 @@ When building a Linear agent, consider these practices for a better developer ex
441
441
442
442
You can find the complete source code for this Linear agent starter kit on GitHub:
443
443
444
-
[View Source Code on GitHub](https://github.com/rivet-gg/rivet/tree/main/examples/linear-agent-starter)
444
+
[View Source Code on GitHub →](https://github.com/rivet-gg/rivet/tree/e13e6e95c56ea63bc73312fa7d01a647412ac507/examples/linear-agent-starter)
0 commit comments