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

@twomilia/angular

v0.1.0

Published

Thin Angular wrapper for the Twomilia web agent — injectable service + provideTwomilia() helper. The agent renders its own shadow-DOM chat widget; this just loads it.

Readme

@twomilia/angular

Thin Angular wrapper for the Twomilia web agent.

The agent ships its own shadow-DOM chat widget overlay — this package does not render any UI. It loads twomilia.js from the CDN (once, like Stripe.js) and mounts the agent with your config. It's SSR-safe (Angular Universal) and idempotent (it never double-mounts the widget).

Install

npm install @twomilia/angular @twomilia/web

@angular/core and @angular/common are peer dependencies (Angular 16+).

Usage

Option A — provideTwomilia in app.config.ts (recommended)

Auto-inits the agent on bootstrap via APP_INITIALIZER. Best place for it: the config stays in one spot and the widget is available everywhere.

// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideTwomilia } from '@twomilia/angular';

export const appConfig: ApplicationConfig = {
  providers: [
    provideTwomilia({
      // analyticsKey is the ONLY required field — get it from
      // Dashboard → Setup & API Keys. Proxy/server default to Twomilia Cloud.
      analyticsKey: 'twomilia_pub_xxx',

      // Ground answers in your dashboard knowledge base.
      knowledgeBase: true,

      // Named actions the agent can call inside your app.
      customTools: {
        applyCoupon: {
          name: 'applyCoupon',
          description: 'Apply a discount coupon to the current cart.',
          parameters: {
            code: { type: 'string', description: 'The coupon code', required: true },
          },
          execute: async ({ code }) => {
            const res = await fetch('/api/cart/coupon', {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify({ code }),
            });
            return res.ok
              ? { success: true, message: `Coupon ${code} applied.` }
              : { success: false, message: 'That coupon is not valid.' };
          },
        },
      },
    }),
  ],
};

For a non-standalone app, call it inside a module instead:

// app.module.ts
import { NgModule } from '@angular/core';
import { provideTwomilia } from '@twomilia/angular';

@NgModule({
  providers: [
    provideTwomilia({ analyticsKey: 'twomilia_pub_xxx', knowledgeBase: true }),
  ],
})
export class AppModule {}

Option B — inject TwomiliaService in a component

Use this when you want to init the agent at a specific moment (e.g. only after login, or once user details are known) instead of on bootstrap.

import { Component, OnInit, inject } from '@angular/core';
import { TwomiliaService } from '@twomilia/angular';

@Component({
  selector: 'app-shell',
  standalone: true,
  template: '<router-outlet />',
})
export class ShellComponent implements OnInit {
  private readonly twomilia = inject(TwomiliaService);

  ngOnInit() {
    // init() is a no-op on the server, so calling it here is SSR-safe.
    this.twomilia.init({
      analyticsKey: 'twomilia_pub_xxx',
      knowledgeBase: true,
      userContext: { userId: 'u_123', name: 'Ada Lovelace' },
      customTools: {
        applyCoupon: {
          name: 'applyCoupon',
          description: 'Apply a discount coupon to the current cart.',
          parameters: {
            code: { type: 'string', description: 'The coupon code', required: true },
          },
          execute: async ({ code }) =>
            ({ success: true, message: `Coupon ${code} applied.` }),
        },
      },
    });
  }
}

Don't use both options for the same agent — provideTwomilia already inits on bootstrap, and the loader is idempotent, so a second init is ignored anyway.

Config

analyticsKey is the only required field; everything else is optional. Common options: knowledgeBase, customTools, userContext, interactionMode ('copilot' | 'autopilot'), enableVoice, accentColor, headerTitle, defaultOpen. proxyUrl / serverUrl default to Twomilia Cloud. See the TwomiliaConfig type (re-exported from this package) for the full list.

API

  • provideTwomilia(config)EnvironmentProviders. Add to your providers; inits the agent on bootstrap via APP_INITIALIZER.
  • TwomiliaService → injectable; init(config) loads and mounts the agent. No-op on the server.
  • Re-exported types: TwomiliaConfig, TwomiliaTool.

SSR (Angular Universal)

Safe out of the box. TwomiliaService.init guards with isPlatformBrowser and the underlying loader no-ops without window, so the agent only mounts in the browser. Nothing renders or runs during server-side rendering.

License

MIT