@armoriq/sdk
v0.2.6
Published
ArmorIQ SDK - Build secure AI agents with cryptographic intent verification.
Maintainers
Readme
ArmorIQ SDK (TypeScript)
Build secure AI agents with cryptographic intent verification.
The ArmorIQ SDK enables developers to build AI agents with built-in security and auditability. Just one API key - no cloud complexity.
Why ArmorIQ?
- Simple - Just one API key, no cloud credentials
- Secure - Cryptographic verification for every action
- Auditable - Complete execution trail
- Fast - Get started in 5 minutes
Installation
npm install @armoriq/sdk
# or
yarn add @armoriq/sdkQuick Start
1. Get Your API Key
Visit platform.armoriq.ai to generate your API key.
2. Initialize the Client
import { ArmorIQClient } from '@armoriq/sdk';
const client = new ArmorIQClient({
apiKey: 'ak_your_key_here',
userId: 'your-user-id',
agentId: 'your-agent-id',
});3. Capture Your Plan
const plan = {
goal: 'Get weather forecast',
steps: [
{
action: 'get_weather',
tool: 'weather_api',
mcp: 'weather-mcp',
inputs: { city: 'Boston' },
},
],
};
const planCapture = client.capturePlan('gpt-4', "What's the weather in Boston?", plan);4. Get Intent Token
const token = await client.getIntentToken(planCapture);5. Invoke Actions
const result = await client.invoke('weather-mcp', 'get_weather', token, {
city: 'Boston',
});
console.log(result);Environment Variables
# Required
ARMORIQ_API_KEY=ak_your_key_here
USER_ID=your-user-id
AGENT_ID=your-agent-id
# Optional
ARMORIQ_ENV=production # or 'development' for local
CONTEXT_ID=default
IAP_ENDPOINT=https://customer-iap.armoriq.ai
PROXY_ENDPOINT=https://customer-proxy.armoriq.ai
BACKEND_ENDPOINT=https://customer-api.armoriq.aiAdvanced Usage
Delegation
import * as crypto from 'crypto';
// Generate delegate keypair
const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
const pubKeyHex = publicKey.export({ type: 'spki', format: 'der' }).toString('hex');
const delegation = await client.delegate(token, pubKeyHex, 1800);
console.log(`Delegated token: ${delegation.delegatedToken.tokenId}`);Custom Proxy Endpoints
const client = new ArmorIQClient({
apiKey: 'ak_your_key_here',
userId: 'user-123',
agentId: 'agent-456',
proxyEndpoints: {
'weather-mcp': 'https://weather-proxy.example.com',
'finance-mcp': 'https://finance-proxy.example.com',
},
});Error Handling
import {
InvalidTokenException,
IntentMismatchException,
MCPInvocationException,
TokenExpiredException,
} from '@armoriq/sdk';
try {
const result = await client.invoke('weather-mcp', 'get_weather', token, { city: 'Boston' });
} catch (error) {
if (error instanceof TokenExpiredException) {
console.error('Token expired, please get a new one');
} else if (error instanceof IntentMismatchException) {
console.error('Action not in original plan');
} else if (error instanceof MCPInvocationException) {
console.error('MCP invocation failed:', error.message);
}
}API Reference
ArmorIQClient
Constructor Options
interface SDKConfig {
apiKey: string; // Required: Your API key
userId: string; // Required: User identifier
agentId: string; // Required: Agent identifier
contextId?: string; // Optional: Context identifier (default: 'default')
useProduction?: boolean; // Optional: Use production endpoints (default: true)
iapEndpoint?: string; // Optional: Override IAP endpoint
proxyEndpoint?: string; // Optional: Override proxy endpoint
backendEndpoint?: string; // Optional: Override backend endpoint
proxyEndpoints?: Record<string, string>; // Optional: MCP-specific proxies
timeout?: number; // Optional: Request timeout in ms (default: 30000)
maxRetries?: number; // Optional: Max retry attempts (default: 3)
verifySsl?: boolean; // Optional: Verify SSL (default: true)
}Methods
capturePlan(llm, prompt, plan, metadata?)- Capture an execution plangetIntentToken(planCapture, policy?, validitySeconds?)- Get a signed intent tokeninvoke(mcp, action, intentToken, params?, merkleProof?, userEmail?)- Invoke an MCP actiondelegate(intentToken, delegatePublicKey, validitySeconds?, allowedActions?, targetAgent?, subtask?)- Delegate to another agentverifyToken(intentToken)- Verify a token locallyclose()- Cleanup resources
Documentation
For complete documentation, visit docs.armoriq.ai
Links
License
MIT License - see LICENSE file for details.
