Skip to content

Knapsack

Validated file reads, edits and patches for an Agent's Computer, for TypeScript services that host their own Agent runtime.

  • @fungi.computer/knapsack
  • v0.4.0
  • MIT

Fastest path

  1. Install

    Add it to your project with npm, pnpm, Yarn or Bun.

    TERMINAL
    npm install @fungi.computer/knapsack
  2. Validate a Files read request

    Validates a bounded Files read request with the same Zod schema the Files module uses, then rejects one whose page limit is too small.

    home.ts
    import { readInputSchema } from "@fungi.computer/knapsack";
    const request = readInputSchema.parse({
    path: "notes.md",
    offset: 0,
    limit: 4,
    });
    console.log(request); // { path: "notes.md", offset: 0, limit: 4 }
    console.log(readInputSchema.safeParse({ path: "notes.md", limit: 1 }).success); // false: limit too small