feat(agent): add trigger-schedule api

This commit is contained in:
Acbox
2026-02-06 00:32:28 +08:00
parent 81155f2f78
commit 7d43c064c0
3 changed files with 27 additions and 4 deletions
+7 -1
View File
@@ -12,7 +12,13 @@ export const createAgent = ({
brave,
language = 'Same as the user input',
allowedActions = allActions,
identity,
identity = {
botId: '',
sessionId: '',
containerId: '',
contactId: '',
contactName: '',
},
platforms = [],
currentPlatform = 'Unknown Platform',
}: AgentParams, fetch: AuthFetcher) => {
+19 -2
View File
@@ -4,7 +4,7 @@ import { createAgent } from '../agent'
import { createAuthFetcher } from '../index'
import { ModelConfig } from '../types'
import { bearerMiddleware } from '../middlewares/bearer'
import { AllowedActionModel, IdentityContextModel, ModelConfigModel } from '../models'
import { AllowedActionModel, IdentityContextModel, ModelConfigModel, ScheduleModel } from '../models'
import { allActions } from '../types'
const AgentModel = z.object({
@@ -61,4 +61,21 @@ export const chatModule = new Elysia({ prefix: '/chat' })
}, {
body: AgentModel,
})
.post('/trigger-schedule', async ({ body, bearer }) => {
const authFetcher = createAuthFetcher(bearer)
const { triggerSchedule } = createAgent({
model: body.model as ModelConfig,
activeContextTime: body.activeContextTime,
platforms: body.platforms,
currentPlatform: body.currentPlatform,
allowedActions: body.allowedActions,
}, authFetcher)
return triggerSchedule({
schedule: body.schedule,
messages: body.messages,
})
}, {
body: AgentModel.extend({
schedule: ScheduleModel,
}),
})
+1 -1
View File
@@ -40,7 +40,7 @@ export interface AgentParams {
activeContextTime?: number
allowedActions?: AgentAction[]
brave?: BraveConfig
identity: IdentityContext
identity?: IdentityContext
platforms?: string[]
currentPlatform?: string
}