@supaku/agentfactory-nextjs 0.4.0 → 0.4.2
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 +139 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @supaku/agentfactory-nextjs
|
|
2
|
+
|
|
3
|
+
Next.js route handlers, webhook processor, middleware, and OAuth for [AgentFactory](https://github.com/supaku/agentfactory). Drop-in API routes that turn a Next.js app into a full agent fleet server.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @supaku/agentfactory-nextjs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or scaffold a complete project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @supaku/create-agentfactory-app my-agent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Configure routes
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// src/lib/config.ts
|
|
23
|
+
import { createAllRoutes, createDefaultLinearClientResolver } from '@supaku/agentfactory-nextjs'
|
|
24
|
+
|
|
25
|
+
export const routes = createAllRoutes({
|
|
26
|
+
linearClient: createDefaultLinearClientResolver(),
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Add webhook route
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// src/app/webhook/route.ts
|
|
34
|
+
import { routes } from '@/lib/config'
|
|
35
|
+
export const POST = routes.webhook.POST
|
|
36
|
+
export const GET = routes.webhook.GET
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3. Add middleware
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// src/middleware.ts
|
|
43
|
+
import { createAgentFactoryMiddleware } from '@supaku/agentfactory-nextjs'
|
|
44
|
+
|
|
45
|
+
const { middleware } = createAgentFactoryMiddleware()
|
|
46
|
+
export { middleware }
|
|
47
|
+
|
|
48
|
+
export const config = {
|
|
49
|
+
matcher: ['/api/:path*', '/webhook', '/dashboard', '/sessions/:path*', '/'],
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What's Included
|
|
54
|
+
|
|
55
|
+
`createAllRoutes()` generates 21+ route handlers from a single config:
|
|
56
|
+
|
|
57
|
+
| Route Group | Endpoints | Purpose |
|
|
58
|
+
|-------------|-----------|---------|
|
|
59
|
+
| **Webhook** | `POST /webhook` | Receive Linear events, dispatch agents |
|
|
60
|
+
| **Workers** | `/api/workers/*` | Worker registration, heartbeat, polling |
|
|
61
|
+
| **Sessions** | `/api/sessions/*` | Session management, status, activity |
|
|
62
|
+
| **Public** | `/api/public/*` | Public stats, session list |
|
|
63
|
+
| **Cleanup** | `/api/cleanup` | Orphaned resource cleanup |
|
|
64
|
+
| **OAuth** | `/callback` | Linear OAuth callback |
|
|
65
|
+
|
|
66
|
+
Each route file is a 2-line re-export:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { routes } from '@/lib/config'
|
|
70
|
+
export const GET = routes.sessions.list.GET
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const routes = createAllRoutes({
|
|
77
|
+
// Required: how to resolve a Linear API client
|
|
78
|
+
linearClient: createDefaultLinearClientResolver(),
|
|
79
|
+
|
|
80
|
+
// Optional: customize prompts, detection, priority
|
|
81
|
+
generatePrompt: (identifier, workType, mentionContext) => string,
|
|
82
|
+
detectWorkTypeFromPrompt: (prompt, validWorkTypes) => AgentWorkType | undefined,
|
|
83
|
+
getPriority: (workType) => number,
|
|
84
|
+
|
|
85
|
+
// Optional: auto-trigger QA/acceptance
|
|
86
|
+
autoTrigger: {
|
|
87
|
+
enableAutoQA: true,
|
|
88
|
+
enableAutoAcceptance: false,
|
|
89
|
+
autoQARequireAgentWorked: true,
|
|
90
|
+
autoAcceptanceRequireAgentWorked: true,
|
|
91
|
+
autoQAProjects: [],
|
|
92
|
+
autoAcceptanceProjects: [],
|
|
93
|
+
autoQAExcludeLabels: [],
|
|
94
|
+
autoAcceptanceExcludeLabels: [],
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Optional: OAuth
|
|
98
|
+
oauth: { clientId: '...', clientSecret: '...' },
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Middleware
|
|
103
|
+
|
|
104
|
+
Handles API key auth, rate limiting, and webhook signature verification:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const { middleware } = createAgentFactoryMiddleware({
|
|
108
|
+
routes: {
|
|
109
|
+
public: ['/api/public/', '/dashboard', '/'],
|
|
110
|
+
protected: ['/api/sessions', '/api/workers'],
|
|
111
|
+
webhook: '/webhook',
|
|
112
|
+
},
|
|
113
|
+
rateLimits: {
|
|
114
|
+
public: { max: 60, windowMs: 60_000 },
|
|
115
|
+
webhook: { max: 10, windowMs: 1_000 },
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Environment Variables
|
|
121
|
+
|
|
122
|
+
| Variable | Required | Description |
|
|
123
|
+
|----------|----------|-------------|
|
|
124
|
+
| `LINEAR_ACCESS_TOKEN` | Yes | Linear API key |
|
|
125
|
+
| `LINEAR_WEBHOOK_SECRET` | For webhooks | Webhook signature verification |
|
|
126
|
+
| `REDIS_URL` | For distributed | Redis connection URL |
|
|
127
|
+
|
|
128
|
+
## Related Packages
|
|
129
|
+
|
|
130
|
+
| Package | Description |
|
|
131
|
+
|---------|-------------|
|
|
132
|
+
| [@supaku/agentfactory](https://www.npmjs.com/package/@supaku/agentfactory) | Core orchestrator |
|
|
133
|
+
| [@supaku/agentfactory-linear](https://www.npmjs.com/package/@supaku/agentfactory-linear) | Linear integration |
|
|
134
|
+
| [@supaku/agentfactory-server](https://www.npmjs.com/package/@supaku/agentfactory-server) | Redis infrastructure |
|
|
135
|
+
| [@supaku/agentfactory-cli](https://www.npmjs.com/package/@supaku/agentfactory-cli) | CLI tools |
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supaku/agentfactory-nextjs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Next.js API route handlers for AgentFactory — webhook processor, worker/session management, public stats",
|
|
6
6
|
"author": "Supaku (https://supaku.com)",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"LICENSE"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@supaku/agentfactory": "0.4.
|
|
47
|
-
"@supaku/agentfactory-server": "0.4.
|
|
48
|
-
"@supaku/agentfactory
|
|
46
|
+
"@supaku/agentfactory-linear": "0.4.2",
|
|
47
|
+
"@supaku/agentfactory-server": "0.4.2",
|
|
48
|
+
"@supaku/agentfactory": "0.4.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"next": ">=14.0.0"
|