Node.js SDK

Node.js SDK

Send decision requests from your Node.js agent system

Download

Installation


  npm install @noxy-network/node-sdk@2.2.0
  # or
  yarn add @noxy-network/node-sdk@2.2.0
  # or
  pnpm add @noxy-network/node-sdk@2.2.0
  
Code

Quick Start


  import { initNoxyAgentClient, NoxyHumanDecisionOutcome } from '@noxy-network/node-sdk';

  const client = await initNoxyAgentClient({
    endpoint: 'https://relay.noxy.network',
    authToken: '__your-api-token__',
    decisionTtlSeconds: 3600,
  });

  const proposedAction = {
    kind: 'propose_tool_call',
    tool: 'transfer_funds',
    args: { to: '__your-burn-address__', amountWei: '1' },
    title: 'Transfer 1 wei to the burn address',
    summary: 'The agent is requesting approval to send 1 wei to the burn address.',
  };

  // identity_id: wallet (0x…), email, phone (E.164), or user_id string
  const identityId = 'user@example.com';

  const resolution = await client.sendDecisionAndWaitForOutcome(identityId, proposedAction, {
    maxWaitMs: 5 * 60 * 1000,
  });
  if (resolution?.outcome === NoxyHumanDecisionOutcome.APPROVED) {
    // your agent should proceed the action
  } else {
    // your agent should abort the action
  }