
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@agentai/agentai
Advanced tools
A modern JavaScript library for interacting with the Agent.ai Actions API.
# Using npm
npm install @agentai/agentai
# Using yarn
yarn add @agentai/agentai
# Using pnpm
pnpm add @agentai/agentai
Before you can start using the library, you'll need to sign up for an account at Agent.ai and obtain a Bearer token from https://agent.ai/user/settings#credits.
import AgentAi from '@agentai/agentai';
// Using CommonJS
#const { AgentAiClient } = require('@agentai/agentai');
// Create a client instance with your bearer token
const client = new AgentAiClient('YOUR_BEARER_TOKEN_HERE');
// Example: Grab web text
async function fetchWebText() {
try {
const webTextResponse = await client.action(
'grabWebText',
{ url: 'https://agent.ai' }
);
if (webTextResponse.status === 200) {
console.log("Web Text Response Status:", webTextResponse.status);
console.log("First 100 chars of Response:", webTextResponse.results.substring(0, 100) + "...");
} else {
console.error(`Error: Status Code: ${webTextResponse.status}, Message: ${webTextResponse.error}`);
}
} catch (error) {
console.error('An error occurred:', error);
}
}
// Example: Chat with an LLM
async function chatWithLlm() {
try {
const chatResponse = await client.chat(
"What is an AI agent?",
{ model: "gpt4o" }
);
if (chatResponse.status === 200) {
console.log("Chat Response:", chatResponse.results);
} else {
console.error(`Error: ${chatResponse.error}`);
}
} catch (error) {
console.error('An error occurred:', error);
}
}
// Example: Get Google News
async function getGoogleNews() {
try {
const googleNewsResponse = await client.action(
'getGoogleNews',
{
query: "AI advancements",
date_range: "7d",
location: "Boston"
}
);
if (googleNewsResponse.status === 200) {
console.log("Google News Location:", googleNewsResponse.metadata.search_information.location_used);
console.log("Number of articles:", googleNewsResponse.results.length);
} else {
console.error(`Error: ${googleNewsResponse.error}`);
}
} catch (error) {
console.error('An error occurred:', error);
}
}
// Run the examples
fetchWebText();
chatWithLlm();
getGoogleNews();
// Method 1: Using API key only
const client = new AgentAiClient('YOUR_API_KEY');
// Method 2: Using API key with config object
const client = new AgentAiClient('YOUR_API_KEY', {
timeout: 60000, // Optional: custom timeout in ms
baseUrl: 'https://custom-url.com', // Optional: custom base URL
headers: {
'X-Custom-Header': 'value' // Optional: additional headers
}
});
client.action(actionId, params)
Execute an AI action by its ID.
actionId
(string): The ID of the action to execute (e.g., 'grabWebText')params
(object): Parameters for the actionclient.chat(prompt, options)
Use the invokeLlm action to generate text based on a prompt.
prompt
(string): The text prompt for the LLMoptions
(object, optional):
model
(string, default: 'gpt4o'): LLM model to useAll methods return a Promise that resolves to an object with the following structure:
{
status: 200, // HTTP status code
error: null, // Error message (if any)
results: {...}, // API response data (if successful)
metadata: {...} // Metadata from the API response (if available)
}
All methods return Promises that may reject with errors. It's recommended to use try/catch blocks when calling these methods:
try {
const response = await client.action('grabWebText', { url: 'https://agent.ai' });
if (response.status !== 200) {
console.error(`API Error: ${response.error}`);
}
} catch (error) {
console.error('Network or client error:', error);
}
Contributions are welcome! Please feel free to submit pull requests or open issues for feature requests or bug reports.
This project is licensed under the MIT License.
FAQs
A JavaScript client for the Agent.ai API
The npm package @agentai/agentai receives a total of 3 weekly downloads. As such, @agentai/agentai popularity was classified as not popular.
We found that @agentai/agentai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.