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 🙏

© 2026 – Pkg Stats / Ryan Hefner

funky-sdk

v0.3.0

Published

The official TypeScript SDK for Funky

Readme

Funky TypeScript SDK

The TypeScript client for building and running agents with Funky. It provides typed APIs for agents, environments, sessions, and session events.

The SDK is currently an alpha. It covers Funky's /v1 data-plane API and intentionally does not expose organization, project, membership, API-key, or other /console/v1 administration APIs.

Installation

npm install funky-sdk

Funky supports Node.js 20 and newer.

Quick start

Set an API key provisioned through Funky:

export FUNKY_API_KEY=fk_...

Then create reusable agent and environment configurations and start a session:

import { Funky } from "funky-sdk";

const funky = new Funky();

const agent = await funky.agents.create({
  name: "Repository investigator",
  system_prompt: "You are a careful coding agent. Verify claims with tools.",
  model: { provider: "anthropic", model: "claude-sonnet-5" },
  tool_policy: { max_iterations: 20 },
});

const environment = await funky.environments.create({
  name: "github-access",
  network: {
    type: "limited",
    allowed_hosts: ["github.com", "*.githubusercontent.com"],
  },
});

const session = await funky.sessions.create({
  agent: agent.id,
  environment_id: environment.id,
  title: "Investigate issue 42",
});

await funky.sessions.waitUntilReady(session.id);

const result = await funky.sessions.runTurn(session.id, {
  content: "Inspect the repository and identify the root cause.",
});

console.log(result.output_text);
funky.close();

Create agents and environments during application setup and retain their IDs. A new session is appropriate for each independent run or durable conversation.

Public model and parameter fields use the API's snake_case spelling. Resource methods use normal TypeScript camelCase. Python-style aliases such as send_message, list_events, and wait_until_ready are also available when sharing examples between Funky SDKs.

Resource APIs

The client exposes:

funky.agents.create(...)
funky.agents.list(...)
funky.agents.iter(...)
funky.agents.retrieve(agentId)
funky.agents.update(agentId, ...)
funky.agents.archive(agentId)
funky.agents.listVersions(agentId, ...)
funky.agents.iterVersions(agentId, ...)
funky.agents.retrieveVersion(agentId, version)

funky.environments.create(...)
funky.environments.list(...)
funky.environments.iter(...)
funky.environments.retrieve(environmentId)
funky.environments.update(environmentId, ...)
funky.environments.archive(environmentId)
funky.environments.delete(environmentId)

funky.sessions.create(...)
funky.sessions.list(...)
funky.sessions.iter(...)
funky.sessions.retrieve(sessionId)
funky.sessions.archive(sessionId)
funky.sessions.sendMessage(sessionId, ...)
funky.sessions.runTurn(sessionId, ...)
funky.sessions.listEvents(sessionId, ...)
funky.sessions.iterEvents(sessionId, ...)
funky.sessions.streamEvents(sessionId, ...)
funky.sessions.waitUntilReady(sessionId, ...)
funky.sessions.waitForTurn(sessionId, ...)

Create operations generate a stable UUID by default, making the request safe to retry. Pass id explicitly when the caller needs to control that UUID.

Pagination

Use list() when page metadata matters, or consume the auto-paginating async iterator:

for await (const agent of funky.agents.iter({ include_archived: true })) {
  console.log(agent.id, agent.name);
}

for await (const event of funky.sessions.iterEvents(session.id, {
  after_seq: 0,
})) {
  console.log(event.seq, event.type);
}

Live events

streamEvents() replays persisted events and follows the live SSE stream. It automatically reconnects from the last consumed sequence and deduplicates replayed events.

import { isSessionEvent } from "funky-sdk";

const controller = new AbortController();
const stream = funky.sessions.streamEvents(session.id, {
  after_seq: 0,
  signal: controller.signal,
});

try {
  for await (const event of stream) {
    if (isSessionEvent(event, "assistant_message")) {
      // Process content or tool calls.
    } else if (isSessionEvent(event, "turn_completed")) {
      break;
    } else if (isSessionEvent(event, "turn_failed")) {
      throw new Error(event.payload.message);
    }
  }
} finally {
  stream.close();
}

Heartbeat comments are ignored. Unknown future event, content-block, and tool-call variants do not fail parsing; their original data is available through raw.

Errors

All SDK errors extend FunkyError:

FunkyError
├── APIConnectionError
│   └── APITimeoutError
├── APIStatusError
│   ├── BadRequestError
│   ├── AuthenticationError
│   ├── PermissionDeniedError
│   ├── NotFoundError
│   ├── ConflictError
│   ├── RateLimitError
│   └── InternalServerError
└── TurnFailedError

APIStatusError retains status_code, error_type, code, request_id, response headers, and a safely redacted response body. TurnFailedError retains the event's error_class, session_id, and seq.

Automatic retries are conservative: reads, stable-ID creates, and archive operations retry transient failures; updates and messages do not retry after ambiguous failures. SSE streams reconnect from the last yielded event.

Client configuration

const funky = new Funky({
  apiKey: "fk_...",                 // defaults from FUNKY_API_KEY
  baseURL: "https://api.funky.dev",
  timeout: 30,                     // seconds
  maxRetries: 2,
  userAgent: "my-service/1.0",
  fetch: customFetch,              // useful for custom transports and tests
});

timeoutMs is available when millisecond configuration is more convenient. close() aborts active requests and event streams. The client never includes the API key in its string representation or API exceptions.