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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@crewdle/ai-firebase-service

v1.0.2

Published

AI Firebase Service wrapper for Crewdle applications with workflow and file processing capabilities

Readme

@crewdle/ai-firebase-service

A TypeScript AI Firebase service wrapper that provides workflow execution and file processing capabilities for Crewdle applications. Built on top of @crewdle/firebase-service.

Features

  • 🤖 AI Workflows: Execute AI workflows with message history and file attachments
  • 📦 File Processing: Handle file uploads with base64 encoding and caching
  • 🔄 Streaming Support: Stream AI responses in real-time
  • 💾 Image Caching: Automatic caching of fetched images for performance
  • 🎯 TypeScript: Full type safety and IntelliSense support
  • 🔧 Flexible: Works with any Firebase project configuration
  • 📱 Angular Integration: Injectable service with module support

Installation

npm install @crewdle/ai-firebase-service @crewdle/firebase-service

Note: Firebase is a peer dependency, so you need to install it separately:

npm install firebase

Quick Start

Angular Usage (Recommended)

1. Install the package:

npm install @crewdle/ai-firebase-service @crewdle/firebase-service firebase

2. Configure in your app module:

import { NgModule } from '@angular/core';
import { AiFirebaseServiceModule } from '@crewdle/ai-firebase-service';
import { environment } from '../environments/environment';

@NgModule({
  imports: [
    AiFirebaseServiceModule.forRoot({
      firebaseConfig: environment.firebaseConfig,
      functionsRegion: 'us-central1' // optional
    })
  ]
})
export class AppModule { }

Alternative: Using providers directly (for standalone apps):

import { bootstrapApplication } from '@angular/platform-browser';
import { AiFirebaseService, AI_FIREBASE_SERVICE_CONFIG } from '@crewdle/ai-firebase-service';
import { environment } from './environments/environment';

bootstrapApplication(AppComponent, {
  providers: [
    {
      provide: AI_FIREBASE_SERVICE_CONFIG,
      useValue: {
        firebaseConfig: environment.firebaseConfig,
        functionsRegion: 'us-central1'
      }
    },
    AiFirebaseService
  ]
});

3. Inject and use in your components/services:

import { Component, inject } from '@angular/core';
import { AiFirebaseService, WorkflowMessage } from '@crewdle/ai-firebase-service';

@Component({
  selector: 'app-example',
  template: '...'
})
export class ExampleComponent {
  private readonly aiService = inject(AiFirebaseService);

  async generateContent() {
    const messages: WorkflowMessage[] = [
      { role: 'user', content: 'Hello, can you help me?' }
    ];
    
    const response = await this.aiService.generateContent('workflow-id', messages);
    console.log(response);
  }
}

Non-Angular Usage

import { AiFirebaseService } from '@crewdle/ai-firebase-service';

const aiService = AiFirebaseService.create({
  firebaseConfig: {
    apiKey: "your-api-key",
    authDomain: "your-project.firebaseapp.com",
    projectId: "your-project-id",
    // ... other config
  },
  functionsRegion: "us-central1" // optional, defaults to us-central1
});

API Reference

Workflow Execution

// Generate content using a workflow
const messages: WorkflowMessage[] = [
  { role: 'user', content: 'Analyze this data' }
];

const response = await aiService.generateContent('workflow-id', messages);
console.log('Generated content:', response);

// Generate content with file attachments
const files = [new File(['content'], 'data.txt', { type: 'text/plain' })];
const responseWithFiles = await aiService.generateContent('workflow-id', messages, files);

Streaming Responses

// Stream AI responses in real-time
const messages: WorkflowMessage[] = [
  { role: 'user', content: 'Write a story about AI' }
];

for await (const chunk of aiService.streamContent('workflow-id', messages)) {
  console.log('Chunk:', chunk);
  // Update UI with streaming content
}

Image Processing

// Fetch and cache images from URLs
const imageFile = await aiService.fetchUrl('https://example.com/image.jpg');
console.log('Image file:', imageFile.name, imageFile.size);

// Use fetched image in workflow
const messages: WorkflowMessage[] = [
  { role: 'user', content: 'Describe this image' }
];
const description = await aiService.generateContent('vision-workflow', messages, [imageFile]);

Cache Management

// Check cached images count
const cacheCount = aiService.getCachedImageCount();
console.log('Cached images:', cacheCount);

// Clear image cache
aiService.clearImageCache();

Access Underlying Services

// Get underlying Firebase service if needed
const firebaseService = aiService.getFirebaseService();
const firestore = firebaseService.getFirestore();

Advanced Usage

Custom File Processing

// Process multiple files with different types
const files = [
  new File(['{"data": "value"}'], 'data.json', { type: 'application/json' }),
  new File(['Hello world'], 'text.txt', { type: 'text/plain' })
];

const response = await aiService.generateContent('data-analysis-workflow', [
  { role: 'user', content: 'Analyze these files' }
], files);

Error Handling

try {
  const response = await aiService.generateContent('workflow-id', messages);
} catch (error) {
  console.error('Failed to generate content:', error);
}

Streaming with Error Handling

try {
  for await (const chunk of aiService.streamContent('workflow-id', messages)) {
    // Process chunk
    console.log(chunk);
  }
} catch (error) {
  console.error('Streaming failed:', error);
}

TypeScript Support

The package includes full TypeScript definitions:

import { 
  AiFirebaseService, 
  WorkflowMessage,
  WorkflowResponse,
  WorkflowFile,
  StreamChunk,
  FetchUrlResponse,
  FirebaseServiceConfig
} from '@crewdle/ai-firebase-service';

Requirements

  • Node.js >= 16
  • TypeScript >= 4.7
  • Angular >= 15 (for Angular usage)
  • @crewdle/firebase-service >= 1.0.0
  • firebase >= 9.0.0

License

MIT © Crewdle