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

@dudko.dev/agent-web-angular

v0.0.5

Published

Angular bindings for @dudko.dev/agent-web, the in-browser LLM agent: injectAgent() - the agent's chat state as Angular signals plus its methods (run, stop, steer, consent, questions), tied to the component's life. Headless, zoneless-friendly, SSR-safe; pl

Readme

@dudko.dev/agent-web-angular

npm downloads license last commit release

agent.dudko.dev · docs · live demo · source

Angular bindings for @dudko.dev/agent-web, the in-browser LLM agent. One function, injectAgent: the agent's chat state as Angular signals, plus its methods - run, stop, steer, consent, questions - tied to your component's life.

It is headless: no component, no markup, no styles. You draw the chat your way. If you want the whole chat ready-made, use <dd-agent-chat> instead.

It is thin. Everything the agent does in a view - building it, folding its events into state, consent and question queues, steering, other tabs, usage - is @dudko.dev/agent-web-ui's createAgentController. This package only makes its snapshot a signal and its life Angular's.

The family

One planning loop: two agents, and the layers that put its chat on a page. Every package has its page at agent.dudko.dev/docs. The live demo and the app are built on them.

| Package | What it is | | --- | --- | | @dudko.dev/agent | The agent in Node: stdio and HTTP MCP servers, OAuth 2.1, a REPL CLI, persistence and resume | | @dudko.dev/agent-web | The same agent in a browser tab, with no backend: your own key or a local WebGPU model | | @dudko.dev/agent-web-ui | Its chat with no framework: the state, a controller, labels in 33 languages, Markdown | | @dudko.dev/agent-web-react | React: the useAgent hook and a ready chat panel | | @dudko.dev/agent-web-element | <dd-agent-chat>: the whole chat as a web component, for a page on any stack | | @dudko.dev/agent-web-vue | Vue 3: the useAgent() composable | | @dudko.dev/agent-web-angular (this package) | Angular: injectAgent(), the chat state as signals | | @dudko.dev/agent-web-svelte | Svelte 4 and 5: createAgent(), the chat state as a store |

Install

npm install @dudko.dev/agent-web-angular @dudko.dev/agent-web
# and the model providers you use, e.g.
npm install @ai-sdk/google
  • @angular/core 17 or newer (signals) and @dudko.dev/agent-web are peers: your app's own copies.
  • @dudko.dev/agent-web-ui comes with it (a regular dependency, imported, not bundled).
  • Plain ESM / CJS. The package is a few plain functions over @angular/core (inject, signal, computed, effect, DestroyRef). No decorator, no @Injectable, no component - so there is nothing for the Angular compiler to do. It was not built with ng-packagr and needs no partial compilation or linker. Any Angular build (the CLI's esbuild or webpack builder, Vite, Analog) imports it like any other ESM package.
  • Zone-less friendly. The state is signals only. With provideZonelessChangeDetection() the view updates when a signal changes; with zone.js it updates as usual.

Usage

import { Component } from '@angular/core'
import { VaultCredentialStore } from '@dudko.dev/agent-web'
import { injectAgent } from '@dudko.dev/agent-web-angular'

const credentials = new VaultCredentialStore() // keys encrypted at rest, in IndexedDB
// once, e.g. from a settings form: await credentials.setApiKey('google', key)

@Component({
  selector: 'app-assistant',
  standalone: true,
  template: `
    @for (m of agent.messages(); track m.id) {
      <p [class]="m.role">{{ m.content }}@if (m.pending) { … }</p>
    }

    @for (a of agent.pendingApprovals(); track a.id) {
      <div role="alertdialog">
        Run <code>{{ a.name }}</code>?
        <button (click)="agent.approve(a.id)">Allow</button>
        <button (click)="agent.approve(a.id, { remember: true })">Always</button>
        <button (click)="agent.deny(a.id)">Deny</button>
      </div>
    }

    @for (q of agent.pendingQuestions(); track q.id) {
      <fieldset>
        <legend>{{ q.question }}</legend>
        @for (o of q.options; track o.label) {
          <button (click)="agent.answerQuestion(q.id, { choice: [o.label] })">{{ o.label }}</button>
        }
        <button (click)="agent.answerQuestion(q.id, { declined: true })">Skip</button>
      </fieldset>
    }

    <form (submit)="send($event, box)">
      <input #box [disabled]="!agent.isReady() && !agent.isRunning()" />
      @if (agent.isRunning()) {
        <button type="button" (click)="agent.stop()">Stop</button>
      } @else {
        <button [disabled]="!agent.isReady()">Send</button>
      }
    </form>
    <small>{{ agent.status() }} · {{ agent.state().totalUsage.totalTokens }} tokens</small>
  `,
})
export class AssistantComponent {
  readonly agent = injectAgent({
    model: { providerType: 'google', model: 'gemini-3.5-flash', credentialRef: 'google' },
    credentials,
    toolApproval: { mode: 'ask-writes' }, // a tool that writes waits in pendingApprovals()
    askUser: true, // the model may ask; its questions wait in pendingQuestions()
  })

  send(event: Event, box: HTMLInputElement) {
    event.preventDefault()
    const text = box.value.trim()
    if (!text) return
    box.value = ''
    // While a run goes on, a message steers it (shown to the model at its next step);
    // otherwise it starts a new run.
    if (!this.agent.send(text)) void this.agent.run(text)
  }
}

API

injectAgent(config, options?)

Call it in an injection context: a field initializer or the constructor of a component, directive or service, or inside runInInjectionContext(injector, …). Elsewhere it throws (NG0203), unless you pass options.injector.

  • config - the agent's BrowserAgentConfig (@dudko.dev/agent-web), as a value or a Signal<BrowserAgentConfig>.
  • options - the controller's options (AgentControllerOptions of @dudko.dev/agent-web-ui/controller), plus injector:

| Option | Default | What it does | | --- | --- | --- | | injector | the current injection context's | The injector whose life the agent shares (its DestroyRef and PLATFORM_ID). Lets you call injectAgent outside an injection context. | | autoStart | true | Build the agent at once. false: wait for reload(). | | approvals | true | Route tool-consent requests into pendingApprovals (when the config has no toolApproval.onRequest of its own). | | questions | true | Route the model's questions (askUser) into pendingQuestions (when the config has no onQuestion of its own). | | followUp | true | A message sent while the answer was being written, which the run never showed the model, is sent as the next message. | | watch | true | Follow this conversation's run in another tab of the site (needs a shared memory, e.g. IndexedDBStore). | | maxEvents | 200 | The raw event log's cap (0: no cap). | | onEvent | - | Called for every raw agent event, after the state took it. | | appToolGrants | the page's | Where "always allow" for MCP Apps' tools is kept. |

What it returns (InjectedAgent)

Signals (read-only):

| Signal | Type | | | --- | --- | --- | | state | Signal<AgentControllerSnapshot> | Everything: the AgentUiState (plan, steps, tool calls, subagents, the streamed answer, totalUsage, events, queued, undelivered, remote, …), isReady, isRunning, pendingApprovals, pendingQuestions, approvalMode, sessionId. | | isReady | Signal<boolean> | The agent is built and nothing runs (here, or for this conversation in another tab). | | isRunning | Signal<boolean> | A run goes on: this tab's, or this conversation's in another tab. | | status | Signal<'idle' \| 'initializing' \| 'ready' \| 'running' \| 'error'> | | | messages | Signal<ChatMessage[]> | The transcript: { id, role, content, pending, steps?, attachments?, … }. | | pendingApprovals | Signal<ApprovalView[]> | Tool calls waiting for consent: { id, name, input, readOnly, … }. | | pendingQuestions | Signal<PendingQuestion[]> | The model's questions: { id, question, options, multiple, allowOther, expiresAt? }. | | approvalMode | Signal<ToolApprovalMode> | The consent policy in effect. | | agent | Signal<Agent \| undefined> | The built agent, once ready. |

Methods - the controller's own functions (they keep their identity; pass them around freely): run(goal, { label?, images?, files?, attachments? }), stop(), send(text) (steer the run in flight; false when none), approve(id, { remember? }), deny(id, reason?), answerQuestion(id, answer) ({ choice: [label] }, { other: text }, { declined: true }), setApprovalMode(mode), reset(), reload(), loadChat({ sessionId, messages?, totalUsage? }), compact(), stopSubagent(id), forgetSkill(name), sendUndelivered(), discardUndelivered(), sendRemote(text), stopRemote(), approveAppToolCall(call, signal?), sampleForApp(request, approve, signal?). Each is documented on AgentControllerActions in @dudko.dev/agent-web-ui.

controller - the AgentController underneath (undefined on the server), for anything the signals do not cover. Do not dispose() it yourself: the injector does.

What is reactive, and how

  • state is set from the controller's subscribe. The controller keeps the same snapshot object until something changes, and a signal skips a value it already holds - so state changes exactly when the agent's state does, never with the same value twice.
  • isReady, messages, … are computed over state. Each keeps its value while its part is the same object: a template that reads only messages() is not re-checked when the mode changes.
  • The write is untracked, so a method called inside your own effect updates the signals on every supported Angular (17 included, where an effect may not write signals by default).

A config that changes

Pass a Signal when the agent's config changes over time - another model, a new API key:

readonly model = signal<'gemini-3.5-flash' | 'gemini-3.5-pro'>('gemini-3.5-flash')
readonly config = computed(() => ({
  model: { providerType: 'google', model: this.model(), credentialRef: 'google' },
  credentials,
}))
readonly agent = injectAgent(this.config)
  • A new object from the signal rebuilds the agent. The transcript stays.
  • The same object never rebuilds. A computed gives a new object only when what it reads changed - keep it that way (do not build the config in a template or a getter).
  • It is applied by an effect, so it happens when Angular runs effects (in change detection, or right after the signal changed when zone-less).
  • A plain value is read once. To rebuild with the same config, call reload().

Lifecycle and teardown

  • The controller is made at once, in injectAgent - in the browser. The agent starts building then (unless autoStart: false).
  • When the injector is destroyed - the component goes away, or the service's injector - the controller is disposed: the run in flight is aborted, its consent requests are denied and its questions declined, the other-tab channels are closed, the timers cleared, the subscription dropped. The signals keep their last value; the methods do nothing from then on.
  • In a service (providedIn: 'root'), the agent lives as long as the application.

Server-side rendering

On the server (PLATFORM_ID is not 'browser') no controller is made: no agent is built, no model is called, no IndexedDB or BroadcastChannel is touched. The signals hold the initial snapshot (status 'idle', no messages) and the methods do nothing (run resolves undefined, send returns false). In the browser the controller is made as usual.

With hydration, the browser's first value differs from the server's ('initializing', not 'idle'). Keep markup that depends on the agent's status out of the server render, e.g. in @defer (on idle) { … }, or render it the same way for both.

The chat in 33 languages

The chat's strings, translated, come with @dudko.dev/agent-web-ui - one chunk per language, loaded when asked for:

import { defaultLabels, mergeLabels, type AgentLabels } from '@dudko.dev/agent-web-ui'
import { loadAgentLabels } from '@dudko.dev/agent-web-ui/locales'

readonly labels = signal<AgentLabels>(defaultLabels)
constructor() {
  loadAgentLabels(navigator.language).then((l) => this.labels.set(mergeLabels(defaultLabels, l)))
}
// template: <button>{{ labels().send }}</button>

The languages and how a tag is matched: @dudko.dev/agent-web-ui's "In your language".

Markdown

The model answers in Markdown. Never put it into [innerHTML]. @dudko.dev/agent-web-ui/markdown parses it into a small tree that you draw as elements - raw HTML stays text, a link is only http(s) or mailto, no picture is loaded:

import { Component, computed, input } from '@angular/core'
import { NgTemplateOutlet } from '@angular/common'
import { parseMarkdownCached } from '@dudko.dev/agent-web-ui/markdown'

@Component({
  selector: 'app-md',
  standalone: true,
  imports: [NgTemplateOutlet],
  template: `
    <ng-template #runs let-runs>
      @for (r of runs; track $index) {
        @switch (r.t) {
          @case ('text') { {{ r.v }} }
          @case ('br') { <br /> }
          @case ('code') { <code>{{ r.v }}</code> }
          @case ('strong') { <strong><ng-container *ngTemplateOutlet="runs; context: { $implicit: r.c }" /></strong> }
          @case ('em') { <em><ng-container *ngTemplateOutlet="runs; context: { $implicit: r.c }" /></em> }
          @case ('del') { <del><ng-container *ngTemplateOutlet="runs; context: { $implicit: r.c }" /></del> }
          @case ('link') { <a [href]="r.href" target="_blank" rel="noopener noreferrer"><ng-container *ngTemplateOutlet="runs; context: { $implicit: r.c }" /></a> }
          @case ('file') { <ng-container *ngTemplateOutlet="runs; context: { $implicit: r.c }" /> }
        }
      }
    </ng-template>
    @for (b of blocks(); track $index) {
      @switch (b.t) {
        @case ('p') { <p><ng-container *ngTemplateOutlet="runs; context: { $implicit: b.c }" /></p> }
        @case ('h') { <h4><ng-container *ngTemplateOutlet="runs; context: { $implicit: b.c }" /></h4> }
        @case ('code') { <pre><code>{{ b.v }}</code></pre> }
        @case ('hr') { <hr /> }
        @case ('list') {
          <ul>
            @for (i of b.items; track $index) {
              <li><ng-container *ngTemplateOutlet="runs; context: { $implicit: i.c }" /></li>
            }
          </ul>
        }
      }
    }
  `,
})
export class MarkdownComponent {
  readonly text = input.required<string>()
  readonly blocks = computed(() => parseMarkdownCached(this.text()))
}

Quotes, tables, nested lists and the parser for an answer still being written (parseMarkdownStreaming) are in @dudko.dev/agent-web-ui's "Markdown".

Need the whole chat?

Use @dudko.dev/agent-web-element: the complete chat (transcript, Markdown, tool calls, consent, questions, saved chats, workspace, MCP Apps, voice, 33 languages) as one standard web component. Angular renders it with CUSTOM_ELEMENTS_SCHEMA:

import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import '@dudko.dev/agent-web-element'
import { config } from './agent'

@Component({
  selector: 'app-help',
  standalone: true,
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `<dd-agent-chat [config]="config" lang="fr" (dd-agent-run-end)="onEnd($event)"></dd-agent-chat>`,
})
export class HelpComponent {
  config = config
  onEnd(e: Event) {
    console.log((e as CustomEvent).detail.result?.final)
  }
}

What it does not do

  • No components, no markup, no CSS. (<dd-agent-chat> has them.) Motion is the stylesheet's: soft by default; motion="reduced" | "none" on <dd-agent-chat>, or data-awr-motion on your own .awr-chat root with the ui package's styles.css (its README, "Motion"). Skins too: skin="glass" (or one of your own) on <dd-agent-chat>, switched at run time by setting the attribute or the skin property, or data-awr-skin on your own root (its README, "Skins").
  • No logic of its own. Whatever the agent does in a view is the controller's, in @dudko.dev/agent-web-ui; a fix there reaches React, the web component and this package alike.
  • No Observables. Need one? toObservable(agent.state) from @angular/core/rxjs-interop.

License

MIT © Siarhei Dudko