v1.2 — Powered by Google Gemini

The jQuery of
AI Agents

Drop console.agent(...) anywhere in your code to execute agentic workflows — as easy as console.log()

terminal
$
+ @console-agent/agent@1.0.0
$
[AGENT] 🛡️ Security audit Complete
[AGENT] ├─ SQL injection detected in user input
[AGENT] ├─ Tool: google_search
[AGENT] ├─ fix: Use parameterized queries
[AGENT] └─ confidence: 0.94 | 247ms | 156 tokens | model: gemini-2.5-flash-lite
───── verbose: true ↑ shows full trace  │  default ↓ shows just the answer ─────
SQL injection detected in user input
fix: Use parameterized queries
severity: critical
0 Line to install
0 Config required
0 AI Personas
0 Built-in Tools

See the Difference

From guesswork to answers. One line changes everything.

❌ Before — console.log hell
your-app.js
console.log("error here:", err);
console.log("data:", JSON.stringify(data));
console.log("hmm", typeof result);
console.log("WHY IS THIS NULL???");
console.log("trying fix #47...");
console.log(data?.users?.map);
// 45 minutes later...
console.log("FOUND IT maybe?");
⏱️ 45 min of guesswork. No confidence.
❌ Before — print() debugging hell
your_app.py
print("error here:", err)
print("data:", json.dumps(data))
print("hmm", type(result))
print("WHY IS THIS NONE???")
print("trying fix #47...")
print(getattr(data, 'users', None))
# 45 minutes later...
print("FOUND IT maybe?")
⏱️ 45 min of guesswork. No confidence.
✅ After — console.agent
your-app.js
console.agent.debug("why is this null?", err);
[AGENT] 🐛 Analyzing error...
[AGENT] ├─ Tool: code_execution → Tested fix
[AGENT] └─ ✓ ROOT CAUSE IDENTIFIED
Likely cause: Missing await on async fn
Suggested fix: Add 'await' on line 47
Confidence: 0.92 | 312ms | 189 tokens
⚡ 1 line. 312ms. Root cause + fix.
✅ After — agent()
your_app.py
agent.debug("why is this None?", context=err)
[AGENT] 🐛 Analyzing error...
[AGENT] ├─ Tool: code_execution → Tested fix
[AGENT] └─ ✓ ROOT CAUSE IDENTIFIED
Likely cause: Missing 'await' on async fn
Suggested fix: Add 'await' on line 47
Confidence: 0.92 | 312ms | 189 tokens
⚡ 1 line. 312ms. Root cause + fix.

Why console.agent?

😤

Agents are too complicated

Langchain requires 100+ lines of boilerplate. We need 1 line.

🔧

Wrong abstraction layer

Existing tools are for chat apps, not runtime utilities.

console.agent is the jQuery of agents

Simple API, powerful capabilities. Zero config works.

Quick Start

Get running in under 30 seconds. No config needed.

1

Install

npm install @console-agent/agent
2

Set API Key

export GEMINI_API_KEY="your-key-here"

Free key at aistudio.google.com/apikey

3

Use it

import '@console-agent/agent';

// Fire-and-forget — never blocks your app
console.agent("analyze this error", error);

// Blocking — await for structured results
const result = await console.agent("validate email", email);

// Persona shortcuts
console.agent.security("check for SQL injection", input);
console.agent.debug("why is this slow?", { duration, query });
console.agent.architect("review API design", endpoint);

How It Works

📝Parse prompt + context
🎭Auto-detect persona
🔒Anonymize secrets
💰Check budget
🤖Gemini ToolLoopAgent
📊Structured AgentResult

API Reference

console.agent(prompt, context?, options?)

The main API. Call it like console.log().

// Simple — fire-and-forget
console.agent("explain this error", error);

// Await structured results
const result = await console.agent("analyze", data, {
  persona: 'security',
  model: 'gemini-3-flash-preview',
  thinking: { level: 'high', includeThoughts: true },
});

console.log(result.success);    // boolean
console.log(result.summary);    // "SQL injection detected..."
console.log(result.confidence); // 0.94
console.log(result.data);       // { vulnerability: "...", fix: "..." }

Return Type: AgentResult

interface AgentResult {
  success: boolean;           // Overall task success
  summary: string;            // Human-readable conclusion
  reasoning?: string;         // Agent's thought process
  data: Record<string, any>;  // Structured findings
  actions: string[];          // Tools used / steps taken
  confidence: number;         // 0-1 confidence score
  metadata: {
    model: string;
    tokensUsed: number;
    latencyMs: number;
    toolCalls: ToolCall[];
    cached: boolean;
  };
}

AI Personas

Auto-detected from your prompt keywords, or set explicitly.

🛡️

Security

OWASP security expert

Detects: injection, xss, vulnerability, csrf, exploit

console.agent.security("audit this query", sql);
🐛

Debugger

Senior debugging expert

Detects: slow, error, optimize, crash, memory leak

console.agent.debug("why is this slow?", metrics);
🏗️

Architect

Principal engineer

Detects: design, architecture, schema, scalability

console.agent.architect("review API", endpoint);
🔍

General

Full-stack senior engineer

Default fallback — handles everything else

console.agent("validate this data", records);

Built-in Tools

Opt-in tools that give your agent real-world capabilities. Only activated when you explicitly pass tools: [...].

🔍

Google Search

Real-time web grounding

Search the web for up-to-date information, facts, CVEs, docs

const result = await console.agent(
  "What is the current population of Tokyo?",
  null,
  { tools: ['google_search'] }
);
💻

Code Execution

Python sandbox (Gemini-hosted)

Run calculations, data processing, algorithm verification

const result = await console.agent(
  "Calculate the 20th Fibonacci number",
  null,
  { tools: ['code_execution'] }
);
// result.data.result → 6765
🌐

URL Context

Fetch & analyze web pages

Read documentation, analyze APIs, extract page content

const result = await console.agent(
  "Summarize this page",
  null,
  { tools: ['url_context'] }
);

Combining Multiple Tools

Tools can be combined — the agent decides which to use based on the prompt.

// Search + calculate in one call
const result = await console.agent(
  "Search for the current world population, then calculate 1% of it",
  null,
  { tools: ['google_search', 'code_execution'] }
);

// The agent will:
// 1. Use google_search to find current population
// 2. Use code_execution to calculate 1%
// 3. Return combined structured result

Configuration

Zero config works. Customize when you need to.

Full Config

import { init } from '@console-agent/agent';
import { z } from 'zod';

init({
  apiKey: process.env.GEMINI_API_KEY,
  model: 'gemini-2.5-flash-lite',
  persona: 'general',
  mode: 'fire-and-forget',
  timeout: 10000,

  budget: {
    maxCallsPerDay: 100,
    maxTokensPerCall: 8000,
    costCapDaily: 1.00,  // USD
  },

  anonymize: true,   // Auto-strip secrets/PII
  localOnly: false,  // Disable cloud tools
  dryRun: false,     // Log without calling API
  logLevel: 'info',
});

// ── Structured Output ────────────────────────

// Option A: Zod schema → typed, validated
const result = await console.agent(
  "analyze sentiment", review,
  {
    schema: z.object({
      sentiment: z.enum(["positive","negative","neutral"]),
      score: z.number(),
      keywords: z.array(z.string()),
    }),
  }
);
result.data.sentiment; // "positive" ✅ typed

// Option B: Plain JSON Schema (no Zod needed)
const info = await console.agent(
  "extract info", text,
  {
    responseFormat: {
      type: 'json_object',
      schema: {
        type: 'object',
        properties: {
          name: { type: 'string' },
          age:  { type: 'number' },
        },
        required: ['name', 'age'],
      },
    },
  }
);
info.data.name; // "John Doe" ✅

🔒 Privacy & Anonymization

Auto-strips API keys, emails, IPs, AWS keys, private keys, and connection strings before sending to AI.

💰 Budget Controls

Hard daily limits on calls (100/day), tokens (8K/call), and cost ($1.00/day). Prevents cost explosion.

⏱️ Rate Limiting

Token bucket algorithm spreads calls evenly across 24 hours. Graceful degradation when limits hit.

🧠 Thinking Mode

Enable extended reasoning with thinking: { level: 'high' } for complex architecture and debugging tasks.

🛠️ Built-in Tools

Code execution (Python sandbox), Google Search (real-time grounding), and file analysis (PDF, images, video).

📊 Structured Output

Every call returns typed AgentResult. Pass a Zod schema or responseFormat (JSON Schema) for custom-shaped output.

Models

Model Best For Speed Cost Default
gemini-2.5-flash-lite General purpose, fast ~200ms Very low ✅ Default
gemini-3-flash-preview Complex reasoning, thinking ~400ms Low

Use Cases

🛡️

Security Auditing

console.agent.security("check for SQL injection", userInput)
🐛

Debugging

console.agent.debug("why is this slow?", { duration, query })
📊

Data Validation

await console.agent("validate batch meets schema", records)
🏗️

Architecture Review

console.agent.architect("review API design", { endpoint })
🔢

Math & Reasoning

await console.agent("calculate optimal batch size", metrics)
🔍

Research

console.agent("research CVEs for lodash@4.17.20")