# Quickstart: TypeScript, plain functions

## 1. Install

```bash
npm install signafaide        # or: pnpm add / yarn add / bun add
```

## 2. Wrap the tools that act

```ts
import { note, record, wrapTools } from "signafaide";

const approvePayout = record(async (claimId: string, amount: number) => {
  /* ... */
}, { name: "approve_payout" });

// or wrap existing functions (object key = recorded name):
const tools = wrapTools({ approve_payout: approvePayout, escalate });

// a decision that is not a tool call:
note("routing", { reason: "amount over limit" });
```

Every call of a wrapped tool writes a signed `decision` record before it runs and an `outcome` record after it (the result, or the error, which is raised again unchanged). Records are signed and chained in `.signafaide/` on your machine, and nothing is sent until you opt in (step 4).

## 3. Verify

Run the agent once, then:

```bash
npx signafaide verify
```

One line per check, then a result line that says how many of the 12 checks passed, are pending and were not checked, for example `PASS: 4 of 12 checks passed, 8 not checked (nothing co-signed yet)` before anything is sent, and what still needs a witness (co-signature, public timestamp). A check that was not run is never counted as passed. See [Verify](/docs/verify) for what each check means.

## 4. Send hashes to a witness (when you choose)

```bash
npx signafaide init
```

creates a free sandbox (no account, email or card), saves `SIGNAFAIDE_API_KEY` to `.env` (and adds `.env` to `.gitignore`) and prints a link to claim it. Only salted hashes are sent, never inputs or outputs; records written before ship with their original times, if they are at most 7 days old. To keep the evidence in your environment, [self-host the witness](/docs/self-host) and set `SIGNAFAIDE_URL`.

Other quickstarts: [Python, plain functions](/docs/quickstart/python) · [Python, LangChain](/docs/quickstart/python-langchain) · [Python, OpenAI Agents SDK](/docs/quickstart/python-openai-agents) · [TypeScript, LangChain](/docs/quickstart/typescript-langchain) · [TypeScript, OpenAI Agents SDK](/docs/quickstart/typescript-openai-agents) · [TypeScript, Vercel AI SDK](/docs/quickstart/typescript-vercel-ai).
