npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@apetechs/ai-tool

v0.2.0

Published

Khai báo API của module NestJS thành tool cho APE AI Assistant (@AiTool, /ai/manifest)

Readme

ape-ai-tool

Khai báo API có sẵn của một module NestJS thành tool cho APE AI Assistant (ape-erp-chatbot). Module chỉ gắn decorator; guard, RBAC, DTO giữ nguyên. Hợp đồng đầy đủ: ape-erp-chatbot/docs/tool-contract.md.

Dùng

// app.module.ts
AiToolModule.forRoot({ module: 'eam', manifestKey: () => process.env.AI_MANIFEST_KEY, instructions: '...' });

// controller có sẵn
@DefPost('list')
@RequirePermissions([PERMISSION_CODES.ASSET.VIEW])
@AiTool({
  name: 'list_assets',
  description: 'Tìm thiết bị theo trạng thái… Không dùng để xem work order.',
  mode: 'read',
  input: { fields: ['serialNumber', 'operationalStatus'] },   // lấy schema từ @ApiProperty của DTO
  output: { listPath: 'data', totalPath: 'total', fields: ['id', 'assetName'] },
  recordUrl: '/assets/asset-instances?id={id}',
})
list(@Body() dto: ListAssetDto) {}

// một handler, sau middleware xác thực của module
@DefPost('context')
@AiToolContext()
context() { /* trả { tenantId, userId, tools: [...] } — xem ape_eam_api/src/modules/client/ai-tool */ }

// nút AI ở màn nghiệp vụ (0.2.0): handler trả dữ liệu, assistant đưa cho LLM với `instructions`, nhận object đúng `output`
@DefPost('pr-summary')
@RequirePermissions([PERMISSION_CODES.PURCHASE_REQUEST.VIEW])
@AiTask({
  name: 'pr_summary',
  description: 'Tóm tắt một PR',
  instructions: 'Bạn là trợ lý mua hàng… Chỉ dùng dữ liệu được đưa.',
  output: PrSummaryOutputDto,          // class có @ApiProperty → outputSchema
})
prSummary(@Body() dto: IdDto) { return this.service.prSummaryContext(dto.id) }
  • GET /<global prefix>/ai/manifest + header x-ai-manifest-key → danh sách tool, path đầy đủ (global prefix + prefix module của @ChildModule + controller + action), JSON Schema tham số, version = sha256 nội dung.
  • Manifest có tasks[] (0.2.0): name, instructions, method, path, inputSchema, outputSchema. Assistant gọi qua POST /tasks/<name>; task không bao giờ lẫn vào tools, một handler chỉ mang một trong @AiTool/@AiTask/@AiToolContext.
  • AiToolRegistry.tools() / tasks() trả thêm handler, controller để module tự kiểm quyền từng tool bằng guard của mình.
  • Field trong input.fields thiếu @ApiProperty, tên tool trùng, hoặc hai @AiToolContext() ⇒ lỗi khi dựng manifest.

Lệnh

yarn install --frozen-lockfile
yarn typecheck && yarn test && yarn build
./publish.sh                     # đăng nhập npm nếu cần, kiểm, publish, rồi cài vào ape_eam_api

Smoke test đầu-cuối

examples/chat-smoke.mjs (Node 22, không phụ thuộc gì) đi đúng đường assistant sẽ đi: manifest → context → LLM qua OpenRouter → gọi tool bằng token user → rút gọn kết quả. Cách chạy ghi ở đầu file.