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

@kedge-agentic/common

v0.2.0

Published

Shared types for Claude Code as a Service

Readme

@kedge-agentic/common

Shared types, protocols, and utilities for Claude Code as a Service.

Overview

This package provides shared TypeScript definitions used across all CCAAS packages:

  • Types (@kedge-agentic/common/types) - Core interfaces for sessions, messages, skills, tenants, etc.
  • Protocols (@kedge-agentic/common/protocols) - Real-time event protocols for output updates

Installation

# Install from workspace
npm install @kedge-agentic/common

Usage

Import Everything

import {
  // Types
  Session,
  Message,
  Skill,
  TokenUsage,
  // Protocols
  OutputUpdateEvent,
  validateOutputUpdateEvent,
  mapFieldsToFrontend,
} from '@kedge-agentic/common';

Import Specific Modules

// Just types
import { Session, Message, Skill } from '@kedge-agentic/common/types';

// Just protocols
import { OutputUpdateEvent, validateOutputUpdateEvent } from '@kedge-agentic/common/protocols';

Types Module

Session Types

import { Session, SessionStatus, SessionSummary } from '@kedge-agentic/common/types';

const session: Session = {
  id: 'sess_123',
  tenantId: 'tenant_456',
  status: 'processing',
  createdAt: '2024-01-01T00:00:00Z',
  updatedAt: '2024-01-01T00:00:00Z',
};

Message Types

import { Message, ToolCall, ThinkingBlock } from '@kedge-agentic/common/types';

const message: Message = {
  id: 'msg_123',
  sessionId: 'sess_123',
  role: 'assistant',
  content: 'Hello!',
  toolCalls: [],
  createdAt: '2024-01-01T00:00:00Z',
};

Skill Types

import { Skill, SkillVersion, SkillTrigger } from '@kedge-agentic/common/types';

const skill: Skill = {
  id: 'skill_123',
  tenantId: 'tenant_456',
  name: 'Code Review',
  slug: 'code-review',
  type: 'prompt',
  status: 'published',
  prompt: 'You are a code reviewer...',
  version: 1,
  createdAt: '2024-01-01T00:00:00Z',
  updatedAt: '2024-01-01T00:00:00Z',
};

API Key Types

import { ApiKey, ApiKeyScope } from '@kedge-agentic/common/types';

const scopes: ApiKeyScope[] = ['skills:read', 'skills:execute', 'chat'];

Event Types

import {
  TextDeltaEvent,
  ToolActivityEvent,
  AgentStatusEvent,
} from '@kedge-agentic/common/types';

// Type-safe event handling (SSE or Socket.IO)
// SSE example:
function handleEvent(event: TextDeltaEvent) {
  console.log(event.delta);
}

Protocols Module

Output Update Protocol

Used for streaming AI-generated content from backend to frontend.

import {
  OutputUpdateEvent,
  validateOutputUpdateEvent,
  safeValidateOutputUpdateEvent,
  mapFieldsToFrontend,
} from '@kedge-agentic/common/protocols';

// Backend: Emit event
const event: OutputUpdateEvent = {
  data: { textbookAnalysis: {...} },
  status: 'generating',
  progress: { totalSteps: 7, completedSteps: 1, percentage: 14 },
  timestamp: new Date().toISOString(),
};

// Validate before emitting
validateOutputUpdateEvent(event);

// Frontend: Receive event
socket.on('output_update', (rawEvent) => {
  const result = safeValidateOutputUpdateEvent(rawEvent);
  if (result.success) {
    const formData = mapFieldsToFrontend(result.data.data);
    store.updateFields(formData);
  }
});

Field Mappings

Some fields have different names in backend vs frontend:

| Backend Field | Frontend Field | |---------------|----------------| | learningTasks | learningProcess | | homeworkTasks | homeworkAssessment |

import { mapFieldsToFrontend, mapFieldsToBackend } from '@kedge-agentic/common/protocols';

// Backend → Frontend
const frontendData = mapFieldsToFrontend(backendData);

// Frontend → Backend
const backendData = mapFieldsToBackend(frontendData);

API Reference

Types

| Type | Description | |------|-------------| | Session | Session entity | | SessionStatus | Session status enum | | Message | Chat message entity | | ToolCall | Tool invocation details | | ThinkingBlock | Extended thinking content | | TokenUsage | Token usage metrics | | Skill | Skill definition | | SkillVersion | Skill version history | | ApiKey | API key entity | | ApiKeyScope | Available API scopes | | Tenant | Tenant entity | | PaginatedResult<T> | Paginated response wrapper |

Protocols

| Export | Description | |--------|-------------| | OutputUpdateEvent | Output update event interface | | validateOutputUpdateEvent() | Validate event (throws on error) | | safeValidateOutputUpdateEvent() | Safe validation (returns result) | | isOutputUpdateEvent() | Type guard function | | mapFieldsToFrontend() | Transform backend → frontend fields | | mapFieldsToBackend() | Transform frontend → backend fields | | FIXTURES | Valid event fixtures for testing | | INVALID_FIXTURES | Invalid fixtures for testing |

Development

# Build
npm run build

# Test
npm test

# Type check
npm run typecheck

License

MIT