open-index/open-npm huggingface dataset:
npm package: @infektweb/injectjs
Latest version: 0.0.4

injectjs
========

Helper methods to:
  - Inject a javascript tag with some javascript into a html file
  - Inject environment variables into html as env.ENV_VAR = "X"

Inject js
---------

    import { injectJs } from '@infektweb/injectjs'

    injectJs('<html><head></head><body></body></html>', 'alert("FOO")')
    // <html><head><script type="javascript">alert("FOO")</script></head><body></body></html>

Inject env
----------

    import { injectEnv } from '@infektweb/injectjs'

    injectEnv('<html><head></head><body></body></html>', {
      Foo: 'foo',
      TERM: 'foo',
    })
    // <html><head><script type="javascript">
    // window.env = {};
    // window.env.FOO = 'foo';
    // window.env.TERM = 'xterm-256color';
    // </script></head><body></body></html>
npm package: @inferable/chat
Description: Chat CLI for inferable.ai
Author: Inferable, Inc.
Latest version: 0.0.6

## Inferable Chat

A React-based chat interface for Inferable, available both as a CLI tool and a React component.

## CLI Usage

### Installation

```bash
npm install -g @inferable/chat
```

This will make the `inf-chat` command available globally.

### Basic Usage

```bash
inf-chat \
  --api-secret your_api_secret \
  --cluster-id your_cluster_id \
  [--agent-id your_agent_id] \
  [--run-id existing_run_id]
```

### Environment Variables
All flags can also be set via environment variables:
- `INFERABLE_API_SECRET`
- `INFERABLE_CLUSTER_ID` 
- `INFERABLE_AGENT_ID`

Flags take precedence over environment variables.

### Using with npx
```bash
npx @inferable/chat --api-secret your_api_secret --cluster-id your_cluster_id
```

## Library Usage

### Installation

```bash
npm install @inferable/chat
```

### Usage as a React Component

```tsx
import { ChatInterface } from '@inferable/chat';

function MyApp() {
  return (
    <ChatInterface
      apiSecret="your-api-secret"
      clusterId="your-cluster-id"
      runId="optional-run-id"
      agentId="optional-agent-id"
    />
  );
}
```

## Local Development

```bash
npm run dev
```
npm package: @inferable/cli
Description: CLI for inferable.ai
Author: Inferable, Inc.
Latest version: 0.24.13

## Inferable CLI

## Installation

```bash
npm install -g @inferable/cli
```

This will make the `inf` command available globally.

Alternatively, use the CLI with `npx`:

```bash
npx @inferable/cli <cmd>
```

## Usage

### Authentication

To authenticate the CLI, run `inf auth login`.
This will open a browser and prompt you to login to the Inferable console.

### Environment

The CLI respects use the following environment variables if available:

- `INFERABLE_API_ENDPOINT`: The Inferable API endpoint to use (See [self-hosting guide](https://docs.inferable.ai/pages/self-hosting)).
- `INFERABLE_CLUSTER_ID`: Cluster related commands will automatically use this cluster.

### Commands

- **inf clusters**: Manage Inferable clusters.

  - `create`: Create a new cluster.
  - `list`: List all clusters.
  - `info`: Show details of a cluster.
  - `open`: View a cluster in the browser.

- **inf runs**: Manage runs associated with your clusters.

  - `create`: Create a new run and follow its progress.
  - `list`: List runs within a cluster.
  - `info`: Display information about a specific run.
  - `open`: View a run in the browser.

- **inf auth**: Authenticate with the Inferable API.

  - `login`: Start the authentication process.
  - `keys`: Manage API keys.
    - `list`: List all API keys for a cluster.
    - `revoke`: Revoke a specific API key.
    - `create`: Create a new API key.

- **ing generate**: Generate functions for GraphQL and OpenAPI schemas.

  - `graphql`: Generate functions from a GraphQL schema.
  - `openapi`: Generate functions from an OpenAPI schema.

- **inf cli**: Manage the Inferable CLI itself.

  - `update`: Update the Inferable CLI.

- **inf app**: Open the Inferable app in a browser.

Use `inf <cmd> --help` to get details for a specific command.

## Local Development

All commands can be run with tsx:

```bash
tsx src/index.ts <cmd>
tsx src/index.ts auth login
```
npm package: @inferable/demo
Description: Inferable service demo with SQL and terminal copilot
Author: Inferable
Latest version: 0.0.25

# @inferable/demo

A demonstration of Inferable services including a terminal copilot and SQL-to-text functionality.

## Installation

```bash
npm install @inferable/demo
```

## Usage

This package requires Node.js 18 or later. Run the service using:

```bash
npx tsx index.ts
```

Or use the provided npm scripts:

```bash
# Start the service
npm start

# Start with watch mode for development
npm run dev
```

## Environment Variables

Make sure to set your Inferable API secret in an environment variable:

```bash
export INFERABLE_API_SECRET=your_secret_here
```

## License

MIT
npm package: @infercost/express
Description: Express middleware for automatic InferCost feature attribution
Latest version: 0.1.0

# @infercost/express

Express middleware for automatic InferCost feature attribution. Captures the current route as the feature name so every AI API call made during a request is automatically tagged.

## Getting Started

```bash
npm install @infercost/express
```

### 1. Add the middleware

```ts
import express from "express";
import { infercostMiddleware, setCustomer } from "@infercost/express";

const app = express();

// Add InferCost middleware — captures route as feature name
app.use(infercostMiddleware());

// Optionally set the customer after auth
app.use((req, res, next) => {
  setCustomer(req.user.id); // or however you identify your customer
  next();
});
```

### 2. Pass headers to your AI SDK

```ts
import OpenAI from "openai";
import { getInferCostHeaders } from "@infercost/express";

const openai = new OpenAI({
  baseURL: "https://gateway.infercost.dev/openai/v1",
  defaultHeaders: {
    "X-InferCost-Key": process.env.INFERCOST_KEY!,
  },
});

app.post("/api/summarize", async (req, res) => {
  const result = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: req.body.text }],
  }, {
    headers: getInferCostHeaders(), // → { "X-InferCost-Feature": "POST /api/summarize" }
  });

  res.json(result);
});
```

The feature will appear as `POST /api/summarize` in your InferCost dashboard.

## API

### `infercostMiddleware()`

Returns an Express middleware that captures the route as the feature name using `AsyncLocalStorage`.

**Important:** `req.route` is only available _after_ Express has matched a route. When registered as global middleware (before your routes), `req.route` is `undefined` and the middleware falls back to `req.path` — the literal URL path including dynamic segments (e.g. `/users/42` instead of `/users/:id`).

**Recommended patterns:**

1. **Register per-router** (after route matching):
   ```ts
   const usersRouter = express.Router();
   usersRouter.use(infercostMiddleware()); // req.route is available here
   usersRouter.post("/:id/summarize", handler);
   app.use("/users", usersRouter);
   ```

2. **Call `setFeature()` manually** in each handler:
   ```ts
   app.post("/users/:id/summarize", (req, res) => {
     setFeature("POST /users/:id/summarize");
     // ... call AI API
   });
   ```

### `setFeature(name: string)`

Override the auto-detected feature name for the current request. Use this when you need explicit control over the feature name.

### `getInferCostHeaders()`

Returns the attribution headers for the current request context. Returns an empty object if called outside a request.

### `setCustomer(customerId: string)`

Sets the customer ID for the current request context. Call this after authenticating the user.
npm package: @infercost/next
Description: Next.js middleware for automatic InferCost feature attribution
Latest version: 0.1.0

# @infercost/next

Next.js middleware for automatic InferCost feature attribution. Captures the current API route as the feature name so every AI API call is automatically tagged.

## Getting Started

```bash
npm install @infercost/next
```

## Pages Router (`/pages/api/`)

Wrap your API route handler with `withInferCost`:

```ts
// pages/api/summarize.ts
import type { NextApiRequest, NextApiResponse } from "next";
import OpenAI from "openai";
import { withInferCost, getInferCostHeaders, setCustomer } from "@infercost/next";

const openai = new OpenAI({
  baseURL: "https://gateway.infercost.dev/openai/v1",
  defaultHeaders: { "X-InferCost-Key": process.env.INFERCOST_KEY! },
});

export default withInferCost(async (req: NextApiRequest, res: NextApiResponse) => {
  setCustomer(req.headers["x-user-id"] as string);

  const result = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: req.body.text }],
  }, {
    headers: getInferCostHeaders(), // → { "X-InferCost-Feature": "POST /api/summarize" }
  });

  res.json(result);
});
```

## App Router (`/app/api/`)

Wrap your route handler with `withInferCostApp`:

```ts
// app/api/summarize/route.ts
import OpenAI from "openai";
import { withInferCostApp, getInferCostHeaders, setCustomer } from "@infercost/next";

const openai = new OpenAI({
  baseURL: "https://gateway.infercost.dev/openai/v1",
  defaultHeaders: { "X-InferCost-Key": process.env.INFERCOST_KEY! },
});

export const POST = withInferCostApp(async (req) => {
  const body = await req.json();
  setCustomer(body.userId);

  const result = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: body.text }],
  }, {
    headers: getInferCostHeaders(), // → { "X-InferCost-Feature": "POST /api/summarize" }
  });

  return Response.json(result);
});
```

## Edge Middleware (optional)

For automatic route tagging at the middleware level:

```ts
// middleware.ts
import { infercostMiddleware } from "@infercost/next";
export const middleware = infercostMiddleware();
```

## API

### `withInferCost(handler)`

HOC for Pages Router API routes. Captures `req.method + req.url` as the feature name.

### `withInferCostApp(handler)`

HOC for App Router route handlers. Captures `req.method + pathname` as the feature name.

### `infercostMiddleware()`

Edge-compatible middleware for `middleware.ts`. Reads the `x-matched-path` header for the route name.

### `getInferCostHeaders()`

Returns attribution headers for the current request context.

### `setCustomer(customerId: string)`

Sets the customer ID for the current request context.
npm package: @inference-net/tokenizers
Description: Multi-arch builds of HuggingFace tokenizers
Latest version: 0.2.1

# @inference-net/tokenizers

The official Node bindings are in a jinx with limited support for Node versions and architectures. This package offers multi-arch bindings for [@huggingface/tokenizers](https://github.com/huggingface/tokenizers) with Node v20.x supported.

## Supports:

> - Windows x86_64
> - Linux x86_64
> - MacOS aarch64/x86_64

## Installation

```bash
npm install @inference-net/tokenizers
```

## Features

- Train new vocabularies and tokenize using 4 pre-made tokenizers (Bert WordPiece and the 3
  most common BPE versions).
- Extremely fast (both training and tokenization), thanks to the Rust implementation. Takes
  less than 20 seconds to tokenize a GB of text on a server's CPU.
- Easy to use, but also extremely versatile.
- Designed for research and production.
- Normalization comes with alignments tracking. It's always possible to get the part of the
  original sentence that corresponds to a given token.
- Does all the pre-processing: Truncate, Pad, add the special tokens your model needs.

## Basic example

```ts
import { Tokenizer } from "@inference-net/tokenizers";

const tokenizer = await Tokenizer.fromFile("tokenizer.json");
const wpEncoded = await tokenizer.encode("Who is John?");

console.log(wpEncoded.getLength());
console.log(wpEncoded.getTokens());
console.log(wpEncoded.getIds());
console.log(wpEncoded.getAttentionMask());
console.log(wpEncoded.getOffsets());
console.log(wpEncoded.getOverflowing());
console.log(wpEncoded.getSpecialTokensMask());
console.log(wpEncoded.getTypeIds());
console.log(wpEncoded.getWordIds());
```

## License

[MIT](LICENSE)
npm package: @inferevents/skills
Description: Agent skills for Infer analytics — setup wizard, data interpretation, automated insights, and tracking plan generation
Latest version: 0.1.0

# Infer Skills

Agent skills for [Infer](https://infer.events) — headless analytics for AI-first developers.

## Install

```
npx skills add @inferevents/skills
```

Then run `/infer-setup` in Claude Code. The wizard handles everything:
- Creates your Infer account
- Installs the MCP server
- Installs the SDK in your project
- Detects your framework and adds tracking
- Verifies events are flowing

## Skills included

| Skill | Command | What it does |
|-------|---------|-------------|
| **infer-setup** | `/infer-setup` | Full setup wizard — signup, install, integrate, verify |
| **infer-analytics** | Auto-loaded when querying | Teaches agents to interpret retention, funnels, benchmarks |
| **infer-insights** | "Give me insights" | Automated discovery of top 5 impactful findings |
| **infer-tracking-plan** | "What should I track?" | Reads your codebase, proposes events with file:line references |

## How it works

```
You: "What's my retention?"

Agent reads infer-analytics skill, calls get_retention MCP tool, interprets:

  Retention: signup → page_view
  weekly cohorts | last_30d

  Mar 3 (142 users)
    week 0  █████████████████████████  100%
    week 1  ██████████░░░░░░░░░░░░░░░  42% 🟢
    week 4  ███░░░░░░░░░░░░░░░░░░░░░░  12% 🔴

  Week-4 is 12%, below the 20% B2C benchmark.
  Check your onboarding flow.

  💡 Dig deeper: ask "Show me the journey of a user who churned"
```

## Architecture

```
Skills (this package)          MCP Server (@inferevents/mcp)       SDK (@inferevents/sdk)
~/.claude/skills/infer/        Connected as MCP server              Installed in your app

infer-setup     ──────────►    get_event_counts                     init()
infer-analytics ──────────►    get_retention        ◄──────────     track()
infer-insights  ──────────►    get_user_journey                     identify()
infer-tracking-plan            get_top_events                       page()
```

Skills teach the agent WHAT to do. MCP tools do the actual queries. SDK collects the data.