{"_id":"@bastion-ai/sdk","_rev":"2-5dcb7f722c152d937e62b08daebf02f0","name":"@bastion-ai/sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@bastion-ai/sdk","version":"0.1.0","keywords":["ai","agents","security","proxy","audit","typescript"],"license":"MIT","_id":"@bastion-ai/sdk@0.1.0","maintainers":[{"name":"matthieu-hakim","email":"commandobob@outlook.com"}],"homepage":"https://github.com/Matthieuhakim/Bastion#readme","bugs":{"url":"https://github.com/Matthieuhakim/Bastion/issues"},"dist":{"shasum":"3d6b0735847a2ec8fb4dc81ece06bea1945d1a88","tarball":"https://registry.npmjs.org/@bastion-ai/sdk/-/sdk-0.1.0.tgz","fileCount":22,"integrity":"sha512-2cKHbp/k8So0ZBDZxeEdxM1AK6+9H1HnGIVbppCFubW+8Z3xyJ3913FHa22Niq+nnc4dI/D0c0kwl+8TME3Pkg==","signatures":[{"sig":"MEUCIQDGCH+rR92lebF2paS5kB3WqgDm64XWCoyq36oXKo3TwgIgOFcQcb8WkS/wLvVXGi0HGkO9Gvns6GHO+kuGufUQw4c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70060},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"dbd7fe811db0e498f78e14c7b5ceaf187ec5adcd","scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc","test:watch":"vitest"},"_npmUser":{"name":"matthieu-hakim","email":"commandobob@outlook.com"},"repository":{"url":"git+https://github.com/Matthieuhakim/Bastion.git","type":"git","directory":"packages/sdk-node"},"_npmVersion":"10.9.4","description":"TypeScript SDK for the Bastion trust proxy for AI agents","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typescript":"^5.7.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1773711234718_0.523600231567029","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@bastion-ai/sdk","version":"0.1.1","description":"TypeScript SDK for the Bastion trust proxy for AI agents","license":"MIT","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","homepage":"https://github.com/Matthieuhakim/Bastion#readme","repository":{"type":"git","url":"git+https://github.com/Matthieuhakim/Bastion.git","directory":"packages/sdk-node"},"bugs":{"url":"https://github.com/Matthieuhakim/Bastion/issues"},"keywords":["ai","agents","security","proxy","audit","typescript"],"exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"scripts":{"build":"tsc","dev":"tsc --watch","test":"vitest run","test:watch":"vitest"},"devDependencies":{"typescript":"^5.7.0","vitest":"^3.0.0"},"_id":"@bastion-ai/sdk@0.1.1","gitHead":"c2b45e3b4c456a79ca4c5e776badea7ae7f0825c","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-s+UGFoJWsE8VXz/z9KCuzL8Osnq9h7kSTW31hNDqM64KO/1d6UZyBJFsDeK+BHfXj1PobL9VAzXrpW1okgSDgw==","shasum":"3d45534b21f7185acea59c610df7098d293295a1","tarball":"https://registry.npmjs.org/@bastion-ai/sdk/-/sdk-0.1.1.tgz","fileCount":18,"unpackedSize":41710,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDMRG5q5tEccGKsYJ2ZpHQjs6g+aP/xxN3DWYIdb8O3DAIhAOOaEOaHi0/HF4+AXSvzCJFhOhXKKedCSkrsgPaLBuSv"}]},"_npmUser":{"name":"matthieu-hakim","email":"commandobob@outlook.com"},"directories":{},"maintainers":[{"name":"matthieu-hakim","email":"commandobob@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.1_1773766525832_0.598272075004699"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-17T01:33:54.621Z","modified":"2026-03-17T16:55:26.129Z","0.1.0":"2026-03-17T01:33:54.876Z","0.1.1":"2026-03-17T16:55:25.990Z"},"bugs":{"url":"https://github.com/Matthieuhakim/Bastion/issues"},"license":"MIT","homepage":"https://github.com/Matthieuhakim/Bastion#readme","keywords":["ai","agents","security","proxy","audit","typescript"],"repository":{"type":"git","url":"git+https://github.com/Matthieuhakim/Bastion.git","directory":"packages/sdk-node"},"description":"TypeScript SDK for the Bastion trust proxy for AI agents","maintainers":[{"name":"matthieu-hakim","email":"commandobob@outlook.com"}],"readme":"# @bastion-ai/sdk\n\nTypeScript SDK for the [Bastion](../../README.md) trust proxy. Zero runtime dependencies — uses the global `fetch` API.\n\n## Installation\n\n```bash\nnpm install @bastion-ai/sdk\n```\n\nRequires Node.js 22+ (for native `fetch`).\n\n## Quick Start\n\n```typescript\nimport { BastionClient } from '@bastion-ai/sdk';\n\nconst client = new BastionClient({\n  baseUrl: 'http://localhost:3000',\n  apiKey: process.env.PROJECT_API_KEY!, // admin key for management\n});\n\n// Check health\nconst health = await client.health();\n```\n\n## Admin Operations\n\nUse the admin API key (`PROJECT_API_KEY`) to manage agents, credentials, and policies.\n\n### Agents\n\n```typescript\n// Create an agent (returns one-time agentSecret)\nconst { id, agentSecret } = await client.createAgent({\n  name: 'Support Bot',\n  description: 'Handles refund requests',\n  callbackUrl: 'https://example.com/webhook',\n});\n\n// List, get, update, delete\nconst agents = await client.listAgents();\nconst agent = await client.getAgent(id);\nawait client.updateAgent(id, { isActive: false });\nawait client.deleteAgent(id); // soft-delete\n```\n\n### Credentials\n\n```typescript\n// Store a credential (encrypted at rest, raw value never returned)\nconst credential = await client.createCredential({\n  name: 'Stripe Production',\n  type: 'API_KEY',\n  value: 'sk_live_...',\n  agentId: agent.id,\n});\n\nconst credentials = await client.listCredentials(agent.id);\nawait client.revokeCredential(credential.id);\n```\n\n### Policies\n\n```typescript\nconst policy = await client.createPolicy({\n  agentId: agent.id,\n  credentialId: credential.id,\n  allowedActions: ['charges.*'],\n  deniedActions: ['transfers.*'],\n  constraints: {\n    maxAmountPerTransaction: 1000,\n    maxDailySpend: 5000,\n    rateLimit: { maxRequests: 100, windowSeconds: 3600 },\n  },\n  requiresApprovalAbove: 500,\n});\n\n// Dry-run evaluation (no side effects)\nconst result = await client.evaluatePolicy({\n  agentId: agent.id,\n  credentialId: credential.id,\n  action: 'charges.create',\n  params: { amount: 750 },\n});\n// result.decision → \"ESCALATE\"\n```\n\n## Agent Operations\n\nUse an agent secret (`bst_...`) for proxy execution.\n\n```typescript\nconst agentClient = new BastionClient({\n  baseUrl: 'http://localhost:3000',\n  apiKey: agentSecret, // agent secret from createAgent\n});\n\nconst result = await agentClient.execute({\n  credentialId: credential.id,\n  action: 'charges.create',\n  params: { amount: 50 },\n  target: {\n    url: 'https://api.stripe.com/v1/charges',\n    method: 'POST',\n    body: { amount: 5000, currency: 'usd' },\n  },\n});\n\n// result.upstream.status → 200\n// result.upstream.body → Stripe's response\n// result.meta.policyDecision → \"ALLOW\"\n```\n\n### Custom Credential Injection\n\n```typescript\nawait agentClient.execute({\n  credentialId: credential.id,\n  action: 'test',\n  target: { url: 'https://api.example.com' },\n  injection: { location: 'header', key: 'X-Api-Key' },\n});\n```\n\n## HITL (Human-in-the-Loop)\n\n```typescript\nconst pending = await client.listPendingRequests();\nawait client.approveRequest(pending[0].requestId);\nawait client.denyRequest(requestId, 'Too risky');\n```\n\n## Audit\n\n```typescript\nconst records = await client.queryAuditRecords({\n  agentId: agent.id,\n  from: '2026-01-01',\n  policyDecision: 'DENY',\n  limit: 10,\n});\n\nconst verification = await client.verifyChain(agent.id);\n// verification.valid → true\n```\n\n## Error Handling\n\nAll API errors throw typed exceptions:\n\n```typescript\nimport { BastionForbiddenError, BastionNotFoundError } from '@bastion-ai/sdk';\n\ntry {\n  await agentClient.execute({ ... });\n} catch (err) {\n  if (err instanceof BastionForbiddenError) {\n    console.log('Policy denied:', err.message);\n  }\n}\n```\n\n| Error Class | Status | When |\n| ------------ | ------ | ---- |\n| `BastionValidationError` | 400 | Invalid input |\n| `BastionUnauthorizedError` | 401 | Bad or missing auth |\n| `BastionForbiddenError` | 403 | Policy DENY or HITL timeout |\n| `BastionNotFoundError` | 404 | Resource not found |\n| `BastionConflictError` | 409 | State conflict |\n| `BastionBadGatewayError` | 502 | Upstream API failure |\n\n## License\n\n[MIT](../../LICENSE)\n","readmeFilename":"README.md"}