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

@applica-software-guru/persona-sdk

v0.1.116

Published

Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.

Readme

Deploy

Persona SDK

npm version

Official TypeScript SDK for the Persona API. Manage agents, sessions, projects, knowledge bases, workflows, triggers, missions and more from any JavaScript/TypeScript application.

Install

npm install @applica-software-guru/persona-sdk

Quick Start

import { PersonaSdk } from '@applica-software-guru/persona-sdk';

const sdk = new PersonaSdk(
  'https://persona.applica.guru/api',       // persona-core base URL
  'https://persona.applica.guru/workflows', // workflows service base URL
  'https://persona.applica.guru/billing'    // billing service base URL (optional)
);

// Authenticate with a project API key
const agents = await sdk.agents('prs_your_project_api_key').list(null, 1, 20);
console.log(`Total agents: ${agents.total}`);

The PersonaSdk constructor accepts:

  1. baseUrl — persona-core API base URL (required)
  2. workflowsBaseUrl — workflows service base URL (required)
  3. billingBaseUrl — billing service base URL (optional, defaults to https://persona.applica.guru/billing)

Each resource is exposed as a factory method that requires authentication credentials.

Authentication

The SDK supports two authentication methods. Pass either a string (API key) or an AuthenticationProvider instance to any resource factory.

API Key

The simplest method — pass the API key string directly. The SDK wraps it in an ApiKeyAuthenticationProvider and sends it as the x-persona-apikey header.

Accepts:

  • Master key — full admin access (server-to-server only)
  • Project API key (prs_...) — scoped to a single project
  • Agent API key (prs_ag_...) — scoped to a single agent
const projects = await sdk.projects('prs_your_project_api_key').getMine();

IAM Bearer Token

For applications that authenticate end users via IAM, pass a BearerTokenAuthenticationProvider with a valid JWT:

import { BearerTokenAuthenticationProvider } from '@applica-software-guru/persona-sdk';

const auth = new BearerTokenAuthenticationProvider(iamJwtToken);
const projects = await sdk.projects(auth).getMine();

The token is sent as the Authorization: Bearer <token> header. The server validates it via the IAM service and resolves the user's project automatically. Use this method when building user-facing apps (e.g. control panels) where the user logs in through IAM.

Custom provider

Implement your own provider via the AuthenticationProvider interface:

import { AuthenticationProvider } from '@applica-software-guru/persona-sdk';

class MyProvider implements AuthenticationProvider {
  applyHeaders(headers: Headers): void {
    headers.set('x-custom-header', 'value');
  }

  getCredentials(): string {
    return 'my-credentials';
  }
}

Usage Examples

Agents

const agentsApi = sdk.agents('your-api-key');

// List agents (with optional server-side filters)
const { items, total } = await agentsApi.list('search-term', 1, 20);

// Filter by project
const projectAgents = await agentsApi.list(null, 1, 20, { projectId: 'my-project-id' });

// Get a single agent
const agent = await agentsApi.get('agent-id');

// Create an agent
const agent = await agentsApi.create({
  name: 'My Agent',
  description: 'A helpful assistant',
  systemInstructions: 'You are a helpful assistant.',
});

// Update an agent
const updated = await agentsApi.update({
  id: 'agent-id',
  name: 'Updated Name',
});

// Delete an agent
await agentsApi.remove('agent-id');

// Generate system instructions with AI (project-scoped architect)
const instructions = await agentsApi.generateSystemInstructions(
  'Create a customer support agent that handles billing inquiries',
  'optional-session-id', // for multi-turn refinement
);

// Get the project's architect agent configuration
const architect = await agentsApi.getArchitect();

Sessions

const sessionsApi = sdk.sessions('your-api-key');

// List sessions
const sessions = await sessionsApi.list(null, null, null, null, 1, 20);

// Generate a message
const response = await sessionsApi.generateMessage('session-code', {
  userMessage: 'Hello, how are you?',
});

// Get session messages
const messages = await sessionsApi.findMessages('session-code', 1, 50);

// Get usage info
const usage = await sessionsApi.getUsage('session-id');

Projects

const projectsApi = sdk.projects('your-api-key');

// Get current project
const project = await projectsApi.getMine();

// Create a project
const project = await projectsApi.create({ name: 'My Project' });

// Get subscription info
const subscription = await projectsApi.getSubscription('project-id');

Knowledge Bases

const kbApi = sdk.knowledgeBases('your-api-key');

// List knowledge bases
const knowledgeBases = await kbApi.list(null, 1, 20);

// Create a knowledge base
const kb = await kbApi.create({ name: 'My Knowledge Base' });

// Upload a document
const doc = await kbApi.documents(kb.id).upload({
  name: 'document.pdf',
  uri: 'https://example.com/document.pdf',
});

// Search chunks
const chunks = await kbApi.searchChunks(kb.id, { query: 'search term', limit: 5 });

Workflows

const workflowsApi = sdk.workflows('your-api-key');

// List workflows
const workflows = await workflowsApi.list(null, 1, 20);

// Execute a workflow
const execution = await workflowsApi.executions().run('workflow-id', {
  userId: 'user-123',
  initialData: { key: 'value' },
});

Credentials

const credentialsApi = sdk.credentials('your-api-key');

// List credentials
const creds = await credentialsApi.list();

// Authorize OAuth2
const result = await credentialsApi.authorize('google', {
  name: 'My Google Account',
  clientId: '...',
  clientSecret: '...',
});

Triggers

const triggersApi = sdk.triggers('your-api-key');

// List triggers
const triggers = await triggersApi.list(null, 1, 20);

// Execute a trigger
const result = await triggersApi.executions().execute('trigger-id', {});

Features

const featuresApi = sdk.features('your-api-key');

// List feature templates
const templates = await featuresApi.templates().list(null, 1, 20);

// Get MCP available tools
const tools = await featuresApi.templates().getMcpAvailableTools({
  type: 'mcp',
  name: 'my-server',
  transport: { url: 'https://mcp.example.com' },
});

Missions

const missionsApi = sdk.missions('your-api-key');

// List missions
const missions = await missionsApi.list(null, null, 1, 20);

// Create and execute
const mission = await missionsApi.create({ name: 'My Mission' });
await missionsApi.execute(mission.id);

Model aliases

A model alias is a named indirection to a concrete model. An agent whose model is alias:<name> follows the alias: editing it moves every agent that uses it, e.g. when a model is retired. An alias also lists ordered fallbacks that the server uses at runtime when the target cannot serve a call.

Global aliases are managed by super admins; project aliases by super admins, project admins and the project API key (not plain users, nor agent keys). Everyone in a project can read its aliases and the global ones.

import { aliasRef, ModelAliasesApi } from '@applica-software-guru/persona-sdk';

const aliases = sdk.modelAliases('your-api-key');

// Create a project alias (non-super-admins always create in their own project)
const alias = await aliases.create({
  name: 'smart',
  target: 'openai/gpt-5',
  fallbacks: ['anthropic/claude-sonnet-4'],
  defaults: { reasoningEffort: 'high' }, // only fills what the agent leaves empty
});

// Point an agent at it
const agentsApi = sdk.agents('your-api-key');
const agent = await agentsApi.get('agent-id');
await agentsApi.update({
  id: agent.id,
  model: { ...agent.model, modelName: aliasRef('smart') }, // "alias:smart"
});

// Which agents use it, before changing it
const impact = await aliases.impact(alias.id);

// The target is being retired: ask for candidates (a proposal only, nothing is applied)...
const { replacements, fallbacks } = await aliases.suggestions(alias.id);
// ...and apply the one you choose, by hand
await aliases.update(alias.id, { ...alias, target: replacements[0].model });

// Run the health check now (the server also runs it nightly)
const checked = await aliases.check(alias.id);
console.log(checked.health.status, checked.health.issues);

// Deleting is refused while agents reference the alias
try {
  await aliases.remove(alias.id);
} catch (error) {
  const blocking = ModelAliasesApi.inUse(error); // the agents, or null for any other error
  if (!blocking) throw error;
  console.warn(`Used by ${blocking.total} agent(s)`, blocking.usages);
}

name and the scope (projectId) are immutable. The server keeps the health and the last 50 changes (history). The cost of what ran through an alias is in Billing (byAlias).

Notifications

In-platform notifications (badge and banner), e.g. a model alias whose target is being retired, or that is being served by a fallback.

const notifications = sdk.notifications('your-api-key');

const badge = await notifications.unreadCount();
const { items } = await notifications.list({ unreadOnly: true });
for (const n of items) {
  // `title` and `message` are an English fallback: localize from `code` and `data`
  console.log(n.severity, n.code, n.title);
}
await notifications.markRead(items[0].id);
await notifications.markAllRead();

A project sees its own notifications; platform-wide ones are for super admins. Agent API keys have no access.

Billing

The BillingClient manages customers, subscriptions, credits and invoices. When using PersonaSdk, the billing base URL is configured in the constructor and billing() follows the same authentication pattern as all other APIs.

// Via PersonaSdk (recommended) — uses billingBaseUrl from constructor
const billing = sdk.billing('your-api-key');
const billing = sdk.billing(new BearerTokenAuthenticationProvider(token));

// Standalone usage with explicit base URL
import { BillingClient } from '@applica-software-guru/persona-sdk';
const billing = new BillingClient('https://persona.applica.guru/billing', 'your-api-key');

// Customer management
const customer = await billing.createCustomer({
  owner: 'user-123',
  name: 'Acme Corp',
  email: '[email protected]',
});
const existing = await billing.getCustomer('user-123');
await billing.updateCustomer('user-123', { name: 'Acme Inc.' });
await billing.deleteCustomer('user-123');

// Subscription management
const subscription = await billing.createSubscription({ owner: 'user-123' });
const current = await billing.getSubscription('user-123');
await billing.cancelSubscription('user-123');

// Plan changes
await billing.beginUpgrade('user-123', { toPlanType: 'pro' });
await billing.downgrade('user-123', { toPlanType: 'starter' });
await billing.mentorize('user-123', { endDate: '2026-12-31' });

// Credits
await billing.addCredits('user-123', 100);
await billing.useCredits('user-123', 10, ['chat', 'voice'], 'reference-id');
const credits = await billing.getCredits('user-123');
const valid = await billing.isValid('user-123');

// Invoices
const invoices = await billing.listInvoices('user-123', '2026-01-01', '2026-12-31');

// Project-level billing
const projectSub = await billing.getProjectSubscription('project-id');
await billing.changeProjectSubscriptionPlan('project-id', { toPlanType: 'pro' });
await billing.addProjectSubscriptionCredits('project-id', { credits: 50 });

// Usage statistics: per model and per model alias (the cost of an alias is the sum over the
// concrete models it served; credits and prices follow the visibility of the caller)
const stats = await billing.getUsageStats('project-id', '2026-11-01', '2026-11-30');
console.log(stats.byModel, stats.byAlias);

// Usages that went through an alias (the last parameter)
const usages = await billing.listUsages('project-id', undefined, undefined, undefined, undefined, 0, 20, ['smart']);

Server-side Filtering

All paginated list methods accept an optional extraParams argument as the last parameter. These key-value pairs are appended to the query string, enabling server-side filters such as projectId:

// Filter agents by project
const agents = await sdk.agents(auth).list(null, 1, 20, { projectId: 'abc123' });

// Combine keyword search with project filter
const results = await sdk.knowledgeBases(auth).list('my-kb', 1, 20, { projectId: 'abc123' });

Supported on: AgentsApi, KnowledgeBasesApi, WorkflowsApi, TriggersApi, FeatureTemplatesApi, ServicePricesApi.

Error Handling

import { ApiException } from '@applica-software-guru/persona-sdk';

try {
  const agent = await sdk.agents('api-key').get('invalid-id');
} catch (error) {
  if (error instanceof ApiException) {
    console.error(`API Error ${error.statusCode}: ${error.body}`);
  } else {
    throw error;
  }
}

API Reference

| Resource | Methods | |---|---| | ProjectsApi | list, get, getMine, create, update, remove, getSubscription, changeSubscriptionPlan, addSubscriptionCredits | | AgentsApi | list, get, create, update, remove, getSynthesizerSupportedVoices, listRevisions, getRevision, rollback, generateSystemInstructions, getArchitect | | SessionsApi | list, get, getUsage, generateMessage, findMessages, remove | | KnowledgeBasesApi | list, get, create, update, remove, documents(), searchChunks | | KnowledgeBaseDocumentsApi | list, upload, get, reprocess, remove | | WorkflowsApi | list, create, update, remove, get, executions(), listRevisions, getRevision, rollback | | WorkflowExecutionsApi | list, get, run, queue | | CredentialsApi | authorize, handleOAuth2Callback, list, getByProvider, getById, remove | | TriggersApi | list, create, update, remove, get, executions() | | TriggerExecutionsApi | list, execute, get, remove | | FeaturesApi | templates() | | FeatureTemplatesApi | list, get, create, update, patch, remove, getMcpAvailableTools | | MissionsApi | list, get, create, update, remove, generate, execute, retry, replan, sendInstruction, stop, resume | | ServicePricesApi | list, get, create, update, remove | | ModelAliasesApi | list, get, create, update, remove, impact, check, suggestions, ModelAliasesApi.inUse | | NotificationsApi | list, unreadCount, markRead, markAllRead | | BillingClient | createCustomer, updateCustomer, getCustomer, saveCustomer, deleteCustomer, createSubscription, getSubscription, cancelSubscription, beginUpgrade, downgrade, mentorize, addCredits, useCredits, getCredits, isValid, listInvoices, getProjectSubscription, changeProjectSubscriptionPlan, addProjectSubscriptionCredits, getUsageStats, listUsages |

Compatibility

  • Runtime: Browser (Chrome, Firefox, Safari, Edge), Node.js 18+
  • Frameworks: React, Vue, Angular, Svelte, Next.js, Vite, Webpack
  • Module systems: ESM, CommonJS
  • TypeScript: Full type definitions included

License

MIT