Skip to main content

Angular

npm install @axag/angular
import { Component } from '@angular/core';
import { AxagDirective } from '@axag/angular';
import { defineAction } from '@axag/core';

@Component({
standalone: true,
imports: [AxagDirective],
template: `<button [axag]="deactivateUser" [axagHandler]="deactivate">Deactivate</button>`,
})
export class UserRowComponent {
deactivateUser = defineAction({
intent: 'user.deactivate',
actionType: 'write',
riskLevel: 'critical',
approvalRequired: true,
approvalRoles: ['security_admin'],
requiredParameters: [{ name: 'user_id', type: 'string', format: 'uuid' }],
});

deactivate = ({ user_id }: { user_id: string }) => this.api.deactivate(user_id);
}

Inputs

InputDescription
axagThe action spec (required)
axagHandlerWhat the tool does; defaults to filling the form and pressing the control
axagMiddlewareWraps every call
axagEnabledfalse keeps the action off the agent's list

Behaviour worth knowing

  • Routing and @if unregister the action, because destroying the directive aborts its signal.
  • Changing an input re-registers rather than adding a second tool.
  • SSR is a no-op: on the server there is no model context to register with, and nothing to drive.
  • The directive is standalone and works with Angular 16+.

Templates are read at build time too

@axag/compiler reads *.component.html templates, so a static axag="write:user.deactivate!critical" appears in the manifest. A bound [axag]="spec" is known only at runtime and is listed under dynamic_actions.