{"_id":"@agentai/agentai","_rev":"4-b48edf8673889b55cf623751c669f714","name":"@agentai/agentai","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@agentai/agentai","version":"0.1.0","keywords":["agent.ai","ai agents","api","client","ai","llm"],"author":{"name":"Andrei Oprisan","email":"andrei@agent.ai"},"license":"MIT","_id":"@agentai/agentai@0.1.0","maintainers":[{"name":"andreioprisan","email":"andrei@oprisan.com"}],"homepage":"https://github.com/OnStartups/js_sdk","bugs":{"url":"https://github.com/OnStartups/js_sdk/issues"},"dist":{"shasum":"5bac232a1b8c7559e79bb2b072a29e1a72606e51","tarball":"https://registry.npmjs.org/@agentai/agentai/-/agentai-0.1.0.tgz","fileCount":5,"integrity":"sha512-1BzCYZCh6oVy2zuMAg+YCG3fmPPujlYtkQLwZBtowjVBJ+zErW1WzXuOHcio2/6U98G7btVD1zTPlRBrqvQZ6g==","signatures":[{"sig":"MEUCIQCSQqD8Yk3KcZWXKjbv3d0CoXvoEG7Gcc/qUJM5wz21hQIgAbJ5asACXSmN/K364X6vXAFHGCSITP+iFbhxMV/ANo8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15572},"main":"lib/index.js","engines":{"node":">=14.0.0"},"gitHead":"206194dddb6e5cafac580f641f7c63b71e9e46e7","scripts":{"lint":"eslint src","test":"jest","build":"babel src --out-dir lib","prepublishOnly":"npm run build"},"_npmUser":{"name":"andreioprisan","email":"andrei@oprisan.com"},"repository":{"url":"git+https://github.com/OnStartups/js_sdk.git","type":"git"},"_npmVersion":"9.6.7","description":"A JavaScript client for the Agent.ai API","directories":{},"_nodeVersion":"18.17.1","dependencies":{"axios":"^1.6.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.54.0","@babel/cli":"^7.21.0","@babel/core":"^7.21.0","@babel/preset-env":"^7.21.0"},"_npmOperationalInternal":{"tmp":"tmp/agentai_0.1.0_1741369322304_0.33754567991344175","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agentai/agentai","version":"0.1.1","keywords":["agent.ai","ai agents","api","client","ai","llm"],"author":{"name":"Andrei Oprisan","email":"andrei@agent.ai"},"license":"MIT","_id":"@agentai/agentai@0.1.1","maintainers":[{"name":"andreioprisan","email":"andrei@oprisan.com"}],"homepage":"https://github.com/OnStartups/js_sdk","bugs":{"url":"https://github.com/OnStartups/js_sdk/issues"},"dist":{"shasum":"62715f3d578e7b08d437930926ba81a7015eab7e","tarball":"https://registry.npmjs.org/@agentai/agentai/-/agentai-0.1.1.tgz","fileCount":5,"integrity":"sha512-Y1cn6JayotDR1S3k9RVozErnIgD5E7n3uWkr9APyjJUbYdF7f2aAEwXs8FzHB4m+XD5yrOno5ol5CSHooqbNDw==","signatures":[{"sig":"MEYCIQCMUe02Q1vn2ZA/QFNtD3BUMNoiNmrH9114hGoALrtPAgIhAI6cIJ2+qE+15Q9PQJB3Uq7KtC3HpgZ9JwErf1PugSDY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15590},"main":"lib/index.js","engines":{"node":">=14.0.0"},"gitHead":"206194dddb6e5cafac580f641f7c63b71e9e46e7","scripts":{"lint":"eslint src","test":"jest","build":"babel src --out-dir lib","prepublishOnly":"npm run build"},"_npmUser":{"name":"andreioprisan","email":"andrei@oprisan.com"},"repository":{"url":"git+https://github.com/OnStartups/js_sdk.git","type":"git"},"_npmVersion":"9.6.7","description":"A JavaScript client for the Agent.ai API","directories":{},"_nodeVersion":"18.17.1","dependencies":{"axios":"^1.6.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.54.0","@babel/cli":"^7.21.0","@babel/core":"^7.21.0","@babel/preset-env":"^7.21.0"},"_npmOperationalInternal":{"tmp":"tmp/agentai_0.1.1_1741369437557_0.21591094986045323","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agentai/agentai","version":"0.2.0","description":"A JavaScript client for the Agent.ai API","main":"lib/index.js","scripts":{"build":"babel src --out-dir lib","lint":"eslint src","test":"jest","prepublishOnly":"npm run build"},"keywords":["agent.ai","ai agents","api","client","ai","llm"],"author":{"name":"Andrei Oprisan","email":"andrei@agent.ai"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/OnStartups/js_sdk.git"},"homepage":"https://github.com/OnStartups/js_sdk","dependencies":{"axios":"^1.6.2"},"devDependencies":{"@babel/cli":"^7.21.0","@babel/core":"^7.21.0","@babel/preset-env":"^7.21.0","eslint":"^8.54.0","jest":"^29.7.0"},"engines":{"node":">=14.0.0"},"gitHead":"206194dddb6e5cafac580f641f7c63b71e9e46e7","bugs":{"url":"https://github.com/OnStartups/js_sdk/issues"},"_id":"@agentai/agentai@0.2.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Sil1OQcjqZ2iLJERvxqf+ocFgM3M2dMIueRVlPVTGd+dv2RG8iTC/FbJrasEv+X4coGh1BtG1WRnW3XoAJizGQ==","shasum":"3e3baa04922832498efed2eba0bc279c83860b51","tarball":"https://registry.npmjs.org/@agentai/agentai/-/agentai-0.2.0.tgz","fileCount":6,"unpackedSize":39653,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDY09pNgljYoKeieV1jrZEi1Us9gkkdUxC72gCGGvwFdAiEA/7udZG3ncdXbL5SyIoLUOlWygje9fLCLeJMReX9OyIE="}]},"_npmUser":{"name":"andreioprisan","email":"andrei@oprisan.com"},"directories":{},"maintainers":[{"name":"andreioprisan","email":"andrei@oprisan.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agentai_0.2.0_1765199349506_0.36926146312663155"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-07T17:42:02.302Z","modified":"2025-12-08T13:09:09.847Z","0.1.0":"2025-03-07T17:42:02.499Z","0.1.1":"2025-03-07T17:43:57.778Z","0.2.0":"2025-12-08T13:09:09.657Z"},"bugs":{"url":"https://github.com/OnStartups/js_sdk/issues"},"author":{"name":"Andrei Oprisan","email":"andrei@agent.ai"},"license":"MIT","homepage":"https://github.com/OnStartups/js_sdk","keywords":["agent.ai","ai agents","api","client","ai","llm"],"repository":{"type":"git","url":"git+https://github.com/OnStartups/js_sdk.git"},"description":"A JavaScript client for the Agent.ai API","maintainers":[{"name":"andreioprisan","email":"andrei@oprisan.com"}],"readme":"# Agent.ai JavaScript SDK\n\n[![npm version](https://img.shields.io/npm/v/@agentai/agentai.svg)](https://www.npmjs.com/package/@agentai/agentai)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA modern JavaScript SDK for interacting with the [Agent.ai Actions API](https://docs.agent.ai/api-reference/get-data/web-page-content).\n\n> **For LLMs**: See [`llm.txt`](./llm.txt) for a complete machine-readable specification of this SDK.\n\n## Installation\n\n```bash\n# Using npm\nnpm install @agentai/agentai\n\n# Using yarn\nyarn add @agentai/agentai\n\n# Using pnpm\npnpm add @agentai/agentai\n```\n\n## Quick Start\n\nBefore using the SDK, obtain a Bearer token from [https://agent.ai/user/integrations#api](https://agent.ai/user/integrations#api).\n\n```javascript\nconst { AgentAiClient } = require('@agentai/agentai');\n\n// Initialize the client\nconst client = new AgentAiClient('YOUR_BEARER_TOKEN');\n\n// Chat with an LLM\nconst response = await client.chat('What is an AI agent?');\nconsole.log(response.results);\n```\n\n## Usage Examples\n\n### Chat with LLM\n\n```javascript\nconst { AgentAiClient } = require('@agentai/agentai');\n\nconst client = new AgentAiClient(process.env.AGENT_API_KEY);\n\n// Basic chat\nconst response = await client.chat('Explain quantum computing in simple terms');\n\nif (response.status === 200) {\n  console.log(response.results);\n} else {\n  console.error('Error:', response.error);\n}\n\n// Chat with different models\nconst claudeResponse = await client.chat('Write a haiku about AI', {\n  model: 'claude_sonnet_35'\n});\n```\n\n### Available LLM Models\n\n- `gpt4o` (default)\n- `gpt-4o-mini`\n- `gpt-5`, `gpt-5-mini`, `gpt-5-nano`\n- `o1`, `o1-mini`, `o1-pro`, `o3-mini`\n- `claude_sonnet_35`, `claude_sonnet_4`, `claude_opus_4`\n- `gemini_15_pro`, `gemini_15_flash`, `gemini-2.0-flash-exp`\n- `perplexity`\n- And many more...\n\n### Grab Web Page Content\n\n```javascript\n// Scrape a single page\nconst webContent = await client.grabWebText('https://example.com');\n\nif (webContent.status === 200) {\n  console.log('Content:', webContent.results);\n  console.log('Page title:', webContent.metadata?.title);\n}\n\n// Crawl multiple pages (up to 100)\nconst crawlResult = await client.grabWebText('https://example.com', { \n  mode: 'crawl' \n});\n```\n\n### Get Google News\n\n```javascript\nconst news = await client.getGoogleNews('artificial intelligence', { \n  dateRange: '7d'  // Options: '24h', '7d', '30d'\n});\n\nif (news.status === 200) {\n  const articles = news.results.organic_results || [];\n  \n  articles.forEach(article => {\n    console.log(`${article.title}`);\n    console.log(`  Source: ${article.source}`);\n    console.log(`  Date: ${article.date}`);\n    console.log(`  Link: ${article.link}`);\n  });\n}\n```\n\n### Web Search\n\n```javascript\nconst searchResults = await client.search('best AI frameworks 2024');\n\nif (searchResults.status === 200) {\n  console.log(searchResults.results);\n}\n```\n\n### YouTube Transcript\n\n```javascript\nconst transcript = await client.getYoutubeTranscript(\n  'https://www.youtube.com/watch?v=VIDEO_ID'\n);\n\nif (transcript.status === 200) {\n  console.log(transcript.results);\n}\n```\n\n### LinkedIn Profile\n\n```javascript\nconst profile = await client.getLinkedinProfile(\n  'https://www.linkedin.com/in/username'\n);\n\nif (profile.status === 200) {\n  console.log(profile.results);\n}\n```\n\n### Generate Images\n\n```javascript\nconst image = await client.generateImage('A futuristic city with AI robots');\n\nif (image.status === 200) {\n  console.log(image.results);  // Image URL or data\n}\n```\n\n### Using the Generic Action Method\n\nFor any action not covered by convenience methods:\n\n```javascript\n// Get available actions\nconst actions = client.getAvailableActions();\nconsole.log(actions);\n\n// Call any action directly\nconst result = await client.action('getTwitterUsers', {\n  usernames: ['openai', 'anthropic']\n});\n\n// Store a variable\nawait client.action('storeVariableToDatabase', {\n  key: 'myData',\n  value: { hello: 'world' }\n});\n\n// Retrieve a variable\nconst stored = await client.action('getVariableFromDatabase', {\n  key: 'myData'\n});\n```\n\n## API Reference\n\n### Creating a Client\n\n```javascript\nconst { AgentAiClient } = require('@agentai/agentai');\n\n// Basic initialization\nconst client = new AgentAiClient('YOUR_API_KEY');\n\n// With custom configuration\nconst client = new AgentAiClient('YOUR_API_KEY', {\n  timeout: 60000,           // Custom timeout in ms (default: 30000)\n  baseUrl: 'https://...',   // Custom base URL (optional)\n  headers: {                // Additional headers (optional)\n    'X-Custom-Header': 'value'\n  }\n});\n```\n\n### Convenience Methods\n\n| Method | Description |\n|--------|-------------|\n| `chat(prompt, options)` | Chat with an LLM model |\n| `grabWebText(url, options)` | Extract text from a web page |\n| `getGoogleNews(query, options)` | Get news articles |\n| `search(query, options)` | Web search |\n| `getYoutubeTranscript(videoUrl)` | Get YouTube video transcript |\n| `getLinkedinProfile(linkedinUrl)` | Get LinkedIn profile data |\n| `generateImage(prompt, options)` | Generate an image with AI |\n| `invokeAgent(agentId, input)` | Invoke another Agent.ai agent |\n| `getAvailableActions()` | List all available action IDs |\n\n### Generic Action Method\n\n```javascript\nclient.action(actionId, params)\n```\n\n**Available Action IDs:**\n\n**Data Retrieval:**\n- `grabWebText` - Extract text from web pages\n- `grabWebScreenshot` - Take web page screenshots\n- `getSearchResults` - Google search\n- `getGoogleNews` - News articles\n- `getDomainInformation` - Domain/company info\n- `getYoutubeTranscript` - Video transcripts\n- `getYoutubeChannel` - Channel data\n- `runYoutubeSearch` - Search YouTube\n\n**Social Media:**\n- `getTwitterUsers` - Twitter profile data\n- `getRecentTweets` - Recent tweets\n- `getLinkedinProfile` - LinkedIn profiles\n- `findLinkedinProfile` - Find LinkedIn by name\n- `getLinkedinActivity` - LinkedIn activity\n- `getInstagramProfile` - Instagram profiles\n- `getInstagramFollowers` - Instagram followers\n- `getBlueskyPosts` - Bluesky posts\n- `searchBlueskyPosts` - Search Bluesky\n\n**AI:**\n- `invokeLlm` - Chat with LLM\n- `generateImage` - Generate images\n- `outputAudio` - Text to speech\n\n**Advanced:**\n- `invokeAgent` - Call other agents\n- `restCall` - Make REST API calls\n- `convertFile` - Convert file formats\n- `storeVariableToDatabase` - Store data\n- `getVariableFromDatabase` - Retrieve data\n- `saveToFile` - Save content to file\n\n### Response Structure\n\nAll methods return a Promise that resolves to:\n\n```javascript\n{\n  status: 200,           // HTTP status code\n  error: null,           // Error message (null on success)\n  results: {...},        // API response data\n  metadata: {...}        // Additional metadata (when available)\n}\n```\n\n## Error Handling\n\n```javascript\nconst response = await client.chat('Hello');\n\nif (response.status === 200) {\n  // Success\n  console.log(response.results);\n} else {\n  // API error\n  console.error(`Error ${response.status}: ${response.error}`);\n}\n\n// For network errors, wrap in try/catch\ntry {\n  const response = await client.chat('Hello');\n  // handle response\n} catch (error) {\n  console.error('Network error:', error.message);\n}\n```\n\n## Examples\n\nSee the `examples/` directory for complete working examples:\n\n- **`basic-usage.js`** - Simple examples for common use cases\n- **`advanced-usage.js`** - Advanced patterns like parallel requests and pipelines\n\nRun examples:\n\n```bash\n# Set your API key\nexport AGENT_API_KEY=your_token_here\n\n# Run basic examples\nnode examples/basic-usage.js\n\n# Run advanced examples  \nnode examples/advanced-usage.js\n```\n\n## TypeScript Support\n\nWhile this package is written in JavaScript, it works with TypeScript projects. Type definitions can be added by creating a `.d.ts` file:\n\n```typescript\ndeclare module '@agentai/agentai' {\n  export interface AgentResponse {\n    status: number;\n    error: string | null;\n    results: any;\n    metadata: any;\n  }\n\n  export interface ClientConfig {\n    baseUrl?: string;\n    timeout?: number;\n    headers?: Record<string, string>;\n  }\n\n  export class AgentAiClient {\n    constructor(apiKey: string, config?: ClientConfig);\n    action(actionId: string, params: object): Promise<AgentResponse>;\n    chat(prompt: string, options?: { model?: string }): Promise<AgentResponse>;\n    grabWebText(url: string, options?: { mode?: 'scrape' | 'crawl' }): Promise<AgentResponse>;\n    getGoogleNews(query: string, options?: { dateRange?: '24h' | '7d' | '30d' }): Promise<AgentResponse>;\n    search(query: string, options?: object): Promise<AgentResponse>;\n    getYoutubeTranscript(videoUrl: string, options?: object): Promise<AgentResponse>;\n    getLinkedinProfile(linkedinUrl: string, options?: object): Promise<AgentResponse>;\n    generateImage(prompt: string, options?: object): Promise<AgentResponse>;\n    invokeAgent(agentId: string, input: string, options?: object): Promise<AgentResponse>;\n    getAvailableActions(): string[];\n  }\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests or open issues for feature requests or bug reports.\n\n## License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}