feat: add username/slug based agent API endpoints
- Add /api/[username]/agents/[agentSlug]/conversation/[conversationId] - Add /api/[username]/agents/[agentSlug]/conversations - Update agent dashboard API docs to use new URL format - Include user.username in agent API response - Update Discord summary workflow to use new endpoint format
This commit is contained in:
parent
cd5eaeaf59
commit
efb30f7874
2 changed files with 6 additions and 2 deletions
5
.github/workflows/discord-summary.yml
vendored
5
.github/workflows/discord-summary.yml
vendored
|
|
@ -26,10 +26,11 @@ jobs:
|
||||||
echo "Triggering agent with conversation: ${{ steps.conv-id.outputs.conv_id }}"
|
echo "Triggering agent with conversation: ${{ steps.conv-id.outputs.conv_id }}"
|
||||||
|
|
||||||
# POST to the agent conversation endpoint
|
# POST to the agent conversation endpoint
|
||||||
# Agent ID: Discord Daily Summary agent on tpmjs.com
|
# Uses username/agent-slug URL format: /api/{username}/agents/{agent-slug}/conversation/{conv-id}
|
||||||
|
# Agent: ajax/tpmjs-discord-summary
|
||||||
# Requires API key with agent:chat scope
|
# Requires API key with agent:chat scope
|
||||||
RESPONSE=$(curl -s -X POST \
|
RESPONSE=$(curl -s -X POST \
|
||||||
"https://tpmjs.com/api/agents/cmk9utpvg0001kz04csbisvf5/conversation/${{ steps.conv-id.outputs.conv_id }}" \
|
"https://tpmjs.com/api/ajax/agents/tpmjs-discord-summary/conversation/${{ steps.conv-id.outputs.conv_id }}" \
|
||||||
-H "Authorization: Bearer $TPMJS_API_KEY" \
|
-H "Authorization: Bearer $TPMJS_API_KEY" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ async function getProviderModel(
|
||||||
* POST /api/agents/[id]/conversation/[conversationId]
|
* POST /api/agents/[id]/conversation/[conversationId]
|
||||||
* Send a message and stream the AI response via SSE
|
* Send a message and stream the AI response via SSE
|
||||||
*/
|
*/
|
||||||
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Complex streaming logic required
|
||||||
export async function POST(request: NextRequest, context: RouteContext): Promise<Response> {
|
export async function POST(request: NextRequest, context: RouteContext): Promise<Response> {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
|
@ -291,6 +292,7 @@ export async function POST(request: NextRequest, context: RouteContext): Promise
|
||||||
|
|
||||||
// Create SSE stream
|
// Create SSE stream
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Complex streaming logic
|
||||||
async start(controller) {
|
async start(controller) {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
|
@ -345,6 +347,7 @@ export async function POST(request: NextRequest, context: RouteContext): Promise
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Complex callback
|
||||||
onStepFinish: async ({ toolCalls, toolResults, usage }) => {
|
onStepFinish: async ({ toolCalls, toolResults, usage }) => {
|
||||||
// Capture tool calls from step finish (backup in case onChunk missed any)
|
// Capture tool calls from step finish (backup in case onChunk missed any)
|
||||||
if (toolCalls && Array.isArray(toolCalls)) {
|
if (toolCalls && Array.isArray(toolCalls)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue