{"_id":"@botly-ai/sdk","_rev":"2-0f3845c65a9a8775114a40daa47003fa","name":"@botly-ai/sdk","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.2":{"name":"@botly-ai/sdk","version":"1.0.2","keywords":[],"author":"","license":"ISC","_id":"@botly-ai/sdk@1.0.2","maintainers":[{"name":"nicolasfcoelho","email":"nkxynickftw@gmail.com"}],"dist":{"shasum":"6d695b857ed32234ffa98495cf56958c1b67b5e8","tarball":"https://registry.npmjs.org/@botly-ai/sdk/-/sdk-1.0.2.tgz","fileCount":29,"integrity":"sha512-3TXViZrEbK+wS21bNu4KjBs/qN/sDN00xfnEt0KiOMwg4LlBco9E8Lts9XVPLvpn9H+dovHXkrqTIiYoW4HvXA==","signatures":[{"sig":"MEQCIAQ4RgntuIitpjk6tl4fNUam0ppdSaaVRkRwhkE9xJkVAiB9Ohn9Y5W8CF5HxvA7ysBRlTSEJpFisFmLx42JTsxC5Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":58318},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"7099d28d0fa7c1e937a6820e7b3522f23070fe16","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsup","clean":"rm -rf dist","release:major":"npm version major && git push --follow-tags","release:minor":"npm version minor && git push --follow-tags","release:patch":"npm version patch && git push --follow-tags","prepublishOnly":"pnpm clean && pnpm build"},"_npmUser":{"name":"nicolasfcoelho","email":"nkxynickftw@gmail.com"},"_npmVersion":"10.9.3","description":"A TypeScript SDK for building AI agents with tool calling, multiple providers, and structured callbacks.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"openai":"^6.10.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","typescript":"^5.9.3","@types/node":"^25.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.2_1765603936793_0.1478367017280564","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@botly-ai/sdk","version":"1.0.4","description":"A TypeScript SDK for building AI agents with tool calling, multiple providers, and structured callbacks.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"clean":"rm -rf dist","test":"echo \"Error: no test specified\" && exit 1","build":"tsup","prepublishOnly":"pnpm clean && pnpm build","release:patch":"npm version patch && git push --follow-tags","release:minor":"npm version minor && git push --follow-tags","release:major":"npm version major && git push --follow-tags"},"keywords":[],"author":"","license":"ISC","devDependencies":{"@types/node":"^25.0.0","tsup":"^8.5.1","typescript":"^5.9.3"},"dependencies":{"openai":"^6.10.0"},"_id":"@botly-ai/sdk@1.0.4","gitHead":"6bc92a882970bd8579b318e115ef5cda93f60be3","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-+JF4FVIl9lo1jiLau2hH2akvASyYeSGy49YlDNWXpH+1STs3p0hH3+NMg6WNXdkEWPZFWVMw7ps2fltKh5u7lw==","shasum":"d47d8fe391f951b52188416e4414d1f0fe2374cb","tarball":"https://registry.npmjs.org/@botly-ai/sdk/-/sdk-1.0.4.tgz","fileCount":29,"unpackedSize":58269,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAXnLtmhACLEXuMG38NKszC0K2rMTn4L3Wk8NjyNrjhnAiAHIslh/kjz4k2P7JH8XK58xu5xXdO94TjAan4alNwGZQ=="}]},"_npmUser":{"name":"nicolasfcoelho","email":"nkxynickftw@gmail.com"},"directories":{},"maintainers":[{"name":"nicolasfcoelho","email":"nkxynickftw@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.4_1765664520805_0.48888182169642347"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-13T05:32:16.684Z","modified":"2025-12-13T22:22:01.146Z","1.0.2":"2025-12-13T05:32:16.953Z","1.0.4":"2025-12-13T22:22:00.948Z"},"license":"ISC","keywords":[],"description":"A TypeScript SDK for building AI agents with tool calling, multiple providers, and structured callbacks.","maintainers":[{"name":"nicolasfcoelho","email":"nkxynickftw@gmail.com"}],"readme":"# @botly-ai/sdk\n\n🔗 **Site oficial:** [https://botly.com.br](https://botly.com.br)\n\nSDK TypeScript para criar **assistentes de IA com ferramentas (tools)** de forma simples, tipada e extensível — ideal para backends Node.js e aplicações NestJS.\n\nO `@botly-ai/sdk` abstrai a comunicação com provedores de LLM (ex: OpenAI) e facilita:\n\n* Gerenciamento de mensagens\n* Execução de tools com callbacks\n* Tipagem forte em TypeScript\n* Fluxos com segunda resposta automática do modelo\n\n---\n\n## Instalação\n\n```bash\npnpm add @botly-ai/sdk\n# ou\nnpm install @botly-ai/sdk\n# ou\nyarn add @botly-ai/sdk\n```\n\n---\n\n## Uso básico (Node.js / TypeScript)\n\nExemplo de uso simples em um arquivo TypeScript, sem dependência de frameworks.\n\n```ts\nimport { Botly } from \"@botly-ai/sdk\";\n\nconst messages: { role: 'user' | 'assistant'; content: string }[] = [];\n\nasync function run() {\n    const client = new Botly({\n        apiKey: process.env.OPENAI_API_KEY ?? '',\n        provider: 'openai',\n        model: 'gpt-4o-mini',\n        temperature: 0.7,\n        systemPrompt: 'You are a helpful assistant that can answer questions and help with tasks.',\n    });\n\n    messages.push({ role: 'user', content: 'How many users do we have?' });\n\n    const response = await client.response({\n        input: [...messages],\n        secondResponseCallback: true,\n        tools: [\n            {\n                name: 'get_user_count',\n                description: 'Get the number of users in the database',\n                fields: [\n                    {\n                        name: 'user_type',\n                        type: 'string',\n                        description: 'The type of user to get the count of',\n                    },\n                ],\n                async callback({ user_type }: { user_type: string }) {\n                    console.log('User type:', user_type);\n\n                    return {\n                        count: 1000,\n                    };\n                },\n            },\n            {\n                name: 'create_new_user',\n                description: 'Create a new user in the database',\n                fields: [\n                    { name: 'name', type: 'string' },\n                    { name: 'email', type: 'string' },\n                    { name: 'phone', type: 'string' },\n                ],\n                async callback({ name, email, phone }: { name: string; email: string; phone: string }) {\n                    console.log(name, email, phone);\n\n                    return {\n                        message: 'User created successfully',\n                    };\n                },\n            },\n        ],\n    });\n\n    messages.push({ role: 'assistant', content: response.output_text ?? '' });\n\n    console.log(response.output_text);\n}\n\nrun();\n```\n\n---\n\n## Conceitos principais\n\n### Botly Client\n\n```ts\nconst client = new Botly({\n  apiKey: process.env.OPENAI_API_KEY!,\n  provider: 'openai',\n  model: 'gpt-4o-mini',\n  temperature: 0.7,\n  systemPrompt: 'You are a helpful assistant',\n});\n```\n\n**Opções principais:**\n\n* `apiKey`: chave do provedor\n* `provider`: provedor de LLM (`openai`, etc.)\n* `model`: modelo utilizado\n* `temperature`: nível de criatividade\n* `systemPrompt`: prompt base do agente\n\n---\n\n### Messages (input)\n\nO histórico de mensagens segue o padrão:\n\n```ts\n{\n  name: 'get_user_count',\n  description: 'Get the number of users stored in the system',\n  fields: [\n    {\n      name: 'user_type',\n      type: 'string',\n      description: 'The type of user to get the count of (e.g. admin, customer, guest)',\n    }\n  ],\n  async callback(args) {\n    // args is already a parsed JSON object\n    // matching the schema defined in `fields`\n    const { user_type } = args;\n\n    return { count: 1000 };\n  }\n}\n```\n\nVocê controla totalmente o estado da conversa.\n\n---\n\n### Tools (Function Calling)\n\nCada tool possui:\n\n* `name`\n* `description`\n* `fields` (schema de entrada)\n* `callback` assíncrono\n\n```ts\n{\n  name: 'get_user_count',\n  fields: [\n    { name: 'user_type', type: 'string' }\n  ],\n  async callback(args) {\n    return { count: 1000 };\n  }\n}\n```\n\nO modelo decide **quando chamar a tool**, e o `@botly-ai/sdk` executa o callback automaticamente.\n\n---\n\n### secondResponseCallback\n\n```ts\nsecondResponseCallback: true\n```\n\nQuando ativado:\n\n1. O modelo chama a tool\n2. O callback é executado\n3. O resultado volta para o modelo\n4. O modelo gera **uma segunda resposta final**\n\nIdeal para fluxos naturais e conversacionais.\n\n---\n\n## Retorno\n\n```ts\nconst response = await client.response(...);\n\nresponse.output_text;\n```\n\nVocê também pode acessar o objeto completo (`Output`) se precisar de mais controle.\n\n---\n\n## Requisitos\n\n* Node.js >= 18\n* TypeScript recomendado\n\n---\n\n## Licença\n\nMIT\n","readmeFilename":"README.md"}