feat: agent gateway

This commit is contained in:
Acbox
2026-01-28 14:00:28 +08:00
parent bb5482b982
commit 0711b1f086
22 changed files with 715 additions and 402 deletions
-4
View File
@@ -1,4 +0,0 @@
export * from './system'
export * from './schedule'
export * from './shared'
export * from './utils'
-26
View File
@@ -1,26 +0,0 @@
import { Schedule } from '@memoh/shared'
import { time } from './shared'
export interface ScheduleParams {
schedule: Schedule
locale?: Intl.LocalesArgument
date: Date
}
export const schedule = (params: ScheduleParams) => {
return `
---
notice: **This is a scheduled task automatically send to you by the system, not the user input**
${time({ date: params.date, locale: params.locale })}
schedule-name: ${params.schedule.name}
schedule-description: ${params.schedule.description}
schedule-id: ${params.schedule.id}
max-calls: ${params.schedule.maxCalls ?? 'Unlimited'}
cron-pattern: ${params.schedule.pattern}
---
**COMMAND**
${params.schedule.command}
`.trim()
}
-9
View File
@@ -1,9 +0,0 @@
export const time = (params: {
date: Date
locale?: Intl.LocalesArgument
}) => {
return `
date: ${params.date.toLocaleDateString(params.locale)}
time: ${params.date.toLocaleTimeString(params.locale)}
`.trim()
}
-51
View File
@@ -1,51 +0,0 @@
import { Platform } from '@memoh/shared'
import { time } from './shared'
import { quote } from './utils'
export interface SystemParams {
date: Date
locale?: Intl.LocalesArgument
language: string
maxContextLoadTime: number
platforms: Platform[]
currentPlatform: string
}
export const system = ({ date, locale, language, maxContextLoadTime, platforms, currentPlatform }: SystemParams) => {
return `
---
${time({ date, locale })}
language: ${language}
available-platforms:
${platforms.map(platform => ` - ${platform.name}`).join('\n')}
current-platform: ${currentPlatform}
---
You are a personal housekeeper assistant, which able to manage the master's daily affairs.
Your abilities:
- Long memory: You possess long-term memory; conversations from the last ${maxContextLoadTime} minutes will be directly loaded into your context. Additionally, you can use tools to search for past memories.
- Scheduled tasks: You can create scheduled tasks to automatically remind you to do something.
- Messaging: You may allowed to use message software to send messages to the master.
**Memory**
- Your context has been loaded from the last ${maxContextLoadTime} minutes.
- You can use ${quote('search-memory')} to search for past memories with natural language.
**Schedule**
- We use **Cron Syntax** to schedule tasks.
- You can use ${quote('get-schedules')} to get the list of schedules.
- You can use ${quote('remove-schedule')} to remove a schedule by id.
- You can use ${quote('schedule')} to schedule a task.
+ The ${quote('pattern')} is the pattern of the schedule with **Cron Syntax**.
+ The ${quote('command')} is the natural language command to execute, will send to you when the schedule is triggered, which means the command will be executed by presence of you.
+ The ${quote('maxCalls')} is the maximum number of calls to the schedule, If you want to run the task only once, set it to 1.
- The ${quote('command')} should include the method (e.g. ${quote('send-message')}) for returning the task result. If the user does not specify otherwise, the user should be asked how they would like to be notified.
**Message**
- You can use ${quote('send-message')} to send a message to the master.
+ The ${quote('platform')} is the platform to send the message to, it must be one of the ${quote('available-platforms')}.
+ The ${quote('message')} is the message to send.
+ IF: the problem is initiated by a user, regardless of the platform the user is using, the content should be directly output in the content.
+ IF: the issue is initiated by a non-user (such as a scheduled task reminder), then it should be sent using the appropriate tools on the platform specified in the requirements.
`.trim()
}
-7
View File
@@ -1,7 +0,0 @@
export const quote = (content: string) => {
return `\`${content}\``
}
export const block = (content: string, tag: string = '') => {
return `\`\`\`${tag}\n${content}\n\`\`\``
}