
Company News
AWS Security Hub Adds Socket for Supply Chain Security
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.
@agentgate/sdk
Advanced tools
TypeScript SDK for agents to request human approvals via AgentGate.
npm install @agentgate/sdk
# or
pnpm add @agentgate/sdk
import { AgentGateClient } from '@agentgate/sdk'
const client = new AgentGateClient({
baseUrl: 'http://localhost:3000',
apiKey: 'your-api-key' // optional
})
// Request approval for an action
const request = await client.request({
action: 'send_email',
params: { to: 'customer@example.com' },
context: { dealValue: 50000 }
})
console.log(`Request ${request.id} created, waiting for approval...`)
// Wait for human decision (polls until decided or timeout)
const decided = await client.waitForDecision(request.id, {
timeout: 5 * 60 * 1000, // 5 minutes (default)
pollInterval: 2000 // 2 seconds (default)
})
if (decided.status === 'approved') {
// Execute the action
console.log('Approved! Sending email...')
} else if (decided.status === 'denied') {
console.log('Request denied:', decided.decisionReason)
} else if (decided.status === 'expired') {
console.log('Request expired before decision')
}
AgentGateClientnew AgentGateClient({
baseUrl: string, // Required: URL of your AgentGate server
apiKey?: string // Optional: API key for authentication
})
request(options): Promise<ApprovalRequest>Submit an approval request. Returns immediately with the created request.
const request = await client.request({
action: 'send_email', // Required: action identifier
params: { to: 'user@email.com' }, // Optional: action parameters
context: { reason: 'Follow up' }, // Optional: contextual info
urgency: 'high', // Optional: 'low' | 'normal' | 'high' | 'critical'
expiresAt: new Date(Date.now() + 3600000) // Optional: expiration time
})
getRequest(id): Promise<ApprovalRequest>Get an approval request by ID.
const request = await client.getRequest('req_123')
waitForDecision(id, options?): Promise<ApprovalRequest>Poll until a decision is made or timeout is reached.
const decided = await client.waitForDecision('req_123', {
timeout: 300000, // 5 minutes (default)
pollInterval: 2000 // 2 seconds (default)
})
Throws TimeoutError if timeout is reached.
listRequests(options?): Promise<ApprovalRequest[]>List approval requests with optional filters.
const requests = await client.listRequests({
status: 'pending', // Filter by status
action: 'send_email', // Filter by action
limit: 10, // Max results
offset: 0 // Pagination offset
})
// List all policies
const policies = await client.listPolicies()
// Get a specific policy
const policy = await client.getPolicy('pol_123')
// Create a policy
const newPolicy = await client.createPolicy({
name: 'Auto-approve low-risk emails',
rules: [{ match: { action: 'send_email' }, decision: 'auto_approve' }],
priority: 100,
enabled: true,
})
// Update a policy
const updated = await client.updatePolicy('pol_123', { enabled: false })
// Delete a policy
await client.deletePolicy('pol_123')
// List webhooks
const webhooks = await client.listWebhooks()
// Create a webhook (secret is only returned once!)
const wh = await client.createWebhook({
url: 'https://example.com/webhook',
events: ['request.approved', 'request.denied'],
})
console.log('Save this secret:', wh.secret)
// Update a webhook
await client.updateWebhook('wh_123', { enabled: false })
// Delete a webhook
await client.deleteWebhook('wh_123')
// Test a webhook
const result = await client.testWebhook('wh_123')
console.log(result.success ? 'Delivered!' : 'Failed:', result.message)
// List audit entries with filters
const audit = await client.listAuditLogs({
eventType: 'approved',
actor: 'dashboard:admin',
from: '2024-01-01',
to: '2024-01-31',
limit: 20,
})
console.log(audit.entries, audit.pagination)
// Get unique actors for filter dropdowns
const actors = await client.getAuditActors()
// List API keys (secrets are never returned)
const keys = await client.listApiKeys()
// Create an API key (key is only returned once!)
const newKey = await client.createApiKey({
name: 'CI Pipeline',
scopes: ['agent'],
})
console.log('Save this key:', newKey.key)
// Revoke an API key
await client.revokeApiKey('key_123')
import { AgentGateError, TimeoutError } from '@agentgate/sdk'
try {
await client.waitForDecision(id)
} catch (error) {
if (error instanceof TimeoutError) {
console.log('Timed out waiting for decision')
} else if (error instanceof AgentGateError) {
console.log(`API error: ${error.message} (${error.statusCode})`)
}
}
All types from @agentgate/core are re-exported for convenience:
import type {
ApprovalRequest,
ApprovalStatus,
ApprovalUrgency,
DecisionType,
Policy,
PolicyRule,
PolicyDecision,
Webhook,
WebhookCreateOptions,
WebhookCreateResult,
AuditEntry,
AuditListResult,
ApiKey,
ApiKeyCreateResult,
} from '@agentgate/sdk'
MIT
FAQs
SDK for integrating AgentGate into your applications
The npm package @agentgate/sdk receives a total of 1 weekly downloads. As such, @agentgate/sdk popularity was classified as not popular.
We found that @agentgate/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.

Research
/Security News
Popular npm packages keyv and cacheable compromised.

Security News
A misconfiguration gave three Anthropic models internet access, and one, believing it was in a simulation, shipped a credential-stealing package to PyPI.