Skip to main content
Home

latest
Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads1,728/wk
Published2 years ago (0.1.1)

Game definitions for https://gameplay.computer

function agentHandler
agentHandler<T extends Json = Json>(agents: AgentSpec<T>[]): (req: Request) => Promise<Response>

Create standard fetch handler for an agent.

Takes a list of agents and returns a handler that can be used to create an agent http endpoint. The handler implements the standard fetch interface and can be used with a variety of different http server libraries.

To see how to write the agent functions, see the Connect4Agent and PokerAgent

Type Parameters

T extends Json = Json

The type of the agent data.

  • Must extend Json which restricts it to a JSON serializable type.

Parameters

agents: AgentSpec<T>[]
  • The agents to register. Multiple agents can be registered so you can have multiple agents served by the same http service.

Return Type

An async handler that can be used with an http server that supports the fetch interface.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";
or

Import directly with a jsr specifier

import { agentHandler } from "jsr:@gameplay/games/agent";

Add Package

pnpm i jsr:@gameplay/games
or (using pnpm 10.8 or older)
pnpm dlx jsr add @gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";

Add Package

yarn add jsr:@gameplay/games
or (using Yarn 4.8 or older)
yarn dlx jsr add @gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";

Add Package

vlt install jsr:@gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";

Add Package

npx jsr add @gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";

Add Package

bunx jsr add @gameplay/games

Import symbol

import { agentHandler } from "@gameplay/games/agent";