Commit e6beccf
feat: Recoup Content Agent Slack bot (#342)
* feat: Recoup Content Agent Slack bot and /api/launch endpoint
Add content-agent Slack bot with mention handler for content generation,
callback endpoint for Trigger.dev task results, and /api/launch Release
Autopilot streaming endpoint.
Fixes from code review:
- Remove ~90 unrelated JSDoc-only changes to existing files
- Rename handlers/handleContentAgentCallback.ts to registerOnSubscribedMessage.ts
to resolve naming collision with the top-level handler
- Use crypto.timingSafeEqual for callback secret comparison
- Fix all JSDoc lint errors in new files
Co-Authored-By: Paperclip <noreply@paperclip.ing>
* fix: lazy bot init and thread ID validation (review feedback)
- bot.ts: Replace eager module-scope singleton with lazy
getContentAgentBot() so Vercel build does not crash when
content-agent env vars are not yet configured
- getThread.ts: Add regex validation for adapter:channel:thread
format, throw descriptive error on malformed IDs
- registerHandlers.ts: Convert side-effect import to explicit
ensureHandlersRegistered() call with idempotency guard
- Route files updated to use getContentAgentBot() and
ensureHandlersRegistered()
Co-Authored-By: Paperclip <noreply@paperclip.ing>
* fix: graceful 503 when content-agent env vars missing
- Add isContentAgentConfigured() check to all content-agent routes
- Routes return 503 {"error": "Content agent not configured"} when
env vars are not set, instead of crashing with 500
- Move x-callback-secret auth check to route level (runs before
bot initialization)
- Remove duplicate auth from handleContentAgentCallback handler
Co-Authored-By: Paperclip <noreply@paperclip.ing>
* refactor(content-agent): address CLEAN code review feedback
- YAGNI: Remove unused /api/launch endpoint and lib/launch/
- SRP: Extract parseMentionArgs to its own file
- SRP: Rename handleContentAgentMention.ts → registerOnNewMention.ts
- DRY: Create shared createPlatformRoutes factory for agent webhook routes
- DRY: Extract shared createAgentState for Redis/ioredis state setup
- KISS: Move callback auth into handler to match coding-agent pattern
- Restructure lib/content-agent/ → lib/agents/content/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(content-agent): address round 2 review feedback
SRP: Split validateEnv.ts into isContentAgentConfigured.ts and
validateContentAgentEnv.ts (one export per file).
KISS: Refactor bot.ts to follow coding-agent eager singleton pattern
(contentAgentBot variable instead of getContentAgentBot function).
KISS: Refactor registerHandlers.ts to use module-level side-effect
registration matching coding-agent pattern (removed registered flag).
DRY: Extract shared getThread to lib/agents/getThread.ts, used by
both content-agent and coding-agent.
CodeRabbit: Add Zod platform param validation and consistent JSON
error responses in createPlatformRoutes.ts.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
* fix(content-agent): address round 3 CodeRabbit review feedback
- Fix unhandled promise rejection in createAgentState (log instead of throw in .catch)
- Fix timingSafeEqual byte-length comparison in callback auth
- Add idempotency guard in callback handler (skip if thread not running)
- Add threadId format validation regex in Zod schema
- Reset thread state to failed on triggerPollContentRun failure
- Guard against bot echo loops in onSubscribedMessage handler
Co-Authored-By: Paperclip <noreply@paperclip.ing>
* refactor: use CODING_AGENT_CALLBACK_SECRET instead of CONTENT_AGENT_CALLBACK_SECRET
Reuses the existing coding agent callback secret env var so we don't
need to configure a separate secret for the content agent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add tests for content agent env validation and callback auth
Verifies that:
- CODING_AGENT_CALLBACK_SECRET is used (not CONTENT_AGENT_CALLBACK_SECRET)
- validateContentAgentEnv throws when env vars are missing
- isContentAgentConfigured returns false when env vars are missing
- handleContentAgentCallback rejects invalid/missing secrets
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: fix prettier formatting in test file
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* debug: log missing env vars in isContentAgentConfigured
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: strip Slack mention prefixes in parseMentionArgs
Slack sends mention text as `<@U0ABC123> <artist_id> ...` but
parseMentionArgs was treating the `<@...>` token as the artistAccountId,
causing the real ID to be parsed as the template name.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: handle mixed-case Slack mention IDs and add debug logging
The regex only matched uppercase <@U0ABC123> but Slack IDs can contain
lowercase letters. Also logs raw mention text to diagnose parsing issues.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* debug: hardcode artist ID for testing content agent
Temporarily hardcodes artist ID 1873859c-dd37-4e9a-9bac-80d3558527a9
to bypass mention parsing issues during testing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: remove parseMentionArgs, hardcode defaults for testing
Simplifies onNewMention to use hardcoded artist ID and default values
for template, batch, and lipsync to get end-to-end flow working.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use correct accountId for content agent testing
accountId (fb678396-...) is the user's account, artistAccountId
(1873859c-...) is the artist. Previously both were set to the artist ID.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove coding-agent getThread wrapper and fix lint issues
- Delete lib/coding-agent/getThread.ts wrapper (KISS nit from code review)
- Update callers to import getThread directly from lib/agents/getThread
- Fix unused 'message' parameter in registerOnNewMention.ts
- Update tests to use shared getThread path
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: CTO Agent <cto@recoup.ai>
Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>1 parent 6c9d72a commit e6beccf
File tree
25 files changed
+762
-97
lines changed- app/api
- coding-agent/[platform]
- content-agent
- [platform]
- callback
- lib
- agents
- content
- __tests__
- handlers
- coding-agent
- __tests__
- trigger
25 files changed
+762
-97
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
8 | | - | |
| 6 | + | |
9 | 7 | | |
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 | | - | |
| 8 | + | |
| 9 | + | |
38 | 10 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
0 commit comments