@opena2a/shared

v0.1.1

Published

Shared types, config schema, and utilities for the OpenA2A platform

Downloads

1,491

Readme

@opena2a/shared

npm version License: Apache-2.0

Shared types, config schema, and utilities for the OpenA2A platform.

Install

npm install @opena2a/shared

What's Inside

This package provides the common foundation used by opena2a-cli and other OpenA2A tools:

  • Project config -- loadProjectConfig() reads and validates .opena2a.yml / opena2a.config.json using Zod schemas
  • User config -- loadUserConfig() / saveUserConfig() manage per-user preferences stored in ~/.opena2a/
  • Scan history -- loadScanHistory() / appendScanEntry() track past scan results locally
  • Shared types -- AdapterType, AdapterResult, Finding, and other interfaces used across adapters

Usage

import {
  loadProjectConfig,
  loadUserConfig,
  saveUserConfig,
  isContributeEnabled,
  loadScanHistory,
  appendScanEntry,
} from '@opena2a/shared';

// Load project config from current directory
const config = loadProjectConfig('./');

// Check user preferences
const userConfig = loadUserConfig();
console.log('Contribute enabled:', isContributeEnabled());

// Track scan history
appendScanEntry({
  tool: 'hackmyagent',
  target: 'my-project',
  score: 85,
  timestamp: new Date().toISOString(),
});

API

| Export | Description | |--------|------------| | loadProjectConfig(dir) | Load and validate project config from a directory | | projectConfigSchema | Zod schema for project configuration | | loadUserConfig() | Load user preferences from ~/.opena2a/ | | saveUserConfig(config) | Persist user preferences | | isContributeEnabled() | Check if anonymous data contribution is enabled | | setContributeEnabled(bool) | Toggle data contribution | | loadScanHistory() | Load local scan history | | appendScanEntry(entry) | Add a scan result to history | | getLastScan() | Get the most recent scan entry | | getRecentScans() | Get recent scan entries |

Part of OpenA2A

This is an internal package used by opena2a-cli and other OpenA2A tools. For the CLI, see the main repository.

License

Apache-2.0