用途:在 Convex 项目中实现运行时相关功能,包括 HTTP actions、文件存储、全文与向量搜索、定时调度以及 RAG 模式。
主要能力:HTTP actions 通过 httpAction 定义处理函数,并在 convex/http.ts 中以 httpRouter 注册,默认导出为必需;这些 actions 必须暴露在 https://<deployment>.convex.site。上传流程提供两种方式:生成上传 URL 的 mutation 后由客户端 POST 并保存 storageId(URL 一小时后过期),或通过 HTTP action 调用 ctx.storage.store(blob),后者上传限制 20MB。文件读取可使用 ctx.storage.getUrl(storageId) 获取签名 URL 或 null,文件元数据通过 ctx.db.system.get("_storage", id) 或 query("_storage") 查询。搜索方面,全文搜索使用 withSearchIndex 与 q.search,按相关性排序,末词使用前缀匹配;向量搜索仅限 actions,且结果为非响应式。调度使用 ctx.scheduler.runAfter/runAt,cron 任务在 convex/crons.ts 中通过 cronJobs() 定义,必须使用 crons.interval 或 crons.cron,不可使用 crons.hourly/daily/weekly 等废弃写法;cron 调用内部函数必须从 _generated/api 导入 internal 对象。
使用方式与限制:HTTP actions 只能经 convex/http.ts 默认导出路由,需手动解析 Request,不支持 validators;文件上传 URL 一小时后过期,HTTP 上传上限 20MB;搜索建议在索引定义与查询中使用过滤器;定时函数参数需保持向后兼容。资料未提供更详细的安装或配置步骤。