{"_id":"@agops-labs/sdk","_rev":"2-71b7406c556b8a02e268efda0dcbdab2","name":"@agops-labs/sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@agops-labs/sdk","version":"0.1.0","keywords":["agentops","casper","ai-agents","x402","mcp","policy","web3","payments"],"license":"MIT","_id":"@agops-labs/sdk@0.1.0","maintainers":[{"name":"kaushalya4s5s7","email":"chaudharikaushal02@gmail.com"}],"dist":{"shasum":"bc6876632e9936623ce9dd1e83bf7d40e5084a1f","tarball":"https://registry.npmjs.org/@agops-labs/sdk/-/sdk-0.1.0.tgz","fileCount":7,"integrity":"sha512-ddy86aaVPMLZXpQNw3D5tMPiYk8pVeiib5taEf6BOYutCh9+eM29kwEq2wu9tl1SNNII3A1eiYAeR7PvvP1kAg==","signatures":[{"sig":"MEQCIGaNpHZCoPDyqEFMovXbfc+ruDEIiFTQEZAN4PSVGSWIAiAmERPRROkaLqddFFBKAHMaV52mvaedxm9WnZc53GFXRg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11476},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"2f464b5abe9ec74c01588db836bd134e9859b67b","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run clean && npm run build"},"_npmUser":{"name":"kaushalya4s5s7","email":"chaudharikaushal02@gmail.com"},"_npmVersion":"11.6.2","description":"AgentOps SDK — REST + MCP client for the AgentOps (Casper-AGOPS) policy-firewall proxy. Authorize AI-agent payments and on-chain actions with enforced spend caps and on-chain audit anchoring.","directories":{},"sideEffects":false,"_nodeVersion":"24.11.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.2.6","typescript":"^5.7.2"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1784891413984_0.4288544010757238","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agops-labs/sdk","version":"0.2.0","description":"AgentOps SDK — REST + MCP client for the AgentOps (Casper-AGOPS) policy-firewall proxy. Authorize AI-agent payments and on-chain actions with enforced spend caps and on-chain audit anchoring.","keywords":["agentops","casper","ai-agents","x402","mcp","policy","web3","payments"],"license":"MIT","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"sideEffects":false,"engines":{"node":">=18"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit","test":"vitest run","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build"},"devDependencies":{"typescript":"^5.7.2","vitest":"^3.2.6"},"gitHead":"2a2bcc28a842ce745afb423aab12830d52866b6b","_id":"@agops-labs/sdk@0.2.0","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-9EF4cxFLzeAIG2X52StW3aiBjEtRvlWTLyQW5Ng+PM9sox8+hS1CeHBCS7UK5Yn8NyzEJzllx6GMhx0uQBcjFA==","shasum":"7c4317362b5448018647dd61782b57de0621bb37","tarball":"https://registry.npmjs.org/@agops-labs/sdk/-/sdk-0.2.0.tgz","fileCount":9,"unpackedSize":22978,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB/2kWFeWDq4KbnPAzy3L7s2ompWKT35+/lwVGHM2pJgAiB1faUKNaB+0Vqz2U5YYkd4IzBCqNTcTFzgbKH1/G+WZw=="}]},"_npmUser":{"name":"kaushalya4s5s7","email":"chaudharikaushal02@gmail.com"},"directories":{},"maintainers":[{"name":"kaushalya4s5s7","email":"chaudharikaushal02@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.2.0_1785049724137_0.8489214741255127"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-24T11:10:13.826Z","modified":"2026-07-26T07:08:44.449Z","0.1.0":"2026-07-24T11:10:14.123Z","0.2.0":"2026-07-26T07:08:44.272Z"},"license":"MIT","keywords":["agentops","casper","ai-agents","x402","mcp","policy","web3","payments"],"description":"AgentOps SDK — REST + MCP client for the AgentOps (Casper-AGOPS) policy-firewall proxy. Authorize AI-agent payments and on-chain actions with enforced spend caps and on-chain audit anchoring.","maintainers":[{"name":"kaushalya4s5s7","email":"chaudharikaushal02@gmail.com"}],"readme":"# @agops-labs/sdk\n\nThin REST + MCP client for the AgentOps (Casper-AGOPS) proxy. Phase 2, Milestone F.3 (D-4).\n\n**No private key ever touches this SDK.** The agent holds an `ag_` API key and asks the proxy for\npermission; policy is evaluated and the payment is signed server-side, inside the vault. A\ncompromised agent can be denied or revoked instantly — it never held the key that would let it pay\nwithout asking.\n\n## Guarded fetch (recommended)\n\nA drop-in `fetch` that handles the whole x402 handshake — call the service, get a 402, check policy,\nattach the signed header, retry — so you write one call instead of five steps:\n\n```ts\nimport { createGuardedFetch, PaymentDeniedError } from '@agops-labs/sdk';\n\nconst guardedFetch = createGuardedFetch({\n  baseUrl: 'https://your-proxy.example',\n  apiKey: 'ag_live_...',\n  agentId: 'agt_...',            // must be the agent this key belongs to\n  onDecision: (d) => console.log('decision', d.decisionId),   // optional audit hook\n});\n\nconst res = await guardedFetch('https://svc.example/risk-oracle/score', {\n  method: 'POST',\n  headers: { 'content-type': 'application/json' },\n  body: JSON.stringify({ pair: 'CSPR-USDC', side: 'buy', size_motes: '1000000000' }),\n});\nconst data = await res.json();   // paid 200\n```\n\nNon-402 responses pass through untouched, so this is safe as the only `fetch` in an agent — free\nendpoints and errors behave exactly as the platform `fetch` does.\n\nWhen policy refuses, it throws `PaymentDeniedError` with the reason rather than returning a\nconfusing 402:\n\n```ts\ntry {\n  await guardedFetch(SERVICE_URL);\n} catch (err) {\n  if (err instanceof PaymentDeniedError) {\n    console.log(err.reason);      // e.g. 'spend_cap_exceeded', 'service_not_allowed'\n    console.log(err.decisionId);  // audit id for this refusal\n  }\n}\n```\n\n`PaymentDeniedError` means policy worked correctly. `PaymentFlowError` is the different case where\nthe call never reached policy — a bad key, a tenant mismatch, or a malformed challenge.\n\nIdempotency keys are generated per payment automatically. Pass `idempotencyKey: () => yourKey` only\nif you need to control retry semantics yourself — reusing one key across different payments makes\nthe server return the first decision again.\n\n## REST client\n\nUse this when you want to drive the steps yourself (or authorize a `cspr-trade` / `casper-deploy` /\n`evm-transfer` action rather than pay for an HTTP resource).\n\n```ts\nimport { createAgentOpsClient } from '@agops-labs/sdk';\n\n// Operator (sk_) client — fleet management.\nconst operator = createAgentOpsClient({ baseUrl: 'https://your-proxy.example', apiKey: 'sk_live_...' });\nconst { agent, api_key } = await operator.createAgent({ name: 'Trader' });\nawait operator.attachTradingFlow({ orgId: 'org_1', flow: compiledFlow, roleAssignments: { trader: agent.id } });\nawait operator.revokeAgent({ agentId: agent.id });\nconst decision = await operator.getDecision('cgd_...');\n\n// Agent (ag_) client — authorize a payment or on-chain action.\nconst asAgent = createAgentOpsClient({ baseUrl: 'https://your-proxy.example', apiKey: api_key });\n\n// Sync by default (D-4④): returns the ALLOW/DENY body directly.\nconst result = await asAgent.authorize({\n  kind: 'x402-payment',\n  agentId: agent.id,\n  idempotencyKey: 'idem_1',\n  paymentRequired: rawPaymentRequiredBodyFrom402Response,\n});\n\n// Async opt-in: get a pollable decisionId immediately instead.\nconst { decisionId } = await asAgent.authorize(sameInput, { async: true });\nconst status = await operator.getDecision(decisionId);\n```\n\n## MCP client\n\nFor agent frameworks (LangChain, CrewAI, ...) that consume the proxy as MCP tools instead of raw\nREST:\n\n```ts\nimport { createAgentOpsMcpClient } from '@agops-labs/sdk';\n\nconst mcp = createAgentOpsMcpClient({ url: 'https://your-proxy.example/v1/casper-guard/mcp', apiKey: 'ag_live_...' });\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('casper_guard_authorize_payment', {\n  agent_id: agent.id,\n  idempotency_key: 'idem_1',\n  payment_required: rawPaymentRequiredBody,\n});\n```\n\nNote: `casper_guard_create_agent`, `casper_guard_attach_trading_flow`, and `casper_guard_revoke_agent`\nare OPERATOR-scoped tools — call `createAgentOpsMcpClient` with an `sk_` key for those, not an\nagent's `ag_` key.\n\n## One client per credential\n\nA single client instance uses one API key. The server scopes `sk_` (operator) vs `ag_` (agent)\nroutes separately — construct two client instances if your code needs both.\n","readmeFilename":"README.md"}