@AITool
Tool names must be kebab-case. Provide requiredApiPermission, argParser, and OpenAI-style toolDetail.
TSXai-tool
1import { AITool, Service } from "@quan-erp/shared-backend-core";
2
3@Service()
4export class ExchangeRateService {
5 @AITool({
6 requiredApiPermission: [{ method: "get", url: "/exchange-rate/" }],
7 argParser: (args) => [args.fromId, args.toId],
8 toolDetail: {
9 type: "function",
10 function: {
11 name: "get-rate",
12 description: "Get exchange rates",
13 parameters: { /* JSON schema */ },
14 },
15 },
16 })
17 async getRate(fromId: number, toId: number) { /* … */ }
18}Entity AI annotations
Control what the AI engine may scan on TypeORM entities. Keep table names prefixed with metadata.name and extend BaseEntity.
- @AIEntityInfo({ description }) — describe the entity for the AI
- @AIExcludeEntity() — hide the entire entity from AI indexing
- @AIExcludeColumn() — hide sensitive columns (passwords, secrets)
TSXentity
1import {
2 AIEntityInfo,
3 AIExcludeColumn,
4 BaseEntity,
5} from "@quan-erp/shared-backend-core";
6import { Column, Entity } from "typeorm";
7import metadata from "../../module.metadata.json" with { type: "json" };
8
9@AIEntityInfo({ description: "User credentials store" })
10@Entity(`${metadata.name}_credential`)
11export class CredentialEntity extends BaseEntity {
12 @AIExcludeColumn()
13 @Column({ type: "varchar", select: false })
14 password: string;
15}