ai-query对接新版freesun-agent接口的分支
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
858 B

/**
* 文件作用:
* 在已完成 ai-center 登录后,签发 Agent 可验证的短时 JWT。
*
* 职责:
* 1. 读取 tenderUserAuth 写入的当前用户。
* 2. 用 query api 配置的密钥签发 JWT,sub 为 ai-center userid。
*
* 不负责:
* 1. 代理 Agent 业务请求。
* 2. 把 ai-center token 转发给 Agent。
*/
'use strict';
const { issueAgentAccessToken } = require('../utils/agentJwt');
module.exports.issueAccessToken = async (ctx) => {
try {
const result = issueAgentAccessToken({
userInfo: ctx.fs?.curUser?.userInfo,
config: ctx.app.fs.config?.superAgent?.jwt,
});
ctx.status = 200;
ctx.body = result;
} catch (error) {
ctx.status = error.status || 500;
ctx.body = {
message: error.message || '签发 Agent 访问令牌失败',
};
}
};