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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sctlib/bagent

v0.0.3

Published

AI Native Browser Tab - Autonomous AI agent for browser-based content generation

Readme

🤖 AI Browser Tab Agent

Create AI-native websites with autonomous content generation

AI Browser Tab Agent is a revolutionary web component that transforms any webpage into an AI-powered content creation platform. Generate, edit, and publish AI-created content seamlessly within your browser.

npm version TypeScript License: MIT

✨ Features

🎯 Three Operating Modes

  • Full Mode: Complete development interface with conversation, activity log, and all controls
  • Edit Mode: Focused editing interface with highlighted edit capabilities
  • Preview Mode: Clean presentation mode for AI-generated websites

📦 Export/Import System

  • Export complete agent state as JSON (conversations, content, configuration)
  • Import state from JSON files or URLs for seamless content restoration
  • Share and collaborate on AI-generated content effortlessly

🏗️ Static Site Generation

  • npm run build:content command transforms exported states into deployable websites
  • Custom template support with variable substitution
  • Automatic library bundling for standalone operation

🎨 Content Generation

  • HTML Pages: Static content, documentation, landing pages
  • JavaScript Widgets: Interactive components, calculators, live data displays
  • Dashboards: Complex multi-widget layouts with real-time data

🚀 Quick Start

Installation

Option 1: NPM Package

npm install @sctlib/bagent

Option 2: CDN (No Build Required)

<!DOCTYPE html>
<html>
<head>
    <title>My AI-Powered Website</title>
</head>
<body>
    <ai-browser-tab mode="full"></ai-browser-tab>
    
    <!-- Load from CDN -->
    <script src="https://cdn.jsdelivr.net/npm/@sctlib/bagent@latest/dist-lib/bagent.umd.js"></script>
    <script>
        // Component is automatically available as <ai-browser-tab>
        // Or create programmatically:
        const agent = AIBrowserTab.default({
            mode: 'preview',
            editEnabled: true
        });
        // document.body.appendChild(agent);
    </script>
</body>
</html>

Basic Usage

<!DOCTYPE html>
<html>
<head>
    <title>My AI-Powered Website</title>
</head>
<body>
    <!-- Full development mode -->
    <ai-browser-tab mode="full"></ai-browser-tab>
    
    <script type="module">
        import AIBrowserTab from '@sctlib/bagent';
        // Component auto-initializes from attributes
    </script>
</body>
</html>

Preview Mode for Published Sites

<!-- Clean presentation mode with optional editing -->
<ai-browser-tab 
    mode="preview" 
    import-content="./my-content.json"
    edit="true"
    show-conversation="false">
</ai-browser-tab>

📖 Operating Modes

Full Mode

Perfect for content creation and development:

<ai-browser-tab mode="full"></ai-browser-tab>
  • Complete conversation interface
  • Activity log and debugging tools
  • Export/import functionality
  • All editing controls

Edit Mode

Focused interface for content modification:

<ai-browser-tab mode="edit" show-conversation="true"></ai-browser-tab>
  • Streamlined editing interface
  • Visual edit indicators
  • Conversation context
  • Reduced UI complexity

Preview Mode

Clean presentation for end users:

<ai-browser-tab 
    mode="preview" 
    import-content="./content.json"
    edit="true"
    show-conversation="false">
</ai-browser-tab>
  • Minimal UI footprint
  • Generated content prominently displayed
  • Optional conversation reveal
  • Can upgrade to edit mode

🛠️ Development Workflow

1. Create Content

Start with full mode to generate AI content:

npm run dev
# Navigate to http://localhost:5173
# Use the interface to create content with AI

2. Export State

Export your agent's complete state including conversations and generated content:

const agent = document.querySelector('ai-browser-tab');
agent.downloadState(); // Downloads JSON file

3. Build Static Site

Transform exported states into deployable websites:

# Place exported JSON files in ./content/
cp ~/Downloads/my-ai-content.json content/

# Generate static websites
npm run build:content

# Deploy the generated sites
rsync -av dist-content/my-ai-content/ user@server:/var/www/html/

📁 Project Structure

my-project/
├── content/                    # Exported AI states
│   ├── dashboard.json         # Weather dashboard state
│   └── portfolio.json         # Portfolio site state
├── dist-content/              # Generated static sites
│   ├── dashboard/
│   │   ├── index.html        # Preview page with AI agent
│   │   ├── state.json        # Original state
│   │   └── *.js              # Library files
│   └── portfolio/
├── src/templates/             # Custom templates (optional)
│   └── index.html
└── package.json

🎨 Custom Templates

Override default templates in src/templates/:

<!-- src/templates/index.html -->
<!DOCTYPE html>
<html>
<head>
    <title>{{TITLE}}</title>
    <meta name="description" content="{{DESCRIPTION}}">
</head>
<body>
    <header>
        <h1>🤖 {{TITLE}}</h1>
        <p>Generated: {{CREATED_DATE}} | Items: {{CONTENT_COUNT}}</p>
    </header>
    
    <main>
        <ai-browser-tab 
            mode="preview" 
            import-content="{{STATE_FILE}}"
            edit="true">
        </ai-browser-tab>
    </main>
</body>
</html>

⚙️ Configuration

HTML Attributes

| Attribute | Values | Default | Description | |-----------|--------|---------|-------------| | mode | full, edit, preview | full | Operating mode | | edit | true, false | true | Enable content editing | | show-conversation | true, false | true | Show conversation panel | | import-content | URL/path | - | Import state from file | | ollama-url | URL | http://localhost:11434/api/chat | Ollama API endpoint | | model | string | qwen3:0.6b | Default AI model |

JavaScript API

import AIBrowserTab from 'bagent';

// Create with configuration
const agent = AIBrowserTab({
  mode: 'preview',
  editEnabled: true,
  showConversation: false,
  ollamaUrl: 'https://my-ollama-server.com/api/chat'
});

document.body.appendChild(agent);

// Export/import state
const state = agent.exportState();
await agent.importState(state);

🏗️ Build Commands

# Development
npm run dev              # Start development server
npm run dev:lib          # Watch library builds
npm run dev:website      # Start website dev server

# Production
npm run build            # Build both library and website
npm run build-lib        # Build library only
npm run build-website    # Build website only
npm run build:content    # Generate static sites from content/

# Quality
npm run check            # TypeScript type checking
npm run test             # Run tests

🌐 Deployment

GitLab Pages

Automatic deployment via GitLab CI/CD:

# .gitlab-ci.yml (already configured)
pages:
  script:
    - npm install
    - npm run build-website
    - mv dist-website public
  artifacts:
    paths:
      - public

Static Hosting

Deploy generated content sites:

# Build content sites
npm run build:content

# Deploy to any static host
netlify deploy --dir=dist-content/my-site
# or
vercel --cwd dist-content/my-site
# or
aws s3 sync dist-content/my-site s3://my-bucket

📚 Use Cases

AI-Generated Documentation

Create interactive documentation with live examples:

<ai-browser-tab 
    mode="preview" 
    import-content="./docs-state.json"
    edit="false">
</ai-browser-tab>

Interactive Dashboards

Build live data dashboards with AI assistance:

<ai-browser-tab 
    mode="edit" 
    show-conversation="true">
</ai-browser-tab>

Quick CDN Integration

No-build setup for rapid prototyping:

<!DOCTYPE html>
<html>
<head>
    <title>Quick AI Website</title>
</head>
<body>
    <h1>My AI-Generated Content</h1>
    <ai-browser-tab mode="preview" edit="true"></ai-browser-tab>
    
    <script src="https://cdn.jsdelivr.net/npm/@sctlib/bagent@latest/dist-lib/bagent.umd.js"></script>
</body>
</html>

Portfolio Websites

Generate and customize portfolio sites:

<ai-browser-tab 
    mode="preview" 
    import-content="./portfolio.json"
    edit="true"
    show-conversation="false">
</ai-browser-tab>

Collaborative Content Creation

Share editable AI-generated content:

<ai-browser-tab 
    mode="edit" 
    import-content="./shared-content.json">
</ai-browser-tab>

🔧 Requirements

  • Node.js 18+ for development
  • Modern browser with ES modules support
  • Ollama running locally or remote API for AI functionality

📖 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Start building AI-native websites today!

npm install @sctlib/bagent

Visit gitlab.com/sctlib/bagent for interactive examples and full documentation.