npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@veritone/agent-sdk

v0.1.8-next.2

Published

## Description The `@veritone/agent-sdk` is a TypeScript SDK designed to serve as a client for the `veri-agents-api` Python package (and its associated API surface). It provides core modules for managing agent execution `thread`s, along with React-specifi

Downloads

382

Readme

@veritone/agent-sdk

Description

The @veritone/agent-sdk is a TypeScript SDK designed to serve as a client for the veri-agents-api Python package (and its associated API surface). It provides core modules for managing agent execution threads, along with React-specific hooks.

Features

  • veri-agents-api Client: Seamlessly interact with the backends using veri-agents-api.
  • Agent Thread Management: Core functionalities for creating and managing agent execution threads.
  • React Integration: Dedicated React hooks for easily incorporating agent functionalities into your React projects.
  • TypeScript Support: Fully typed for a robust development experience, with types generated directly from the OpenAPI specification of veri-agents-api.

Installation

You can install the SDK using npm or yarn:

npm install @veritone/agent-sdk
# or
yarn add @veritone/agent-sdk

Usage

Core Thread Module

To interact with APIs utilizing veri-agents-api, instantiate AgentThreadApiClient:

import { AgentThreadApiClient } from '@veritone/agent-sdk/thread';

const apiClient = new AgentThreadApiClient({
  url: 'http://localhost:5002', // Your veri-agents-api endpoint
  // Optional: Add an interceptor for authentication or other request modifications
  interceptor: (config) => {
    // config.headers.Authorization = `Bearer YOUR_TOKEN`;
    return config;
  },
});

// Example: Get chat history
apiClient.getHistory().then(history => {
  console.log('Chat History:', history);
});

// Example: Invoke the agent
apiClient.invoke({
  thread_id: 'my-thread-id',
  message: 'Hello, agent!',
}).then(response => {
  console.log('Agent Response:', response);
});

// Example: Stream agent response
async function streamResponse() {
  for await (const event of apiClient.stream({ thread_id: 'my-thread-id', message: 'Tell me a story.' })) {
    console.log('Stream Event:', event);
  }
}
streamResponse();

React Integration

Context

For React applications, use the provided hooks. First, set up the AgentThreadApiClientContext provider:

// App.tsx or your main application file
import React from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { AgentThreadApiClient } from '@veritone/agent-sdk/thread';
import { AgentThreadApiClientProvider } from '@veritone/agent-sdk/thread/react';
import MyAgentComponent from './MyAgentComponent'; // Your component using the hooks

const client = new AgentThreadApiClient({
  url: 'http://localhost:5002/chat', // Your veri-agents-api endpoint - this example assumes thread_router has prefix /chat
});

function App() {
  return (
    <AgentThreadApiClientProvider client={client}>
      <MyAgentComponent />
    </AgentThreadApiClientProvider>
  );
}

export default App;
Passing thread ids
function App({ threadId }: { threadId: string }) {
  // create a new threadClient for each threadId
  const threadClient = useMemo(() => {
    return new AgentThreadApiClient({
      url: `http://localhost:5002/chat/${threadId}`  // Your veri-agents-api endpoint - this example assumes thread_router has prefix /chat/{threadId}
    });
  }, [threadId]);

  return (
    <AgentThreadApiClientProvider client={threadClient}>
        <MyAgentComponent />
    </AgentThreadApiClientProvider>
  );
}

Hooks

In your components, you can use useGetHistorySuspenseQuery and useInvokeStreamMutation:

Looking for preconfigured UI components?

Check out @veritone/chat-ui

// MyAgentComponent.tsx
import React from 'react';
import { useGetHistorySuspenseQuery, useInvokeStreamMutation } from '@veritone/agent-sdk/thread/react';

function MyAgentComponent() {
  const { data: history } = useGetHistorySuspenseQuery();
  const { mutate: invokeStream, isPending } = useInvokeStreamMutation();

  const handleSendMessage = (message: string) => {
    invokeStream({ thread_id: 'my-react-thread', message });
  };

  return (
    <div>
      <h1>Agent Chat</h1>
      <div>
        {history?.map((msg, index) => (
          <p key={index}><strong>{msg.type}:</strong> {msg.content}</p>
        ))}
      </div>
      <input
        type="text"
        placeholder="Type your message..."
        onKeyDown={(e) => {
          if (e.key === 'Enter' && !isPending) {
            handleSendMessage(e.currentTarget.value);
            e.currentTarget.value = '';
          }
        }}
        disabled={isPending}
      />
      <button onClick={() => handleSendMessage('Hello!')} disabled={isPending}>
        Send
      </button>
      {isPending && <p>Agent is thinking...</p>}
    </div>
  );
}

export default MyAgentComponent;

Development

To set up the development environment and contribute to the SDK:

Install dependencies

pnpm install

Build the project

pnpm run build

Run type checking

pnpm run typecheck

Format code

pnpm run format

Lint code

pnpm run lint

Run tests

pnpm run vitest

Generate TypeScript API types

This command generates TypeScript types from the OpenAPI specification provided by the veri-agents-api. Ensure the veri-agents-api is running locally and accessible at http://localhost:5002.

npm run generate:ts:api