Skip to content

Node.js client wrapper for TokenOps #122

Description

@susheem-k

Summary

We'd like an official Node.js/TypeScript wrapper for TokenOps, mirroring the ergonomics of the Python SDK (tokenops_run, wrap_complete, register_run, crossing hooks, control-plane integration via TOKENOPS_URL).

Motivation

TokenOps currently ships a Python integration. A Node.js wrapper would let JS/TS-based agent frameworks (LangChain.js, Vercel AI SDK, custom Node agents, etc.) get the same run-aware spend caps, halt/steer hooks, and per-agent cost attribution without reimplementing the protocol from scratch.

Rough scope

  • Package under @tokenops/node (or similar) publishable to npm
  • Equivalent of tokenops_run context manager (likely an async-friendly wrapper/decorator)
  • wrap_complete-style helper for wrapping LLM call sites (OpenAI/Anthropic SDKs, etc.)
  • register_run and crossing-hook support talking to the same control-plane HTTP API used by the Python client
  • Respect TOKENOPS_URL env var / config for pointing at a control plane instance
  • Basic examples (single script, LangChain.js agent)
  • Type definitions (TypeScript-first)

Notes

Happy to point contributors at the Python implementation and control-plane API as reference. This is a good "help wanted" item if anyone in the Node ecosystem wants to drive the wrapper design — open to discussion on API shape before implementation starts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions