├── demos
├── mcp-client
│ ├── public
│ │ └── normalize.css
│ ├── .dev.vars.example
│ ├── index.html
│ ├── vite.config.ts
│ ├── get-subdomain.sh
│ ├── wrangler.json
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── server.ts
├── remote-mcp-server
│ ├── static
│ │ └── img
│ ├── img
│ │ ├── mcp-login.png
│ │ ├── available-tools.png
│ │ ├── mcp-inspector-sse-config.png
│ │ ├── mcp-inspector-oauth-success.png
│ │ ├── claude-does-math-the-fancy-way.png
│ │ └── mcp-inspector-successful-tool-call.png
│ ├── tsconfig.json
│ ├── package.json
│ ├── wrangler.jsonc
│ └── src
│ │ └── index.ts
├── mcp-server-bearer-auth
│ ├── static
│ │ └── img
│ ├── .DS_Store
│ ├── img
│ │ ├── mcp-login.png
│ │ ├── available-tools.png
│ │ ├── mcp-inspector-sse-config.png
│ │ ├── mcp-inspector-oauth-success.png
│ │ ├── claude-does-math-the-fancy-way.png
│ │ └── mcp-inspector-successful-tool-call.png
│ ├── tsconfig.json
│ ├── package.json
│ └── wrangler.jsonc
├── remote-mcp-server-autorag
│ ├── static
│ │ └── img
│ ├── img
│ │ ├── mcp-login.png
│ │ ├── available-tools.png
│ │ ├── mcp-inspector-sse-config.png
│ │ ├── mcp-inspector-oauth-success.png
│ │ ├── claude-does-math-the-fancy-way.png
│ │ └── mcp-inspector-successful-tool-call.png
│ ├── tsconfig.json
│ ├── package.json
│ └── wrangler.jsonc
├── image-generation
│ ├── README.md
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── wrangler.jsonc
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ └── package.json
├── remote-mcp-server-descope-auth
│ ├── static
│ │ └── img
│ ├── .gitignore
│ ├── img
│ │ └── mcp-inspector-sse-config.png
│ ├── .dev.vars.example
│ ├── tsconfig.json
│ └── package.json
├── ui-worker
│ ├── src
│ │ ├── client
│ │ │ ├── vite-env.d.ts
│ │ │ ├── index.html
│ │ │ ├── main.tsx
│ │ │ └── App.css
│ │ └── server
│ │ │ └── types
│ │ │ └── hono.ts
│ ├── vitest.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── postcss.config.cjs
│ ├── wrangler.jsonc
│ ├── vite.config.ts
│ └── tsconfig.json
├── vision
│ ├── src
│ │ ├── client
│ │ │ ├── vite-env.d.ts
│ │ │ ├── main.tsx
│ │ │ └── index.html
│ │ └── server
│ │ │ └── types
│ │ │ └── hono.ts
│ ├── public
│ │ └── favicon.ico
│ ├── wrangler.jsonc
│ ├── tsconfig.json
│ ├── vite.config.ts
│ ├── package.json
│ └── biome.json
├── mcp-slack-oauth
│ ├── ci-install.sh
│ ├── .npmrc
│ ├── .dev.vars.example
│ ├── package.json
│ └── wrangler.jsonc
├── mcp-stytch-b2b-okr-manager
│ ├── src
│ │ ├── vite-env.d.ts
│ │ ├── main.tsx
│ │ ├── Setup.tsx
│ │ └── components
│ │ │ └── modal.tsx
│ ├── .env.template
│ ├── .github
│ │ └── hero.png
│ ├── public
│ │ └── stytch.ico
│ ├── .dev.vars.template
│ ├── tsconfig.json
│ ├── tsconfig.worker.json
│ ├── vite.config.ts
│ ├── index.html
│ ├── .gitignore
│ ├── tsconfig.node.json
│ ├── types.d.ts
│ ├── tsconfig.app.json
│ ├── eslint.config.js
│ ├── api
│ │ └── index.ts
│ └── LICENSE
├── mcp-stytch-consumer-todo-list
│ ├── src
│ │ ├── vite-env.d.ts
│ │ ├── main.tsx
│ │ ├── Setup.tsx
│ │ └── App.tsx
│ ├── .dev.vars.template
│ ├── .env.template
│ ├── tsconfig.json
│ ├── tsconfig.worker.json
│ ├── vite.config.ts
│ ├── CODEOWNERS
│ ├── index.html
│ ├── .gitignore
│ ├── types.d.ts
│ ├── tsconfig.node.json
│ ├── eslint.config.js
│ ├── tsconfig.app.json
│ ├── api
│ │ └── index.ts
│ ├── LICENSE
│ └── package.json
├── python-workers-mcp
│ ├── tests
│ │ └── pytest.ini
│ ├── .gitignore
│ ├── package.json
│ ├── src
│ │ ├── uvicorn.py
│ │ └── exceptions.py
│ ├── pyproject.toml
│ └── wrangler.jsonc
├── remote-mcp-logto
│ ├── .gitignore
│ ├── docs
│ │ └── who-am-i-testing.jpg
│ ├── .dev.vars.example
│ ├── tsconfig.json
│ └── package.json
├── remote-mcp-auth0
│ ├── docs
│ │ ├── local.jpg
│ │ ├── claude.png
│ │ ├── consent.png
│ │ ├── create-api.jpg
│ │ ├── playground.png
│ │ ├── offline-access.jpg
│ │ ├── troubleshooting.png
│ │ ├── create-application.jpg
│ │ └── create-permissions.jpg
│ ├── todos-api
│ │ ├── worker-configuration.d.ts
│ │ ├── .prettierrc
│ │ ├── wrangler.jsonc
│ │ ├── src
│ │ │ └── types
│ │ │ │ └── hono.ts
│ │ └── package.json
│ └── mcp-auth0-oidc
│ │ ├── src
│ │ └── types.ts
│ │ ├── .prettierrc
│ │ ├── .dev.vars.example
│ │ ├── package.json
│ │ ├── wrangler.jsonc
│ │ └── worker-configuration.d.ts
├── routing
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── wrangler.jsonc
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── package.json
├── model-scraper
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ ├── package.json
│ └── wrangler.jsonc
├── agent-scheduler
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ ├── llm
│ │ │ ├── extract-schedule-id.ts
│ │ │ └── extract-alarm-message.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ ├── wrangler.jsonc
│ └── package.json
├── agent-task-manager
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ ├── wrangler.jsonc
│ └── package.json
├── parallelisation
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── wrangler.jsonc
│ ├── tsconfig.json
│ └── package.json
├── prompt-chaining
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── wrangler.jsonc
│ ├── tsconfig.json
│ └── package.json
├── text-generation
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── wrangler.jsonc
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── package.json
├── tool-calling
│ ├── vitest.smoke.config.ts
│ ├── vite.config.ts
│ ├── smoke
│ │ └── tsconfig.json
│ ├── test
│ │ └── tsconfig.json
│ ├── vitest.config.ts
│ ├── wrangler.jsonc
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ └── package.json
├── evaluator-optimiser
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ ├── wrangler.jsonc
│ └── package.json
├── orchestrator-workers
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ ├── wrangler.jsonc
│ └── package.json
├── structured-output
│ ├── vitest.smoke.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── vitest.config.ts
│ ├── wrangler.jsonc
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── package.json
├── text-generation-stream
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── wrangler.jsonc
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── package.json
├── tool-calling-stream
│ ├── vitest.smoke.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── vitest.config.ts
│ ├── wrangler.jsonc
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ └── package.json
├── tool-calling-stream-traditional
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── wrangler.jsonc
│ ├── src
│ │ └── types
│ │ │ └── hono.ts
│ ├── tsconfig.json
│ └── package.json
├── agent-task-manager-human-in-the-loop
│ ├── vitest.config.ts
│ ├── vite.config.ts
│ ├── test
│ │ └── tsconfig.json
│ ├── src
│ │ ├── types
│ │ │ └── hono.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ ├── wrangler.jsonc
│ └── package.json
├── remote-mcp-authkit
│ ├── .dev.vars.example
│ ├── worker-configuration.d.ts
│ ├── src
│ │ └── props.ts
│ ├── tsconfig.json
│ ├── package.json
│ └── wrangler.jsonc
├── remote-mcp-github-oauth
│ ├── .dev.vars.example
│ ├── .prettierrc
│ └── package.json
├── remote-mcp-google-oauth
│ ├── .dev.vars.example
│ ├── .prettierrc
│ ├── worker-configuration.d.ts
│ ├── package.json
│ └── wrangler.jsonc
├── remote-mcp-cf-access
│ ├── .prettierrc
│ ├── .dev.vars.example
│ ├── package.json
│ └── wrangler.jsonc
├── remote-mcp-authless
│ ├── tsconfig.json
│ ├── package.json
│ └── wrangler.jsonc
└── structured-output-node
│ ├── tsconfig.json
│ ├── package.json
│ ├── src
│ └── index.ts
│ └── biome.json
├── tools
├── create-demo
│ └── scaffolding
│ │ ├── worker
│ │ ├── .dev.vars.ejs
│ │ ├── README.md.ejs
│ │ ├── vitest.config.ts.ejs
│ │ ├── vite.config.ts.ejs
│ │ ├── test
│ │ │ └── tsconfig.json.ejs
│ │ ├── wrangler.jsonc.ejs
│ │ ├── src
│ │ │ ├── index.ts.ejs
│ │ │ └── types
│ │ │ │ └── hono.ts.ejs
│ │ ├── tsconfig.json.ejs
│ │ ├── biome.json.ejs
│ │ └── package.json.ejs
│ │ └── worker-with-client
│ │ ├── .dev.vars.ejs
│ │ ├── README.md.ejs
│ │ ├── src
│ │ ├── client
│ │ │ ├── vite-env.d.ts.ejs
│ │ │ ├── App.tsx.ejs
│ │ │ ├── main.tsx.ejs
│ │ │ └── index.html.ejs
│ │ └── server
│ │ │ ├── index.ts.ejs
│ │ │ └── types
│ │ │ └── hono.ts.ejs
│ │ ├── vitest.config.ts.ejs
│ │ ├── test
│ │ └── tsconfig.json.ejs
│ │ ├── wrangler.jsonc.ejs
│ │ ├── tsconfig.json.ejs
│ │ ├── vite.config.ts.ejs
│ │ ├── biome.json.ejs
│ │ └── package.json.ejs
└── aicli
│ ├── bin
│ └── aicli
│ ├── tsconfig.json
│ ├── package.json
│ ├── README.md
│ └── src
│ └── bin
│ └── aicli.ts
├── CODEOWNERS
├── .github
├── version-and-install.sh
└── workflows
│ └── prerelease.yml
├── packages
├── workers-ai-provider
│ ├── src
│ │ ├── workersai-image-settings.ts
│ │ ├── workersai-image-config.ts
│ │ ├── autorag-chat-settings.ts
│ │ ├── map-workersai-usage.ts
│ │ ├── workersai-chat-settings.ts
│ │ ├── workersai-error.ts
│ │ ├── workersai-models.ts
│ │ └── workersai-chat-prompt.ts
│ ├── vitest.config.ts
│ └── tsconfig.json
└── ai-gateway-provider
│ ├── vitest.config.ts
│ ├── src
│ ├── providers
│ │ ├── xai.ts
│ │ ├── groq.ts
│ │ ├── azure.ts
│ │ ├── cohere.ts
│ │ ├── openai.ts
│ │ ├── mistral.ts
│ │ ├── cerebras.ts
│ │ ├── deepgram.ts
│ │ ├── deepseek.ts
│ │ ├── anthropic.ts
│ │ ├── fireworks.ts
│ │ ├── elevenlabs.ts
│ │ ├── perplexity.ts
│ │ ├── openrouter.ts
│ │ ├── amazon-bedrock.ts
│ │ ├── google.ts
│ │ ├── unified.ts
│ │ ├── google-vertex.ts
│ │ └── index.ts
│ └── auth.ts
│ ├── tsconfig.json
│ └── tsup.config.ts
├── libs
├── logger
│ ├── vitest.config.ts
│ ├── src
│ │ ├── types.ts
│ │ └── logger.ts
│ └── package.json
├── utils
│ ├── vitest.config.ts
│ └── package.json
├── test-utils
│ ├── vitest.config.ts
│ ├── package.json
│ └── src
│ │ └── DevServerTestHelper.ts
└── middleware
│ ├── package.json
│ └── src
│ └── auth-api-key.ts
├── tsconfig.json
├── tsconfig.node.json
├── pnpm-workspace.yaml
├── .editorconfig
├── nx.json
├── .changeset
└── config.json
├── tsconfig.browser.json
├── tsconfig.base.json
├── tsconfig.workerd.json
└── LICENSE
/demos/mcp-client/public/normalize.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server/static/img:
--------------------------------------------------------------------------------
1 | ../img
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/static/img:
--------------------------------------------------------------------------------
1 | ../img
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/static/img:
--------------------------------------------------------------------------------
1 | ../img
--------------------------------------------------------------------------------
/demos/image-generation/README.md:
--------------------------------------------------------------------------------
1 | # image-generation
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/static/img:
--------------------------------------------------------------------------------
1 | ../img
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/.dev.vars.ejs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | /packages/ai-gateway-provider/* @g4brym
2 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/.dev.vars.ejs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demos/mcp-client/.dev.vars.example:
--------------------------------------------------------------------------------
1 | HOST=http://localhost:5173
2 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/README.md.ejs:
--------------------------------------------------------------------------------
1 | # <%= projectName -%>
2 |
--------------------------------------------------------------------------------
/demos/ui-worker/src/client/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/vision/src/client/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/README.md.ejs:
--------------------------------------------------------------------------------
1 | # <%= projectName -%>
2 |
--------------------------------------------------------------------------------
/demos/mcp-slack-oauth/ci-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | npm install --no-audit --no-fund
3 |
4 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/python-workers-mcp/tests/pytest.ini:
--------------------------------------------------------------------------------
1 | [pytest]
2 | asyncio_default_fixture_loop_scope = session
3 |
--------------------------------------------------------------------------------
/demos/mcp-slack-oauth/.npmrc:
--------------------------------------------------------------------------------
1 | ignore-scripts=true
2 | legacy-peer-deps=true
3 | auto-install-peers=false
4 |
--------------------------------------------------------------------------------
/demos/remote-mcp-logto/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | # wrangler files
4 | .wrangler
5 | .dev.vars
6 |
--------------------------------------------------------------------------------
/demos/vision/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/vision/public/favicon.ico
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/local.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/local.jpg
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/client/vite-env.d.ts.ejs:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.github/version-and-install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | pnpm changeset version
4 | # pnpm install --no-frozen-lockfile
5 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/.DS_Store
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/claude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/claude.png
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/consent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/consent.png
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/create-api.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/create-api.jpg
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/playground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/playground.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/mcp-login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/mcp-login.png
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/mcp-login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/mcp-login.png
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/.dev.vars.template:
--------------------------------------------------------------------------------
1 | STYTCH_PROJECT_ID=TODO_FROM_STYTCH_DASHBOARD
2 | STYTCH_DOMAIN=TODO_FROM_STYTCH_DASHBOARD
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/offline-access.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/offline-access.jpg
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/troubleshooting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/troubleshooting.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/available-tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/available-tools.png
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-image-settings.ts:
--------------------------------------------------------------------------------
1 | export type WorkersAIImageSettings = {
2 | maxImagesPerCall?: number;
3 | };
4 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/.env.template:
--------------------------------------------------------------------------------
1 | VITE_STYTCH_PUBLIC_TOKEN=TODO-FROM-STYTCH-DASHBOARD
2 | VITE_STYTCH_DOMAIN=TODO_FROM_STYTCH_DASHBOARD
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/.github/hero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-stytch-b2b-okr-manager/.github/hero.png
--------------------------------------------------------------------------------
/demos/remote-mcp-logto/docs/who-am-i-testing.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-logto/docs/who-am-i-testing.jpg
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/mcp-login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/mcp-login.png
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/available-tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/available-tools.png
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/public/stytch.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-stytch-b2b-okr-manager/public/stytch.ico
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/.env.template:
--------------------------------------------------------------------------------
1 | VITE_STYTCH_PUBLIC_TOKEN=TODO-FROM-STYTCH-DASHBOARD
2 | VITE_STYTCH_DOMAIN=TODO_FROM_STYTCH_DASHBOARD
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/create-application.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/create-application.jpg
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/docs/create-permissions.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-auth0/docs/create-permissions.jpg
--------------------------------------------------------------------------------
/tools/aicli/bin/aicli:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -eu
3 |
4 | aicli_path="$(realpath "$(dirname $0)/../src/bin/aicli.ts")"
5 |
6 | tsx "$aicli_path" "$@"
7 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/available-tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/available-tools.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/mcp-inspector-sse-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/mcp-inspector-sse-config.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/mcp-inspector-oauth-success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/mcp-inspector-oauth-success.png
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/client/App.tsx.ejs:
--------------------------------------------------------------------------------
1 | function App() {
2 | return <><%= projectName -%>>;
3 | }
4 |
5 | export default App;
6 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/mcp-inspector-sse-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/mcp-inspector-sse-config.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | build
4 | coverage
5 | logs
6 | tmp
7 | .wrangler
8 | .env
9 | .env.local
10 | .dev.vars
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/claude-does-math-the-fancy-way.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/claude-does-math-the-fancy-way.png
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/mcp-inspector-oauth-success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/mcp-inspector-oauth-success.png
--------------------------------------------------------------------------------
/demos/python-workers-mcp/.gitignore:
--------------------------------------------------------------------------------
1 | .venv/
2 | .venv-pyodide/
3 | .pytest_cache/
4 | node_modules/
5 | __pycache__/
6 | src/vendor/
7 | .vscode/
8 | .wrangler/
9 | python_modules/
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/mcp-inspector-sse-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/mcp-inspector-sse-config.png
--------------------------------------------------------------------------------
/demos/routing/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/libs/logger/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/libs/utils/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-image-config.ts:
--------------------------------------------------------------------------------
1 | export type WorkersAIImageConfig = {
2 | provider: string;
3 | binding: Ai;
4 | gateway?: GatewayOptions;
5 | };
6 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/claude-does-math-the-fancy-way.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/claude-does-math-the-fancy-way.png
--------------------------------------------------------------------------------
/demos/model-scraper/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/mcp-inspector-oauth-success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/mcp-inspector-oauth-success.png
--------------------------------------------------------------------------------
/demos/remote-mcp-server/img/mcp-inspector-successful-tool-call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server/img/mcp-inspector-successful-tool-call.png
--------------------------------------------------------------------------------
/demos/ui-worker/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/libs/test-utils/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/image-generation/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/parallelisation/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/img/mcp-inspector-sse-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-descope-auth/img/mcp-inspector-sse-config.png
--------------------------------------------------------------------------------
/demos/text-generation/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/tool-calling/vitest.smoke.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/img/mcp-inspector-successful-tool-call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/mcp-server-bearer-auth/img/mcp-inspector-successful-tool-call.png
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/.dev.vars.template:
--------------------------------------------------------------------------------
1 | STYTCH_PROJECT_ID=TODO_FROM_STYTCH_DASHBOARD
2 | STYTCH_PROJECT_SECRET=TODO_FROM_STYTCH_DASHBOARD
3 | STYTCH_DOMAIN=TODO_FROM_STYTCH_DASHBOARD
--------------------------------------------------------------------------------
/demos/orchestrator-workers/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/claude-does-math-the-fancy-way.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/claude-does-math-the-fancy-way.png
--------------------------------------------------------------------------------
/demos/structured-output/vitest.smoke.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/libs/middleware/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "middleware",
3 | "private": true,
4 | "scripts": {
5 | "format": "biome format --write",
6 | "type-check": "tsc --noEmit"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/img/mcp-inspector-successful-tool-call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudflare/ai/main/demos/remote-mcp-server-autorag/img/mcp-inspector-successful-tool-call.png
--------------------------------------------------------------------------------
/demos/tool-calling-stream/vitest.smoke.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.base.json",
3 | "include": [],
4 | "files": [],
5 | "references": [{ "path": "./tsconfig.browser.json" }, { "path": "./tsconfig.node.json" }]
6 | }
7 |
--------------------------------------------------------------------------------
/demos/mcp-slack-oauth/.dev.vars.example:
--------------------------------------------------------------------------------
1 | SLACK_CLIENT_ID=
2 | SLACK_CLIENT_SECRET=
3 | COOKIE_ENCRYPTION_KEY=
4 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/todos-api/worker-configuration.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by Wrangler by running `wrangler types`
2 |
3 | interface Env {
4 | AUTH0_DOMAIN: string
5 | AUTH0_AUDIENCE: string
6 | }
7 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/.dev.vars.example:
--------------------------------------------------------------------------------
1 | WORKOS_CLIENT_ID=
2 | WORKOS_CLIENT_SECRET=
3 | COOKIE_ENCRYPTION_KEY=
4 |
--------------------------------------------------------------------------------
/demos/remote-mcp-github-oauth/.dev.vars.example:
--------------------------------------------------------------------------------
1 | GITHUB_CLIENT_ID=
2 | GITHUB_CLIENT_SECRET=
3 | COOKIE_ENCRYPTION_KEY=
4 |
--------------------------------------------------------------------------------
/demos/routing/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/vitest.config.ts.ejs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/image-generation/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/model-scraper/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/parallelisation/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/text-generation/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/tool-calling/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | globals: true,
6 | passWithNoTests: true,
7 | },
8 | });
9 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/remote-mcp-logto/.dev.vars.example:
--------------------------------------------------------------------------------
1 | LOGTO_ENDPOINT=
2 | LOGTO_APP_ID=
3 | LOGTO_APP_SECRET=
4 | COOKIE_ENCRYPTION_KEY=
5 |
--------------------------------------------------------------------------------
/demos/structured-output/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/vitest.config.ts.ejs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | },
7 | });
8 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/routing/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/ui-worker/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/model-scraper/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/parallelisation/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/.dev.vars.example:
--------------------------------------------------------------------------------
1 | DESCOPE_PROJECT_ID="your_project_id"
2 | DESCOPE_MANAGEMENT_KEY="your_management_key"
3 | COOKIE_ENCRYPTION_KEY="your_cookie_encryption_key_generate_with_openssl_rand_hex_32"
4 |
--------------------------------------------------------------------------------
/demos/text-generation/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling/smoke/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/vite.config.ts.ejs:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import { defineConfig } from "vite";
3 |
4 | export default defineConfig({
5 | plugins: [cloudflare()],
6 | });
7 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/image-generation/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/structured-output/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/test/tsconfig.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/demos/tool-calling/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, configDefaults } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | exclude: [...configDefaults.exclude, "**/smoke/**"],
7 | },
8 | });
9 |
--------------------------------------------------------------------------------
/libs/utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "utils",
3 | "private": true,
4 | "scripts": {
5 | "format": "biome format --write",
6 | "test": "vitest",
7 | "test:ci": "vitest --watch=false",
8 | "type-check": "tsc --noEmit"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/demos/structured-output/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, configDefaults } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | exclude: [...configDefaults.exclude, "**/smoke/**"],
7 | },
8 | });
9 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, configDefaults } from "vitest/config";
2 |
3 | export default defineConfig({
4 | test: {
5 | passWithNoTests: true,
6 | exclude: [...configDefaults.exclude, "**/smoke/**"],
7 | },
8 | });
9 |
--------------------------------------------------------------------------------
/libs/test-utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test-utils",
3 | "private": true,
4 | "scripts": {
5 | "format": "biome format --write",
6 | "test": "vitest",
7 | "test:ci": "vitest --watch=false",
8 | "type-check": "tsc --noEmit"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/test/tsconfig.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["@cloudflare/vitest-pool-workers"]
5 | },
6 | "include": ["../worker-configuration.d.ts", "**/*.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.base.json",
3 | "include": [
4 | "./**/*.ts",
5 | "./demos/structured-output-node/src/**/*.ts",
6 | "./tools/create-demo/src/**/*.ts"
7 | ],
8 | "exclude": ["**/src/**/*.ts", "**/test/**/*.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { JWTPayload } from "jose";
2 |
3 | export type UserProps = {
4 | claims: JWTPayload;
5 | tokenSet: {
6 | accessToken: string;
7 | idToken: string;
8 | refreshToken: string;
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/libs/logger/src/types.ts:
--------------------------------------------------------------------------------
1 | export interface Logger {
2 | success(message: string, ...args: unknown[]): void;
3 | info(message: string, ...args: unknown[]): void;
4 | warn(message: string, ...args: unknown[]): void;
5 | error(message: string, ...args: unknown[]): void;
6 | }
7 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": [],
3 | "references": [
4 | {
5 | "path": "./tsconfig.app.json"
6 | },
7 | {
8 | "path": "./tsconfig.node.json"
9 | },
10 | {
11 | "path": "./tsconfig.worker.json"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": [],
3 | "references": [
4 | {
5 | "path": "./tsconfig.app.json"
6 | },
7 | {
8 | "path": "./tsconfig.node.json"
9 | },
10 | {
11 | "path": "./tsconfig.worker.json"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/xai.ts:
--------------------------------------------------------------------------------
1 | import { createXai as createXaiOriginal } from "@ai-sdk/xai";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createXai = (...args: Parameters) =>
5 | authWrapper(createXaiOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/remote-mcp-google-oauth/.dev.vars.example:
--------------------------------------------------------------------------------
1 | GOOGLE_CLIENT_ID=
2 | GOOGLE_CLIENT_SECRET=
3 | COOKIE_ENCRYPTION_KEY=
4 | HOSTED_DOMAIN=
5 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/groq.ts:
--------------------------------------------------------------------------------
1 | import { createGroq as createGroqOriginal } from "@ai-sdk/groq";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createGroq = (...args: Parameters) =>
5 | authWrapper(createGroqOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/tsconfig.worker.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.node.json",
3 | "compilerOptions": {
4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
5 | "types": ["./worker-configuration.d.ts", "vite/client"]
6 | },
7 | "include": ["api"]
8 | }
9 |
--------------------------------------------------------------------------------
/libs/logger/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "logger",
3 | "private": true,
4 | "main": "src/index.ts",
5 | "scripts": {
6 | "format": "biome format --write",
7 | "test": "vitest --watch=false",
8 | "test:ci": "vitest --watch=false",
9 | "type-check": "tsc --noEmit"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/azure.ts:
--------------------------------------------------------------------------------
1 | import { createAzure as createAzureOriginal } from "@ai-sdk/azure";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createAzure = (...args: Parameters) =>
5 | authWrapper(createAzureOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/cohere.ts:
--------------------------------------------------------------------------------
1 | import { createCohere as createCohereOriginal } from "@ai-sdk/cohere";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createCohere = (...args: Parameters) =>
5 | authWrapper(createCohereOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/openai.ts:
--------------------------------------------------------------------------------
1 | import { createOpenAI as createOpenAIOriginal } from "@ai-sdk/openai";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createOpenAI = (...args: Parameters) =>
5 | authWrapper(createOpenAIOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/tsconfig.worker.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.node.json",
3 | "compilerOptions": {
4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
5 | "types": ["./worker-configuration.d.ts", "vite/client"],
6 | },
7 | "include": ["api"],
8 | }
9 |
--------------------------------------------------------------------------------
/demos/remote-mcp-cf-access/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 140,
3 | "singleQuote": true,
4 | "semi": false,
5 | "useTabs": false,
6 | "overrides": [
7 | {
8 | "files": ["*.jsonc"],
9 | "options": {
10 | "trailingComma": "none"
11 | }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/demos/remote-mcp-github-oauth/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 140,
3 | "singleQuote": false,
4 | "semi": true,
5 | "useTabs": false,
6 | "overrides": [
7 | {
8 | "files": ["*.jsonc"],
9 | "options": {
10 | "trailingComma": "none"
11 | }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/demos/remote-mcp-google-oauth/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 140,
3 | "singleQuote": true,
4 | "semi": false,
5 | "useTabs": false,
6 | "overrides": [
7 | {
8 | "files": ["*.jsonc"],
9 | "options": {
10 | "trailingComma": "none"
11 | }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/demos/vision/src/client/main.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { StrictMode } from "react";
3 | import { createRoot } from "react-dom/client";
4 | import App from "./App";
5 |
6 | createRoot(document.getElementById("root")!).render(
7 |
8 |
9 | ,
10 | );
11 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/mistral.ts:
--------------------------------------------------------------------------------
1 | import { createMistral as createMistralOriginal } from "@ai-sdk/mistral";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createMistral = (...args: Parameters) =>
5 | authWrapper(createMistralOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - ./libs/*
3 | - ./demos/*
4 | - ./demos/remote-mcp-auth0/*
5 | - ./packages/*
6 | - ./playground/*
7 | - ./tools/aicli
8 | - "!./demos/remote-mcp-auth0"
9 | - "!./demos/remote-mcp-auth0/docs"
10 | onlyBuiltDependencies:
11 | - esbuild
12 | - workerd
13 |
--------------------------------------------------------------------------------
/demos/image-generation/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/wrangler/config-schema.json",
3 | "name": "image-generation",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demos/mcp-client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test MCP client
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/todos-api/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 140,
3 | "singleQuote": false,
4 | "semi": true,
5 | "useTabs": false,
6 | "overrides": [
7 | {
8 | "files": ["*.jsonc"],
9 | "options": {
10 | "trailingComma": "none"
11 | }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 140,
3 | "singleQuote": true,
4 | "semi": false,
5 | "useTabs": false,
6 | "overrides": [
7 | {
8 | "files": ["*.jsonc"],
9 | "options": {
10 | "trailingComma": "none"
11 | }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/cerebras.ts:
--------------------------------------------------------------------------------
1 | import { createCerebras as createCerebrasOriginal } from "@ai-sdk/cerebras";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createCerebras = (...args: Parameters) =>
5 | authWrapper(createCerebrasOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/deepgram.ts:
--------------------------------------------------------------------------------
1 | import { createDeepgram as createDeepgramOriginal } from "@ai-sdk/deepgram";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createDeepgram = (...args: Parameters) =>
5 | authWrapper(createDeepgramOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/deepseek.ts:
--------------------------------------------------------------------------------
1 | import { createDeepSeek as createDeepSeekOriginal } from "@ai-sdk/deepseek";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createDeepSeek = (...args: Parameters) =>
5 | authWrapper(createDeepSeekOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "tool-calling-stream",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/anthropic.ts:
--------------------------------------------------------------------------------
1 | import { createAnthropic as createAnthropicOriginal } from "@ai-sdk/anthropic";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createAnthropic = (...args: Parameters) =>
5 | authWrapper(createAnthropicOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/fireworks.ts:
--------------------------------------------------------------------------------
1 | import { createFireworks as createFireworksOriginal } from "@ai-sdk/fireworks";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createFireworks = (...args: Parameters) =>
5 | authWrapper(createFireworksOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/client/main.tsx.ejs:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 | import App from "./App";
4 |
5 | createRoot(document.getElementById("root")!).render(
6 |
7 |
8 | ,
9 | );
10 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/elevenlabs.ts:
--------------------------------------------------------------------------------
1 | import { createElevenLabs as createElevenLabsOriginal } from "@ai-sdk/elevenlabs";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createElevenLabs = (...args: Parameters) =>
5 | authWrapper(createElevenLabsOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/perplexity.ts:
--------------------------------------------------------------------------------
1 | import { createPerplexity as createPerplexityOriginal } from "@ai-sdk/perplexity";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createPerplexity = (...args: Parameters) =>
5 | authWrapper(createPerplexityOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "text-generation-stream",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/openrouter.ts:
--------------------------------------------------------------------------------
1 | import { createOpenRouter as createOpenRouterOriginal } from '@openrouter/ai-sdk-provider';
2 | import { authWrapper } from "../auth";
3 |
4 | export const createOpenRouter = (...args: Parameters) =>
5 | authWrapper(createOpenRouterOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "tool-calling-stream-traditional",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/wrangler.jsonc.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/wrangler/config-schema.json",
3 | "name": "<%= projectName -%>",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import react from "@vitejs/plugin-react";
3 | import { defineConfig } from "vite";
4 |
5 | // https://vite.dev/config/
6 | export default defineConfig({
7 | plugins: [react(), cloudflare()],
8 | server: {
9 | port: 3000,
10 | },
11 | });
12 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/worker-configuration.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by Wrangler by running `wrangler types --env example`
2 |
3 | interface Env {
4 | OAUTH_KV: KVNamespace;
5 | COOKIE_ENCRYPTION_KEY: string;
6 | WORKOS_CLIENT_ID: string;
7 | WORKOS_CLIENT_SECRET: string;
8 | MCP_OBJECT: DurableObjectNamespace /* MyMCP */;
9 | AI: Ai;
10 | }
11 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/amazon-bedrock.ts:
--------------------------------------------------------------------------------
1 | import { createAmazonBedrock as createAmazonBedrockOriginal } from "@ai-sdk/amazon-bedrock";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createAmazonBedrock = (...args: Parameters) =>
5 | authWrapper(createAmazonBedrockOriginal)(...args);
6 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import react from "@vitejs/plugin-react";
3 | import { defineConfig } from "vite";
4 |
5 | // https://vite.dev/config/
6 | export default defineConfig({
7 | plugins: [react(), cloudflare()],
8 | server: {
9 | port: 3000,
10 | },
11 | });
12 |
--------------------------------------------------------------------------------
/demos/tool-calling/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "tool-calling",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/demos/text-generation/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "text-generation",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Stytch code owners file
2 |
3 | # These owners will be the default owners for everything in
4 |
5 | # the repo. Unless a later match takes precedence,
6 |
7 | # @stytchauth/developer-relations will be requested for
8 |
9 | # review when someone opens a pull request.
10 |
11 | * @stytchauth/developer-relations
12 |
--------------------------------------------------------------------------------
/demos/structured-output/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "structured-output",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/google.ts:
--------------------------------------------------------------------------------
1 | import { createGoogleGenerativeAI as createGoogleGenerativeAIOriginal } from "@ai-sdk/google";
2 | import { authWrapper } from "../auth";
3 |
4 | export const createGoogleGenerativeAI = (
5 | ...args: Parameters
6 | ) => authWrapper(createGoogleGenerativeAIOriginal)(...args);
7 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/.dev.vars.example:
--------------------------------------------------------------------------------
1 | AUTH0_DOMAIN=
2 | AUTH0_CLIENT_ID=
3 | AUTH0_CLIENT_SECRET=
4 | AUTH0_AUDIENCE=
5 | AUTH0_SCOPE=
6 | API_BASE_URL=
7 | NODE_ENV=development
8 | COOKIE_ENCRYPTION_KEY=
9 |
--------------------------------------------------------------------------------
/demos/remote-mcp-google-oauth/worker-configuration.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by Wrangler by running `wrangler types`
2 |
3 | interface Env {
4 | OAUTH_KV: KVNamespace;
5 | GOOGLE_CLIENT_ID: string;
6 | GOOGLE_CLIENT_SECRET: string;
7 | COOKIE_ENCRYPTION_KEY: string;
8 | HOSTED_DOMAIN: string;
9 | MCP_OBJECT: DurableObjectNamespace;
10 | }
11 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esNext",
4 | "module": "commonjs",
5 | "esModuleInterop": true,
6 | "forceConsistentCasingInFileNames": true,
7 | "strict": true,
8 | "skipLibCheck": true,
9 | "noUncheckedIndexedAccess": true,
10 | "noEmit": true
11 | },
12 | "include": ["src/*.ts", "src/**/*.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/demos/mcp-client/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { cloudflare } from "@cloudflare/vite-plugin";
2 | import react from "@vitejs/plugin-react";
3 | import { defineConfig } from "vite";
4 |
5 | export default defineConfig({
6 | plugins: [
7 | react(),
8 | cloudflare({
9 | // ensure that we can run two instances of the dev server
10 | inspectorPort: 9230,
11 | }),
12 | ],
13 | });
14 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/src/main.tsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 | import "./index.css";
4 | import App from "./App.tsx";
5 | import Setup from "./Setup.tsx";
6 |
7 | createRoot(document.getElementById("root")!).render(
8 |
9 |
10 |
11 |
12 | ,
13 | );
14 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/src/main.tsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 | import "./index.css";
4 | import App from "./App.tsx";
5 | import Setup from "./Setup.tsx";
6 |
7 | createRoot(document.getElementById("root")!).render(
8 |
9 |
10 |
11 |
12 | ,
13 | );
14 |
--------------------------------------------------------------------------------
/tools/aicli/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "lib": ["esnext"],
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "types": ["@types/node"],
8 | "noEmit": true,
9 | "isolatedModules": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "skipLibCheck": true,
12 | "strict": true
13 | },
14 | "include": ["src"]
15 | }
16 |
--------------------------------------------------------------------------------
/demos/remote-mcp-cf-access/.dev.vars.example:
--------------------------------------------------------------------------------
1 | ACCESS_CLIENT_ID=
2 | ACCESS_CLIENT_SECRET=
3 | ACCESS_TOKEN_URL=
4 | ACCESS_AUTHORIZATION_URL=
5 | ACCESS_JWKS_URL=
6 | COOKIE_ENCRYPTION_KEY=
7 |
--------------------------------------------------------------------------------
/demos/ui-worker/postcss.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | "postcss-preset-mantine": {},
4 | "postcss-simple-vars": {
5 | variables: {
6 | "mantine-breakpoint-xs": "36em",
7 | "mantine-breakpoint-sm": "48em",
8 | "mantine-breakpoint-md": "62em",
9 | "mantine-breakpoint-lg": "75em",
10 | "mantine-breakpoint-xl": "88em",
11 | },
12 | },
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/src/index.ts.ejs:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
6 |
7 | app.use(cors());
8 | app.get("/", (c) => c.json("ok"));
9 |
10 | export default {
11 | fetch: app.fetch,
12 | } satisfies ExportedHandler;
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{js,jsx,ts,tsx,json,css,html}]
15 | indent_style = tab
16 | indent_size = 2
17 |
18 | [*.{yml,yaml}]
19 | indent_style = space
20 | indent_size = 2
--------------------------------------------------------------------------------
/demos/ui-worker/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "ui-worker",
4 | "main": "src/server/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "assets": {
7 | "not_found_handling": "single-page-application",
8 | "binding": "ASSETS",
9 | "directory": "./dist/client"
10 | },
11 | "observability": {
12 | "enabled": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/nx.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/nx/schemas/nx-schema.json",
3 | "targetDefaults": {
4 | "build": {
5 | "cache": true
6 | },
7 | "lint": {
8 | "cache": true
9 | },
10 | "test": {
11 | "cache": true
12 | },
13 | "test:ci": {
14 | "cache": true
15 | },
16 | "types": {
17 | "cache": true
18 | },
19 | "type-check": {
20 | "cache": true
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3 | "changelog": ["@changesets/changelog-github", { "repo": "cloudflare/ai" }],
4 | "commit": false,
5 | "fixed": [],
6 | "linked": [],
7 | "access": "public",
8 | "baseBranch": "main",
9 | "updateInternalDependencies": "patch",
10 | "privatePackages": {
11 | "tag": true,
12 | "version": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/server/index.ts.ejs:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
6 |
7 | app.use(cors());
8 | app.get("/", (c) => c.json("ok"));
9 |
10 | export default {
11 | fetch: app.fetch,
12 | } satisfies ExportedHandler;
13 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/src/props.ts:
--------------------------------------------------------------------------------
1 | import type { User } from "@workos-inc/node";
2 |
3 | export interface Props {
4 | user: User;
5 | accessToken: string;
6 | refreshToken: string;
7 | permissions: string[];
8 | organizationId?: string;
9 |
10 | // Props must have an index signature to satsify the `McpAgent`
11 | // generic `Props` which extends `Record`.
12 | [key: string]: unknown;
13 | }
14 |
--------------------------------------------------------------------------------
/demos/vision/src/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | vision
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/client/index.html.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <%= projectName -%>
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/demos/python-workers-mcp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "python-workers-mcp",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "Python Workers MCP Demo",
6 | "scripts": {
7 | "build": "uv run pywrangler sync",
8 | "dev": "uv run pywrangler dev",
9 | "deploy": "uv run pywrangler deploy",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "devDependencies": {
13 | "wrangler": "^4.52.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/autorag-chat-settings.ts:
--------------------------------------------------------------------------------
1 | import type { StringLike } from "./utils";
2 |
3 | export type AutoRAGChatSettings = {
4 | /**
5 | * Whether to inject a safety prompt before all conversations.
6 | * Defaults to `false`.
7 | */
8 | safePrompt?: boolean;
9 | } & {
10 | /**
11 | * Passthrough settings that are provided directly to the run function.
12 | */
13 | [key: string]: StringLike;
14 | };
15 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | OKR MCP Server
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/demos/ui-worker/src/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite + React + TS
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "tsup";
2 | import pkg from "./package.json";
3 |
4 | export default defineConfig({
5 | entry: ["src/index.ts", "src/providers/*"],
6 | splitting: false,
7 | sourcemap: true,
8 | clean: true,
9 | dts: true,
10 | format: ["cjs", "esm"],
11 | external: Object.keys(pkg.optionalDependencies ?? {}).filter((dep) => dep !== "@ai-sdk/google-vertex"),
12 | target: "es2020",
13 | });
14 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TODO MCP Server
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tsconfig.browser.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.base.json",
3 | "compilerOptions": {
4 | "target": "ES2020",
5 | "useDefineForClassFields": true,
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "allowSyntheticDefaultImports": true,
8 | "isolatedModules": true,
9 | "jsx": "react-jsx",
10 | "noUncheckedSideEffectImports": true
11 | },
12 | "include": ["./demos/ui-worker/src/client/**/*.ts", "./demos/ui-worker/src/client/**/*.tsx"]
13 | }
14 |
--------------------------------------------------------------------------------
/demos/python-workers-mcp/src/uvicorn.py:
--------------------------------------------------------------------------------
1 | # This file must exist as a hack to satisfy mcp.
2 | # mcp has an optional dependency on uvicorn but still imports it at the top scope, see:
3 | # https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/server/fastmcp/server.py#L18
4 | # Because we never call `run_sse_async` this is not required. However, Python workers used asgi.py
5 | # rather than uvicorn which is why this hack is needed. With this, the import succeeds.
6 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/todos-api/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "./node_modules/wrangler/config-schema.json",
7 | "name": "todos-api",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-04-01",
10 | "observability": {
11 | "enabled": true
12 | },
13 | "dev": {
14 | "port": 8789
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demos/vision/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/wrangler/config-schema.json",
3 | "name": "vision",
4 | "main": "src/server/index.ts",
5 | "compatibility_date": "2025-04-04",
6 | "assets": {
7 | "not_found_handling": "single-page-application",
8 | "binding": "ASSETS",
9 | "directory": "./dist/client",
10 | },
11 | "observability": {
12 | "enabled": true,
13 | },
14 | "ai": {
15 | "binding": "AI",
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | npm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
26 | # wrangler files
27 | .wrangler
28 | .dev.vars*
29 | !.dev.vars.template
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
26 | # wrangler files
27 | .wrangler
28 | .dev.vars*
29 | !.dev.vars.template
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/todos-api/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Variables: Variables;
13 | }>;
14 | export type Context = HonoContext<{ Variables: Variables }>;
15 | export type Next = () => Promise;
16 |
--------------------------------------------------------------------------------
/demos/routing/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "routing",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "workflows": [
14 | {
15 | "name": "routing-workflow",
16 | "binding": "ROUTING_WORKFLOW",
17 | "class_name": "RoutingWorkflow"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/mcp-client/get-subdomain.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Fetch the workers.dev subdomain from Cloudflare API
4 | response=$(curl -s "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/workers/subdomain" \
5 | -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN")
6 |
7 | # Extract the subdomain using jq
8 | subdomain=$(echo "$response" | jq -r '.result.subdomain')
9 |
10 | # Construct and output ONLY the full URL (no other text)
11 | echo "https://$WRANGLER_CI_OVERRIDE_NAME.$subdomain.workers.dev"
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/wrangler.jsonc.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/wrangler/config-schema.json",
3 | "name": "<%= projectName -%>",
4 | "main": "src/server/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "assets": {
7 | "not_found_handling": "single-page-application",
8 | "binding": "ASSETS",
9 | "directory": "./dist/client"
10 | },
11 | "observability": {
12 | "enabled": true
13 | },
14 | "ai": {
15 | "binding": "AI"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/auth.ts:
--------------------------------------------------------------------------------
1 | export const CF_TEMP_TOKEN = "CF_TEMP_TOKEN";
2 |
3 | type HasApiKey = { apiKey: string };
4 |
5 | export function authWrapper any>(
6 | func: Func,
7 | ): (config: Parameters[0]) => ReturnType {
8 | return (config) => {
9 | if (!config) {
10 | return func({ apiKey: CF_TEMP_TOKEN });
11 | }
12 | if (config.apiKey === undefined) {
13 | config.apiKey = CF_TEMP_TOKEN;
14 | }
15 | return func(config);
16 | };
17 | }
18 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/map-workersai-usage.ts:
--------------------------------------------------------------------------------
1 | export function mapWorkersAIUsage(output: AiTextGenerationOutput | AiTextToImageOutput) {
2 | const usage = (
3 | output as {
4 | usage: { prompt_tokens: number; completion_tokens: number };
5 | }
6 | ).usage ?? {
7 | completion_tokens: 0,
8 | prompt_tokens: 0,
9 | };
10 |
11 | return {
12 | outputTokens: usage.completion_tokens,
13 | inputTokens: usage.prompt_tokens,
14 | totalTokens: usage.prompt_tokens + usage.completion_tokens,
15 | };
16 | }
17 |
--------------------------------------------------------------------------------
/demos/routing/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/image-generation/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/model-scraper/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/parallelisation/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/text-generation/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/tool-calling/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/ui-worker/src/client/main.tsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 | import "@mantine/core/styles.css";
4 | import { createTheme, MantineProvider } from "@mantine/core";
5 | import App from "./App";
6 |
7 | const theme = createTheme({
8 | /** Put your mantine theme override here */
9 | });
10 |
11 | createRoot(document.getElementById("root")!).render(
12 |
13 |
14 |
15 |
16 | ,
17 | );
18 |
--------------------------------------------------------------------------------
/demos/ui-worker/src/server/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/ui-worker/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from "node:path";
2 | import { cloudflare } from "@cloudflare/vite-plugin";
3 | import react from "@vitejs/plugin-react";
4 | import { defineConfig } from "vite";
5 |
6 | // https://vite.dev/config/
7 | export default defineConfig({
8 | root: "./src/client",
9 | build: {
10 | emptyOutDir: true,
11 | outDir: resolve(__dirname, "dist"),
12 | },
13 | plugins: [
14 | react(),
15 | cloudflare({
16 | configPath: resolve(__dirname, "wrangler.jsonc"),
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/demos/vision/src/server/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/parallelisation/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "parallelisation",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "workflows": [
14 | {
15 | "name": "parallelisation-workflow",
16 | "binding": "PARALLELISATION_WORKFLOW",
17 | "class_name": "ParallelisationWorkflow"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "prompt-chaining",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "workflows": [
14 | {
15 | "name": "prompt-chaining-workflow",
16 | "binding": "PROMPT_CHAINING_WORKFLOW",
17 | "class_name": "PromptChainingWorkflow"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/structured-output/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/routing/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-chat-settings.ts:
--------------------------------------------------------------------------------
1 | import type { StringLike } from "./utils";
2 |
3 | export type WorkersAIChatSettings = {
4 | /**
5 | * Whether to inject a safety prompt before all conversations.
6 | * Defaults to `false`.
7 | */
8 | safePrompt?: boolean;
9 |
10 | /**
11 | * Optionally set Cloudflare AI Gateway options.
12 | */
13 | gateway?: GatewayOptions;
14 | } & {
15 | /**
16 | * Passthrough settings that are provided directly to the run function.
17 | */
18 | [key: string]: StringLike;
19 | };
20 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/tool-calling/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/ui-worker/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021", "DOM", "DOM.Iterable"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["**/*.ts", "**/*.tsx"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-error.ts:
--------------------------------------------------------------------------------
1 | import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
2 | import { z } from "zod/v4";
3 |
4 | const workersAIErrorDataSchema = z.object({
5 | code: z.string().nullable(),
6 | message: z.string(),
7 | object: z.literal("error"),
8 | param: z.string().nullable(),
9 | type: z.string(),
10 | });
11 |
12 | export const workersAIFailedResponseHandler = createJsonErrorResponseHandler({
13 | errorSchema: workersAIErrorDataSchema,
14 | errorToMessage: (data) => data.message,
15 | });
16 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/src/types/hono.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/image-generation/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/types.d.ts:
--------------------------------------------------------------------------------
1 | export type Todo = {
2 | id: string;
3 | text: string;
4 | completed: boolean;
5 | };
6 |
7 | // Context from the auth process, extracted from the Stytch auth token JWT
8 | // and provided to the MCP Server as this.props
9 | export type AuthenticationContext = {
10 | claims: {
11 | iss: string;
12 | scope: string;
13 | sub: string;
14 | aud: string[];
15 | client_id: string;
16 | exp: number;
17 | iat: number;
18 | nbf: number;
19 | jti: string;
20 | };
21 | accessToken: string;
22 | };
23 |
--------------------------------------------------------------------------------
/demos/model-scraper/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/parallelisation/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-logto/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/structured-output/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/text-generation/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/src/types/hono.ts.ejs:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "evaluator-optimiser",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "workflows": [
14 | {
15 | "name": "evaluator-optimiser-workflow",
16 | "binding": "EVALUATOR_OPTIMISER_WORKFLOW",
17 | "class_name": "EvaluatorOptimiserWorkflow"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authless/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/tsconfig.base.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "lib": ["ESNext"],
4 | "target": "ESNext",
5 | "module": "ESNext",
6 | "moduleDetection": "force",
7 | "jsx": "react-jsx",
8 | "allowJs": true,
9 | "moduleResolution": "bundler",
10 | "verbatimModuleSyntax": true,
11 | "noEmit": true,
12 | "strict": true,
13 | "skipLibCheck": true,
14 | "noFallthroughCasesInSwitch": true,
15 | "noUnusedLocals": true,
16 | "noUnusedParameters": true
17 | },
18 | "include": ["libs/**/*", "workers/**/*"],
19 | "exclude": ["node_modules", "dist"]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "orchestrator-workers",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-01-29",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "workflows": [
14 | {
15 | "name": "orchestrator-workers-workflow",
16 | "binding": "ORCHESTRATOR_WORKERS_WORKFLOW",
17 | "class_name": "OrchestratorWorkersWorkflow"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/libs/middleware/src/auth-api-key.ts:
--------------------------------------------------------------------------------
1 | import type { Context } from "hono";
2 |
3 | export async function authApiKey(
4 | c: Context<{
5 | Bindings: any;
6 | Variables: any;
7 | }>,
8 | next: () => Promise,
9 | ) {
10 | if (c.env.ENVIRONMENT === "development") {
11 | return await next();
12 | }
13 |
14 | if (!c.env.API_KEY) {
15 | return c.json({ error: "API key not set" }, 500);
16 | }
17 |
18 | if (c.env.API_KEY !== c.req.header("x-api-key")) {
19 | return c.json({ error: "Invalid API key" }, 401);
20 | }
21 |
22 | await next();
23 | }
24 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "lib": ["ESNext"],
4 | "target": "ESNext",
5 | "module": "ESNext",
6 | "moduleDetection": "force",
7 | "allowJs": true,
8 | "moduleResolution": "bundler",
9 | "verbatimModuleSyntax": true,
10 | "noEmit": false,
11 | "strict": true,
12 | "skipLibCheck": true,
13 | "noFallthroughCasesInSwitch": true,
14 | "noUnusedLocals": true,
15 | "noUnusedParameters": true,
16 | "types": ["@cloudflare/workers-types/experimental"]
17 | },
18 | "include": ["src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/src/server/types/hono.ts.ejs:
--------------------------------------------------------------------------------
1 | import type {
2 | Hono,
3 | Context as HonoContext,
4 | MiddlewareHandler as HonoMiddlewareHandler,
5 | } from "hono";
6 |
7 | export type Variables = Record;
8 |
9 | export type App = Hono<{ Bindings: Env; Variables: Variables }>;
10 |
11 | export type MiddlewareHandler = HonoMiddlewareHandler<{
12 | Bindings: Env;
13 | Variables: Variables;
14 | }>;
15 | export type Context = HonoContext<{ Bindings: Env; Variables: Variables }>;
16 | export type Next = () => Promise;
17 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/tsconfig.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/unified.ts:
--------------------------------------------------------------------------------
1 | import type { OpenAICompatibleProviderSettings } from "@ai-sdk/openai-compatible";
2 | import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
3 |
4 | export const createUnified = (arg?: Partial) => {
5 | return createOpenAICompatible({
6 | baseURL: "https://gateway.ai.cloudflare.com/v1/compat", // intercepted and replaced with actual base URL later
7 | name: "Unified",
8 | ...(arg || {}),
9 | });
10 | }
11 |
12 | export const unified = createUnified();
--------------------------------------------------------------------------------
/demos/vision/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021", "DOM", "DOM.Iterable"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts", "src/**/*.tsx"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/vision/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from "node:path";
2 | import { cloudflare } from "@cloudflare/vite-plugin";
3 | import react from "@vitejs/plugin-react";
4 | import { defineConfig } from "vite";
5 |
6 | // https://vite.dev/config/
7 | export default defineConfig({
8 | root: "./src/client",
9 | build: {
10 | emptyOutDir: true,
11 | outDir: resolve(__dirname, "dist"),
12 | },
13 | plugins: [
14 | react(),
15 | cloudflare({
16 | configPath: resolve(__dirname, "wrangler.jsonc"),
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/tsconfig.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2021",
4 | "lib": ["es2021"],
5 | "jsx": "react-jsx",
6 | "module": "es2022",
7 | "moduleResolution": "Bundler",
8 | "resolveJsonModule": true,
9 | "allowJs": true,
10 | "checkJs": false,
11 | "noEmit": true,
12 | "isolatedModules": true,
13 | "allowSyntheticDefaultImports": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "strict": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "allowSyntheticDefaultImports": true,
5 | "checkJs": false,
6 | "forceConsistentCasingInFileNames": true,
7 | "isolatedModules": true,
8 | "lib": ["es2021"],
9 | "module": "es2022",
10 | "moduleResolution": "Bundler",
11 | "noEmit": true,
12 | "resolveJsonModule": true,
13 | "skipLibCheck": true,
14 | "strict": true,
15 | "target": "es2021",
16 | "types": ["@cloudflare/workers-types/2023-07-01"]
17 | },
18 | "include": ["worker-configuration.d.ts", "src/**/*.ts"]
19 | }
20 |
--------------------------------------------------------------------------------
/demos/structured-output-node/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "allowSyntheticDefaultImports": true,
5 | "checkJs": false,
6 | "forceConsistentCasingInFileNames": true,
7 | "isolatedModules": true,
8 | "jsx": "react-jsx",
9 | "lib": ["es2021"],
10 | "module": "es2022",
11 | "moduleResolution": "Bundler",
12 | "noEmit": true,
13 | "resolveJsonModule": true,
14 | "skipLibCheck": true,
15 | "strict": true,
16 | "target": "es2021",
17 | "types": ["@cloudflare/workers-types", "node"]
18 | },
19 | "include": ["src/**/*.ts"]
20 | }
21 |
--------------------------------------------------------------------------------
/tools/aicli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@repo/aicli",
3 | "private": true,
4 | "version": "0.0.1",
5 | "description": "A handy CLI for developing demos",
6 | "directories": {
7 | "bin": "bin"
8 | },
9 | "dependencies": {
10 | "@commander-js/extra-typings": "^14.0.0",
11 | "commander": "^14.0.2",
12 | "tsx": "^4.21.0",
13 | "zod": "^3.25.76",
14 | "zx": "8.8.5"
15 | },
16 | "devDependencies": {
17 | "@types/node": "^24.10.1",
18 | "typescript": "5.9.3"
19 | },
20 | "scripts": {
21 | "format": "biome format --write",
22 | "type-check": "tsc --noEmit"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "agent-task-manager",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | },
12 | "durable_objects": {
13 | "bindings": [
14 | {
15 | "name": "TASK_MANAGER_AGENT",
16 | "class_name": "TaskManagerAgent"
17 | }
18 | ]
19 | },
20 | "migrations": [
21 | {
22 | "tag": "v1",
23 | "new_sqlite_classes": ["TaskManagerAgent"]
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/google-vertex.ts:
--------------------------------------------------------------------------------
1 | import { createVertex as createVertexOriginal } from "@ai-sdk/google-vertex/edge";
2 | import { CF_TEMP_TOKEN } from "../auth";
3 |
4 | export const createVertex = (...args: Parameters) => {
5 | let [config] = args;
6 | if (config === undefined) {
7 | config = { googleCredentials: { apiKey: CF_TEMP_TOKEN } };
8 | }
9 | if (config.googleCredentials === undefined) {
10 | config.googleCredentials = { apiKey: CF_TEMP_TOKEN };
11 | }
12 | return createVertexOriginal(config);
13 | }
--------------------------------------------------------------------------------
/demos/python-workers-mcp/src/exceptions.py:
--------------------------------------------------------------------------------
1 | from starlette.exceptions import HTTPException
2 | from starlette.requests import Request
3 | from starlette.responses import PlainTextResponse, Response
4 |
5 | from logger import logger
6 |
7 |
8 | async def http_exception(request: Request, exc: Exception) -> Response:
9 | assert isinstance(exc, HTTPException)
10 | logger.exception(exc)
11 | if exc.status_code in {204, 304}:
12 | return Response(status_code=exc.status_code, headers=exc.headers)
13 | return PlainTextResponse(exc.detail, status_code=exc.status_code, headers=exc.headers)
14 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authless/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-server-authless",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types",
12 | "type-check": "tsc --noEmit"
13 | },
14 | "dependencies": {
15 | "agents": "^0.2.29",
16 | "zod": "^3.25.76"
17 | },
18 | "devDependencies": {
19 | "@biomejs/biome": "^2.3.8",
20 | "typescript": "5.9.3",
21 | "wrangler": "^4.52.1"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/biome.json.ejs:
--------------------------------------------------------------------------------
1 | { "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json", "assist": {
2 | "enabled": true, "actions": { "source": { "useSortedKeys": "off" } } }, "files":
3 | { "includes": ["src/**/*.ts", "test/**/*.ts", "!node_modules/**/*",
4 | "!dist/**/*"] }, "linter": { "enabled": true, "rules": { "recommended": true,
5 | "suspicious": { "noExplicitAny": "off", "noDebugger": "off", "noConsoleLog":
6 | "off", "noConfusingVoidType": "off" }, "style": { "noNonNullAssertion": "off" }
7 | } }, "formatter": { "enabled": true, "indentStyle": "tab", "indentWidth": 4,
8 | "lineWidth": 100 } }
9 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/vite.config.ts.ejs:
--------------------------------------------------------------------------------
1 | import { resolve } from "node:path";
2 | import { cloudflare } from "@cloudflare/vite-plugin";
3 | import react from "@vitejs/plugin-react";
4 | import { defineConfig } from "vite";
5 |
6 | // https://vite.dev/config/
7 | export default defineConfig({
8 | root: "./src/client",
9 | build: {
10 | emptyOutDir: true,
11 | outDir: resolve(__dirname, "dist"),
12 | },
13 | plugins: [
14 | react(),
15 | cloudflare({
16 | configPath: resolve(__dirname, "wrangler.jsonc"),
17 | }),
18 | ],
19 | });
20 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/biome.json.ejs:
--------------------------------------------------------------------------------
1 | { "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json", "assist": {
2 | "enabled": true, "actions": { "source": { "useSortedKeys": "off" } } }, "files":
3 | { "includes": ["src/**/*.ts", "test/**/*.ts", "!node_modules/**/*",
4 | "!dist/**/*"] }, "linter": { "enabled": true, "rules": { "recommended": true,
5 | "suspicious": { "noExplicitAny": "off", "noDebugger": "off", "noConsoleLog":
6 | "off", "noConfusingVoidType": "off" }, "style": { "noNonNullAssertion": "off" }
7 | } }, "formatter": { "enabled": true, "indentStyle": "tab", "indentWidth": 4,
8 | "lineWidth": 100 } }
9 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "agent-task-manager-human-in-the-loop",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "ai": {
10 | "binding": "AI"
11 | },
12 | "durable_objects": {
13 | "bindings": [
14 | {
15 | "name": "TASK_MANAGER_AGENT",
16 | "class_name": "TaskManagerAgent"
17 | }
18 | ]
19 | },
20 | "migrations": [
21 | {
22 | "tag": "v1",
23 | "new_sqlite_classes": ["TaskManagerAgent"]
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/todos-api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "todos-api",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@faker-js/faker": "^10.1.0",
14 | "hono": "^4.10.7",
15 | "jose": "^6.1.3"
16 | },
17 | "devDependencies": {
18 | "@cloudflare/workers-types": "^4.20251202.0",
19 | "prettier": "^3.7.4",
20 | "typescript": "5.9.3",
21 | "wrangler": "^4.52.1"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/demos/structured-output-node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "ai": "^5.0.106",
4 | "workers-ai-provider": "^2.0.0",
5 | "zod": "^3.25.76"
6 | },
7 | "devDependencies": {
8 | "@biomejs/biome": "^2.3.8",
9 | "@cloudflare/workers-types": "^4.20251202.0",
10 | "typescript": "5.9.3",
11 | "vitest": "~3.2.4"
12 | },
13 | "name": "structured-output-node",
14 | "private": true,
15 | "scripts": {
16 | "dev": "npx tsx ./src/index.ts",
17 | "format": "biome format --write",
18 | "lint": "biome lint --error-on-warnings",
19 | "lint:fix": "biome lint --fix",
20 | "type-check": "tsc --noEmit"
21 | },
22 | "type": "module"
23 | }
24 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4 | "target": "ES2022",
5 | "lib": ["ES2023"],
6 | "module": "ESNext",
7 | "skipLibCheck": true,
8 |
9 | "moduleResolution": "bundler",
10 | "allowImportingTsExtensions": true,
11 | "isolatedModules": true,
12 | "moduleDetection": "force",
13 | "noEmit": true,
14 |
15 | "strict": true,
16 | "noUnusedLocals": true,
17 | "noUnusedParameters": true,
18 | "noFallthroughCasesInSwitch": true,
19 | "noUncheckedSideEffectImports": true
20 | },
21 | "include": ["vite.config.ts"]
22 | }
23 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/types.d.ts:
--------------------------------------------------------------------------------
1 | export type KeyResult = {
2 | id: string;
3 | text: string;
4 | attainment: number;
5 | };
6 |
7 | export type Objective = {
8 | id: string;
9 | objectiveText: string;
10 | keyResults: KeyResult[];
11 | };
12 |
13 | export type Permissions = {
14 | objective: "create" | "read" | "update" | "delete";
15 | key_result: "create" | "read" | "update" | "delete";
16 | };
17 |
18 | // Context from the auth process, extracted from the Stytch auth token JWT
19 | // and provided to the MCP Server as this.props
20 | export type AuthenticationContext = {
21 | organizationID: string;
22 | accessToken: string;
23 | };
24 |
--------------------------------------------------------------------------------
/tools/aicli/README.md:
--------------------------------------------------------------------------------
1 | # AI CLI
2 |
3 | A handy CLI for developing demos.
4 |
5 | ## Generating lockfiles
6 |
7 | Each demo should contain it's own package-lock.json so that installing dependencies in CI is faster (in Workers Builds, this reduces install time by ~80%).
8 |
9 | Note: We should still use the root package-lock.json for actual development of this repo. If we find that there are conflicts, we should consider switching to pnpm.
10 |
11 | ### Commands:
12 |
13 | ```sh
14 | # generate missing lockfiles
15 | pnpm aicli generate-npm-lockfiles
16 |
17 | # lint lockfiles to ensure they're all up to date
18 | pnpm aicli lint-npm-lockfiles
19 | ```
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-server-autorag",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types"
12 | },
13 | "dependencies": {
14 | "@cloudflare/workers-oauth-provider": "^0.1.0",
15 | "agents": "^0.2.29",
16 | "hono": "^4.10.7",
17 | "zod": "^3.25.76"
18 | },
19 | "devDependencies": {
20 | "marked": "^17.0.1",
21 | "typescript": "5.9.3",
22 | "wrangler": "^4.52.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-descope-auth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-server-descope-auth",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types"
12 | },
13 | "dependencies": {
14 | "@cloudflare/workers-oauth-provider": "^0.1.0",
15 | "agents": "^0.2.29",
16 | "hono": "^4.10.7",
17 | "zod": "^3.25.76"
18 | },
19 | "devDependencies": {
20 | "marked": "^17.0.1",
21 | "typescript": "5.9.3",
22 | "wrangler": "^4.52.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demos/remote-mcp-logto/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-logto",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types",
12 | "type-check": "tsc --noEmit"
13 | },
14 | "dependencies": {
15 | "@cloudflare/workers-oauth-provider": "^0.1.0",
16 | "@logto/node": "^3.1.6",
17 | "agents": "^0.2.29",
18 | "hono": "^4.10.7",
19 | "zod": "^3.25.76"
20 | },
21 | "devDependencies": {
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-server",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types",
12 | "type-check": "tsc --noEmit"
13 | },
14 | "dependencies": {
15 | "@cloudflare/workers-oauth-provider": "^0.1.0",
16 | "agents": "^0.2.29",
17 | "hono": "^4.10.7",
18 | "zod": "^3.25.76"
19 | },
20 | "devDependencies": {
21 | "marked": "^17.0.1",
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "agent-task-manager-scheduled",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "observability": {
8 | "enabled": true
9 | },
10 | "ai": {
11 | "binding": "AI"
12 | },
13 | "durable_objects": {
14 | "bindings": [
15 | {
16 | "name": "SCHEDULER_AGENT",
17 | "class_name": "SchedulerAgent"
18 | }
19 | ]
20 | },
21 | "migrations": [
22 | {
23 | "tag": "v1",
24 | "new_sqlite_classes": ["SchedulerAgent"]
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/demos/mcp-client/wrangler.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mcp-client",
3 | "main": "src/server.ts",
4 | "compatibility_date": "2025-03-14",
5 | "compatibility_flags": ["nodejs_compat"],
6 | "assets": {
7 | "directory": "dist/client"
8 | },
9 | "vars": {
10 | "HOST": ""
11 | },
12 | "durable_objects": {
13 | "bindings": [
14 | {
15 | "name": "MyAgent",
16 | "class_name": "MyAgent"
17 | }
18 | ]
19 | },
20 | "migrations": [
21 | {
22 | "tag": "v1",
23 | "new_sqlite_classes": ["MyAgent"]
24 | }
25 | ],
26 | "observability": {
27 | "logs": {
28 | "enabled": true
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-server-bearer-auth",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "format": "biome format --write",
9 | "lint:fix": "biome lint --fix",
10 | "start": "wrangler dev",
11 | "cf-typegen": "wrangler types",
12 | "type-check": "tsc --noEmit"
13 | },
14 | "dependencies": {
15 | "@cloudflare/workers-oauth-provider": "^0.1.0",
16 | "agents": "^0.2.29",
17 | "hono": "^4.10.7",
18 | "zod": "^3.25.76"
19 | },
20 | "devDependencies": {
21 | "marked": "^17.0.1",
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-models.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * The names of the BaseAiTextGeneration models.
3 | */
4 | export type TextGenerationModels = Exclude<
5 | value2key,
6 | value2key
7 | >; // This needs to be fixed to allow more models
8 |
9 | /*
10 | * The names of the BaseAiTextToImage models.
11 | */
12 | export type ImageGenerationModels = value2key;
13 |
14 | /**
15 | * The names of the BaseAiTextToEmbeddings models.
16 | */
17 | export type EmbeddingModels = value2key;
18 |
19 | type value2key = { [K in keyof T]: T[K] extends V ? K : never }[keyof T];
20 |
--------------------------------------------------------------------------------
/demos/remote-mcp-cf-access/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mcp-access-oauth",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@cloudflare/workers-oauth-provider": "^0.1.0",
14 | "agents": "^0.2.29",
15 | "just-pick": "^4.2.0",
16 | "octokit": "^5.0.5",
17 | "zod": "^3.25.76"
18 | },
19 | "devDependencies": {
20 | "@types/node": "^24.10.1",
21 | "prettier": "^3.7.4",
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tools/aicli/src/bin/aicli.ts:
--------------------------------------------------------------------------------
1 | import { Command } from "@commander-js/extra-typings";
2 | import { generateNpmLockfiles, lintNpmLockfiles } from "../npm";
3 |
4 | const program = new Command();
5 |
6 | program.name("aicli").description("A handy CLI for developing demos");
7 |
8 | program
9 | .command("generate-npm-lockfiles")
10 | .description("Generate npm lockfiles to improve install time of demos")
11 | .action(async () => {
12 | await generateNpmLockfiles();
13 | });
14 |
15 | program
16 | .command("lint-npm-lockfiles")
17 | .description("Lint all demos to ensure npm lockfiles are up to date")
18 | .action(async () => {
19 | await lintNpmLockfiles();
20 | });
21 |
22 | program.parseAsync();
23 |
--------------------------------------------------------------------------------
/demos/mcp-slack-oauth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mcp-slack-oauth",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@cloudflare/workers-oauth-provider": "^0.1.0",
14 | "@slack/web-api": "^7.13.0",
15 | "hono": "^4.10.7",
16 | "just-pick": "^4.2.0",
17 | "octokit": "^5.0.5"
18 | },
19 | "devDependencies": {
20 | "@cloudflare/workers-types": "^4.20251202.0",
21 | "prettier": "^3.7.4",
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1",
24 | "zod": "^3.25.76"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authless/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "remote-mcp-server-authless",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "compatibility_flags": ["nodejs_compat"],
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["MyMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "observability": {
26 | "enabled": true
27 | }
28 | }
--------------------------------------------------------------------------------
/demos/remote-mcp-google-oauth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-google-oauth",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@cloudflare/workers-oauth-provider": "^0.1.0",
14 | "agents": "^0.2.29",
15 | "hono": "^4.10.7",
16 | "just-pick": "^4.2.0",
17 | "zod": "^3.25.76"
18 | },
19 | "devDependencies": {
20 | "@cloudflare/workers-types": "^4.20251202.0",
21 | "prettier": "^3.7.4",
22 | "typescript": "5.9.3",
23 | "wrangler": "^4.52.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4 | "target": "ES2022",
5 | "lib": ["ES2023"],
6 | "module": "ESNext",
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "isolatedModules": true,
13 | "moduleDetection": "force",
14 | "noEmit": true,
15 |
16 | /* Linting */
17 | "strict": true,
18 | "noUnusedLocals": true,
19 | "noUnusedParameters": true,
20 | "noFallthroughCasesInSwitch": true,
21 | "noUncheckedSideEffectImports": true
22 | },
23 | "include": ["vite.config.ts"]
24 | }
25 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | export { TaskManagerAgent } from "./TaskManagerAgent";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/", async (c) => {
11 | const { agentId, prompt } = await c.req.json<{
12 | agentId: string;
13 | prompt: string;
14 | }>();
15 | const id = c.env.TASK_MANAGER_AGENT.idFromName(agentId);
16 | const agent = c.env.TASK_MANAGER_AGENT.get(id);
17 |
18 | const result = await agent.query(prompt);
19 | return c.json(result);
20 | });
21 |
22 | export default {
23 | fetch: app.fetch,
24 | } satisfies ExportedHandler;
25 |
--------------------------------------------------------------------------------
/demos/remote-mcp-github-oauth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-github-oauth",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@cloudflare/workers-oauth-provider": "^0.1.0",
14 | "agents": "^0.2.29",
15 | "hono": "^4.10.7",
16 | "just-pick": "^4.2.0",
17 | "octokit": "^5.0.5",
18 | "zod": "^3.25.76"
19 | },
20 | "devDependencies": {
21 | "@cloudflare/workers-types": "^4.20251202.0",
22 | "prettier": "^3.7.4",
23 | "typescript": "5.9.3",
24 | "wrangler": "^4.52.1"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demos/mcp-client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@cloudflare/agents-mcp-client-example",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "start": "vite dev",
7 | "build": "vite build",
8 | "deploy": "npx wrangler deploy --var HOST:$(./get-subdomain.sh)",
9 | "type-check": "tsc --noEmit"
10 | },
11 | "keywords": [],
12 | "author": "",
13 | "dependencies": {
14 | "agents": "^0.2.29",
15 | "nanoid": "^5.1.6",
16 | "react": "^19.2.1",
17 | "react-dom": "^19.2.1"
18 | },
19 | "devDependencies": {
20 | "@cloudflare/vite-plugin": "^1.16.1",
21 | "@cloudflare/workers-types": "^4.20251202.0",
22 | "@types/react": "^19.2.7",
23 | "@types/react-dom": "^19.2.3",
24 | "@vitejs/plugin-react": "^5.1.1",
25 | "vite": "^7.2.6"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/demos/text-generation/src/index.ts:
--------------------------------------------------------------------------------
1 | import { generateText } from "ai";
2 | import { Hono } from "hono";
3 | import { cors } from "hono/cors";
4 | import { createWorkersAI } from "workers-ai-provider";
5 | import type { Variables } from "./types/hono";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/", async (c) => {
11 | const { prompt } = (await c.req.json()) as { prompt: string };
12 | const workersai = createWorkersAI({ binding: c.env.AI });
13 |
14 | const result = await generateText({
15 | model: workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
16 | prompt,
17 | });
18 |
19 | return c.json(result);
20 | });
21 |
22 | export default {
23 | fetch: app.fetch,
24 | } satisfies ExportedHandler;
25 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4 | "target": "ES2020",
5 | "useDefineForClassFields": true,
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "module": "ESNext",
8 | "skipLibCheck": true,
9 |
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "isolatedModules": true,
13 | "moduleDetection": "force",
14 | "noEmit": true,
15 | "jsx": "react-jsx",
16 |
17 | "strict": true,
18 | "noUnusedLocals": true,
19 | "noUnusedParameters": true,
20 | "noFallthroughCasesInSwitch": true,
21 | "noUncheckedSideEffectImports": true,
22 |
23 | "types": ["./worker-configuration.d.ts"]
24 | },
25 | "include": ["src"]
26 | }
27 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mcp-auth0-oidc",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "deploy": "wrangler deploy",
7 | "dev": "wrangler dev",
8 | "start": "wrangler dev",
9 | "cf-typegen": "wrangler types",
10 | "type-check": "tsc --noEmit"
11 | },
12 | "dependencies": {
13 | "@cloudflare/workers-oauth-provider": "^0.1.0",
14 | "agents": "^0.2.29",
15 | "hono": "^4.10.7",
16 | "jose": "^6.1.3",
17 | "just-pick": "^4.2.0",
18 | "oauth4webapi": "^3.8.3",
19 | "zod": "^3.25.76"
20 | },
21 | "devDependencies": {
22 | "@cloudflare/workers-types": "^4.20251202.0",
23 | "prettier": "^3.7.4",
24 | "typescript": "5.9.3",
25 | "wrangler": "^4.52.1"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/demos/mcp-server-bearer-auth/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "remote-mcp-server-bearer-auth",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "compatibility_flags": ["nodejs_compat"],
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["MyMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "observability": {
26 | "enabled": true
27 | },
28 | "assets": { "directory": "./static/", "binding": "ASSETS" }
29 | }
30 |
--------------------------------------------------------------------------------
/demos/ui-worker/src/client/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | transition: filter 300ms;
13 | }
14 | .logo:hover {
15 | filter: drop-shadow(0 0 2em #646cffaa);
16 | }
17 | .logo.react:hover {
18 | filter: drop-shadow(0 0 2em #61dafbaa);
19 | }
20 |
21 | @keyframes logo-spin {
22 | from {
23 | transform: rotate(0deg);
24 | }
25 | to {
26 | transform: rotate(360deg);
27 | }
28 | }
29 |
30 | @media (prefers-reduced-motion: no-preference) {
31 | a:nth-of-type(2) .logo {
32 | animation: logo-spin infinite 20s linear;
33 | }
34 | }
35 |
36 | .card {
37 | padding: 2em;
38 | }
39 |
40 | .read-the-docs {
41 | color: #888;
42 | }
43 |
--------------------------------------------------------------------------------
/packages/ai-gateway-provider/src/providers/index.ts:
--------------------------------------------------------------------------------
1 | export { createAmazonBedrock } from "./amazon-bedrock";
2 | export { createAnthropic } from "./anthropic";
3 | export { createAzure } from "./azure";
4 | export { createCerebras } from "./cerebras";
5 | export { createCohere } from "./cohere";
6 | export { createDeepgram } from "./deepgram";
7 | export { createDeepSeek } from "./deepseek";
8 | export { createElevenLabs } from "./elevenlabs";
9 | export { createFireworks } from "./fireworks";
10 | export { createGoogleGenerativeAI } from "./google";
11 | export { createVertex } from "./google-vertex";
12 | export { createGroq } from "./groq";
13 | export { createMistral } from "./mistral";
14 | export { createOpenAI } from "./openai";
15 | export { createPerplexity } from "./perplexity";
16 | export { createXai } from "./xai";
17 |
--------------------------------------------------------------------------------
/libs/logger/src/logger.ts:
--------------------------------------------------------------------------------
1 | import type { Logger } from "./types";
2 |
3 | export const log: Logger = { error, info, success, warn };
4 |
5 | function success(message: string, ...args: unknown[]): void {
6 | console.log(`\x1b[32m[${getTimestamp()}] √ ${message}\x1b[0m`, ...args);
7 | }
8 |
9 | function info(message: string, ...args: unknown[]): void {
10 | console.log(`\x1b[36m[${getTimestamp()}] i ${message}\x1b[0m`, ...args);
11 | }
12 |
13 | function warn(message: string, ...args: unknown[]): void {
14 | console.warn(`\x1b[33m[${getTimestamp()}] ! ${message}\x1b[0m`, ...args);
15 | }
16 |
17 | function error(message: string, ...args: unknown[]): void {
18 | console.error(`\x1b[31m[${getTimestamp()}] × ${message}\x1b[0m`, ...args);
19 | }
20 |
21 | function getTimestamp(): string {
22 | return new Date().toISOString();
23 | }
24 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/src/Setup.tsx:
--------------------------------------------------------------------------------
1 | import type { ReactNode } from "react";
2 |
3 | export default function Setup({ children }: { children: ReactNode }) {
4 | if (!import.meta.env.VITE_STYTCH_PUBLIC_TOKEN) {
5 | return (
6 | <>
7 | Error: Stytch Not Configured Yet
8 |
9 | Full setup instructions are available in the{" "}
10 | README
11 | . Make sure you have configured the following:
12 |
13 | -
14 |
VITE_STYTCH_PUBLIC_TOKEN in your .env.local
15 |
16 | -
17 |
STYTCH_PROJECT_ID in your wrangler.jsonc
18 |
19 |
20 |
21 | >
22 | );
23 | }
24 |
25 | return children;
26 | }
27 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/eslint.config.js:
--------------------------------------------------------------------------------
1 | import js from "@eslint/js";
2 | import reactHooks from "eslint-plugin-react-hooks";
3 | import reactRefresh from "eslint-plugin-react-refresh";
4 | import globals from "globals";
5 | import tseslint from "typescript-eslint";
6 |
7 | export default tseslint.config(
8 | { ignores: ["dist", "worker-configuration.d.ts"] },
9 | {
10 | extends: [js.configs.recommended, ...tseslint.configs.recommended],
11 | files: ["**/*.{ts,tsx}"],
12 | languageOptions: {
13 | ecmaVersion: 2020,
14 | globals: globals.browser,
15 | },
16 | plugins: {
17 | "react-hooks": reactHooks,
18 | "react-refresh": reactRefresh,
19 | },
20 | rules: {
21 | ...reactHooks.configs.recommended.rules,
22 | "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
23 | },
24 | },
25 | );
26 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/eslint.config.js:
--------------------------------------------------------------------------------
1 | import js from "@eslint/js";
2 | import reactHooks from "eslint-plugin-react-hooks";
3 | import reactRefresh from "eslint-plugin-react-refresh";
4 | import globals from "globals";
5 | import tseslint from "typescript-eslint";
6 |
7 | export default tseslint.config(
8 | { ignores: ["dist", "worker-configuration.d.ts"] },
9 | {
10 | extends: [js.configs.recommended, ...tseslint.configs.recommended],
11 | files: ["**/*.{ts,tsx}"],
12 | languageOptions: {
13 | ecmaVersion: 2020,
14 | globals: globals.browser,
15 | },
16 | plugins: {
17 | "react-hooks": reactHooks,
18 | "react-refresh": reactRefresh,
19 | },
20 | rules: {
21 | ...reactHooks.configs.recommended.rules,
22 | "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
23 | },
24 | },
25 | );
26 |
--------------------------------------------------------------------------------
/packages/workers-ai-provider/src/workersai-chat-prompt.ts:
--------------------------------------------------------------------------------
1 | export type WorkersAIChatPrompt = Array;
2 |
3 | export type WorkersAIChatMessage =
4 | | WorkersAISystemMessage
5 | | WorkersAIUserMessage
6 | | WorkersAIAssistantMessage
7 | | WorkersAIToolMessage;
8 |
9 | export interface WorkersAISystemMessage {
10 | role: "system";
11 | content: string;
12 | }
13 |
14 | export interface WorkersAIUserMessage {
15 | role: "user";
16 | content: string;
17 | }
18 |
19 | export interface WorkersAIAssistantMessage {
20 | role: "assistant";
21 | content: string;
22 | tool_calls?: Array<{
23 | id: string;
24 | type: "function";
25 | function: { name: string; arguments: string };
26 | }>;
27 | }
28 |
29 | export interface WorkersAIToolMessage {
30 | role: "tool";
31 | name: string;
32 | content: string;
33 | tool_call_id: string;
34 | }
35 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-mcp-authkit",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "build": "tsc -p .",
7 | "cf-typegen": "wrangler types --env example",
8 | "deploy": "wrangler deploy",
9 | "dev": "wrangler dev",
10 | "format": "biome format --write",
11 | "lint": "biome lint",
12 | "lint:fix": "biome lint --fix",
13 | "start": "wrangler dev",
14 | "type-check": "tsc --noEmit"
15 | },
16 | "dependencies": {
17 | "@cloudflare/workers-oauth-provider": "^0.1.0",
18 | "@workos-inc/node": "^7.77.0",
19 | "agents": "^0.2.29",
20 | "hono": "^4.10.7",
21 | "jose": "^6.1.3",
22 | "zod": "^3.25.76"
23 | },
24 | "devDependencies": {
25 | "@biomejs/biome": "^2.3.8",
26 | "@cloudflare/workers-types": "^4.20251202.0",
27 | "typescript": "5.9.3",
28 | "wrangler": "^4.52.1"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker/package.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= projectName -%>",
3 | "type": "module",
4 | "scripts": {
5 | "build": "vite build",
6 | "cf-typegen": "wrangler types",
7 | "deploy": "npm run build && wrangler deploy",
8 | "dev": "vite",
9 | "format": "biome lint --error-on-warnings",
10 | "lint": "biome lint --error-on-warnings",
11 | "preview": "npm run build && vite preview",
12 | "start": "npm run dev",
13 | "test": "vitest",
14 | "test:ci": "vitest --watch=false",
15 | "type-check": "tsc --noEmit"
16 | },
17 | "dependencies": {},
18 | "devDependencies": {
19 | "@cloudflare/vitest-pool-workers": "^0.7.5",
20 | "typescript": "^5.5.2",
21 | "vitest": "~3.0.7",
22 | "wrangler": "^4.2.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "remote-mcp-server",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "compatibility_flags": ["nodejs_compat"],
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["MyMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "kv_namespaces": [
26 | {
27 | "binding": "OAUTH_KV",
28 | "id": ""
29 | }
30 | ],
31 | "observability": {
32 | "enabled": true
33 | },
34 | "assets": { "directory": "./static/", "binding": "ASSETS" }
35 | }
36 |
--------------------------------------------------------------------------------
/demos/python-workers-mcp/pyproject.toml:
--------------------------------------------------------------------------------
1 | [project]
2 | name = "python-workers-mcp"
3 | version = "0.1.0"
4 | requires-python = "==3.12.*"
5 | dependencies = ["mcp", "structlog"]
6 |
7 | [dependency-groups]
8 | dev = [
9 | "workers-py",
10 | "pytest",
11 | "requests",
12 | "pytest-asyncio",
13 | "ruff",
14 | ]
15 |
16 | [tool.ruff]
17 | target-version = "py312"
18 | line-length = 100
19 | [tool.ruff.lint]
20 | select = [
21 | "E", # pycodestyle errors
22 | "F", # pyflakes
23 | "B", # flake8-bugbear
24 | "I", # isort
25 | "C4", # flake8-comprehensions
26 | "UP", # pyupgrade
27 | "N", # pep8-naming
28 | "RUF", # ruff-specific rules
29 | ]
30 | ignore = []
31 |
32 | [tool.ruff.lint.isort]
33 | known-first-party = ["src"]
34 |
35 | [tool.ruff.format]
36 | quote-style = "double"
37 | indent-style = "space"
38 | line-ending = "auto"
39 | skip-magic-trailing-comma = false
40 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server-autorag/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "remote-mcp-server-autorag",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "migrations": [
11 | {
12 | "new_sqlite_classes": ["MyMCP"],
13 | "tag": "v1"
14 | }
15 | ],
16 | "durable_objects": {
17 | "bindings": [
18 | {
19 | "class_name": "MyMCP",
20 | "name": "MCP_OBJECT"
21 | }
22 | ]
23 | },
24 | "kv_namespaces": [
25 | {
26 | "binding": "OAUTH_KV",
27 | "id": ""
28 | }
29 | ],
30 | "ai": {
31 | "binding": "AI"
32 | },
33 | "observability": {
34 | "enabled": true
35 | },
36 | "assets": { "directory": "./static/", "binding": "ASSETS" }
37 | }
38 |
--------------------------------------------------------------------------------
/.github/workflows/prerelease.yml:
--------------------------------------------------------------------------------
1 | name: Prerelease
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 | build:
11 | if: ${{ github.repository_owner == 'cloudflare' }}
12 | timeout-minutes: 5
13 | runs-on: ubuntu-22.04
14 | concurrency:
15 | group: ${{ github.workflow }}-${{ github.ref }}
16 | cancel-in-progress: true
17 |
18 | steps:
19 | - uses: actions/checkout@v4
20 | with:
21 | fetch-depth: 1
22 |
23 | - uses: pnpm/action-setup@v4
24 | - uses: actions/setup-node@v4
25 |
26 | - name: Install dependencies
27 | run: pnpm install --no-frozen-lockfile --child-concurrency=10
28 |
29 | - name: Test and Build
30 | run: |
31 | pnpm nx build workers-ai-provider
32 | pnpm nx build ai-gateway-provider
33 |
34 | - run: pnpm dlx pkg-pr-new publish './packages/*' --bin
35 |
--------------------------------------------------------------------------------
/demos/remote-mcp-google-oauth/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "mcp-google-oauth",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "compatibility_flags": ["nodejs_compat"],
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["MyMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "kv_namespaces": [
26 | {
27 | "binding": "OAUTH_KV",
28 | "id": ""
29 | }
30 | ],
31 | "observability": {
32 | "enabled": true
33 | },
34 | "dev": {
35 | "port": 8788
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/src/Setup.tsx:
--------------------------------------------------------------------------------
1 | import type { ReactNode } from "react";
2 |
3 | export default function Setup({ children }: { children: ReactNode }) {
4 | if (!import.meta.env.VITE_STYTCH_PUBLIC_TOKEN) {
5 | return (
6 | <>
7 | Error: Stytch Not Configured Yet
8 |
9 | Full setup instructions are available in the{" "}
10 | README.
11 | Make sure you have configured the following:
12 |
13 | -
14 |
VITE_STYTCH_PUBLIC_TOKEN in your .env.local
15 |
16 | -
17 |
STYTCH_PROJECT_ID in your .dev.vars
18 |
19 | -
20 |
STYTCH_PROJECT_SECRET in your .dev.vars
21 |
22 |
23 |
24 | >
25 | );
26 | }
27 |
28 | return children;
29 | }
30 |
--------------------------------------------------------------------------------
/tsconfig.workerd.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.base.json",
3 | "compilerOptions": {
4 | "types": ["./types/workerd.d.ts"]
5 | },
6 | "include": [
7 | "./demos/agent-scheduler/src/**/*.ts",
8 | "./demos/agent-task-manager-human-in-the-loop/src/**/*.ts",
9 | "./demos/agent-task-manager/src/**/*.ts",
10 | "./demos/evaluator-optimiser/src/**/*.ts",
11 | "./demos/model-scraper/src/**/*.ts",
12 | "./demos/orchestrator-workers/src/**/*.ts",
13 | "./demos/parallelisation/src/**/*.ts",
14 | "./demos/prompt-chaining/src/**/*.ts",
15 | "./demos/routing/src/**/*.ts",
16 | "./demos/structured-output/src/**/*.ts",
17 | "./demos/text-generation-stream/src/**/*.ts",
18 | "./demos/text-generation/src/**/*.ts",
19 | "./demos/tool-calling-stream-traditional/src/**/*.ts",
20 | "./demos/tool-calling-stream/src/**/*.ts",
21 | "./demos/tool-calling/src/**/*.ts",
22 | "./demos/ui-worker/src/server/**/*.ts"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/demos/mcp-slack-oauth/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/wrangler/config-schema.json",
3 | "name": "mcp-slack-oauth",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-03-10",
6 | "compatibility_flags": ["nodejs_compat"],
7 | "migrations": [
8 | {
9 | "new_sqlite_classes": ["SlackMCP"],
10 | "tag": "v1",
11 | },
12 | ],
13 | "vars": {
14 | // replace this in .dev.vars
15 | "SLACK_CLIENT_ID": "1234567890",
16 | "SLACK_CLIENT_SECRET": "1234567890",
17 | },
18 | "durable_objects": {
19 | "bindings": [
20 | {
21 | "class_name": "SlackMCP",
22 | "name": "MCP_OBJECT",
23 | },
24 | ],
25 | },
26 | "kv_namespaces": [
27 | {
28 | "binding": "OAUTH_KV",
29 | "id": "",
30 | },
31 | ],
32 | "observability": {
33 | "enabled": true,
34 | },
35 | "dev": {
36 | "port": 8788,
37 | },
38 | }
39 |
--------------------------------------------------------------------------------
/demos/image-generation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "image-generation",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "build": "vite build",
7 | "cf-typegen": "wrangler types",
8 | "deploy": "npm run build && wrangler deploy",
9 | "dev": "vite",
10 | "format": "biome lint --error-on-warnings",
11 | "lint": "biome lint --error-on-warnings",
12 | "preview": "npm run build && vite preview",
13 | "start": "npm run dev",
14 | "test": "vitest",
15 | "test:ci": "vitest --watch=false",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "ai": "^5.0.106",
20 | "hono": "^4.10.7",
21 | "workers-ai-provider": "^2.0.0",
22 | "zod": "^3.25.76"
23 | },
24 | "devDependencies": {
25 | "@cloudflare/vite-plugin": "^1.16.1",
26 | "@cloudflare/vitest-pool-workers": "^0.10.13",
27 | "typescript": "5.9.3",
28 | "vite": "^7.2.6",
29 | "vitest": "~3.2.4",
30 | "wrangler": "^4.52.1"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/src/components/modal.tsx:
--------------------------------------------------------------------------------
1 | import "./modal.css";
2 |
3 | interface ModalProps {
4 | isOpen: boolean;
5 | onClose: () => void;
6 | children?: React.ReactNode;
7 | }
8 |
9 | export const Modal: React.FC = ({ isOpen, onClose, children }) => {
10 | if (!isOpen) return null;
11 |
12 | return (
13 | // biome-ignore lint/a11y/noStaticElementInteractions: expected
14 | // biome-ignore lint/a11y/useKeyWithClickEvents: expected
15 |
16 | {/** biome-ignore lint/a11y/noStaticElementInteractions: expected */}
17 | {/** biome-ignore lint/a11y/useKeyWithClickEvents: expected */}
18 |
e.stopPropagation()}>
19 |
22 |
{children}
23 |
24 |
25 | );
26 | };
27 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "./node_modules/wrangler/config-schema.json",
7 | "name": "mcp-auth0-oidc",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-04-01",
10 | "compatibility_flags": ["nodejs_compat"],
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["AuthenticatedMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "AuthenticatedMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "kv_namespaces": [
26 | {
27 | "binding": "OAUTH_KV",
28 | "id": ""
29 | }
30 | ],
31 | "ai": {
32 | "binding": "AI"
33 | },
34 | "observability": {
35 | "enabled": true
36 | },
37 | "dev": {
38 | "port": 8788
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/demos/remote-mcp-server/src/index.ts:
--------------------------------------------------------------------------------
1 | import OAuthProvider from "@cloudflare/workers-oauth-provider";
2 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3 | import { McpAgent } from "agents/mcp";
4 | import { z } from "zod";
5 | import app from "./app";
6 |
7 | export class MyMCP extends McpAgent {
8 | server = new McpServer({
9 | name: "Demo",
10 | version: "1.0.0",
11 | });
12 |
13 | async init() {
14 | this.server.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
15 | content: [{ type: "text", text: String(a + b) }],
16 | }));
17 | }
18 | }
19 |
20 | // Export the OAuth handler as the default
21 | export default new OAuthProvider({
22 | apiRoute: "/sse",
23 | // TODO: fix these types
24 | apiHandler: MyMCP.mount("/sse"),
25 | // @ts-expect-error
26 | defaultHandler: app,
27 | authorizeEndpoint: "/authorize",
28 | tokenEndpoint: "/token",
29 | clientRegistrationEndpoint: "/register",
30 | });
31 |
--------------------------------------------------------------------------------
/demos/routing/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "routing",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "test": "vitest",
11 | "test:ci": "vitest --watch=false",
12 | "cf-typegen": "wrangler types",
13 | "lint": "biome lint --error-on-warnings",
14 | "lint:fix": "biome lint --fix",
15 | "type-check": "tsc --noEmit"
16 | },
17 | "dependencies": {
18 | "agents": "^0.2.29",
19 | "ai": "^5.0.106",
20 | "hono": "^4.10.7",
21 | "workers-ai-provider": "^2.0.0",
22 | "zod": "^3.25.76"
23 | },
24 | "devDependencies": {
25 | "@biomejs/biome": "^2.3.8",
26 | "@cloudflare/vite-plugin": "^1.16.1",
27 | "@cloudflare/vitest-pool-workers": "^0.10.13",
28 | "typescript": "5.9.3",
29 | "vite": "^7.2.6",
30 | "vitest": "~3.2.4",
31 | "wrangler": "^4.52.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/demos/vision/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vision",
3 | "type": "module",
4 | "private": true,
5 | "scripts": {
6 | "build": "vite build",
7 | "cf-typegen": "wrangler types",
8 | "deploy": "npm run build && wrangler deploy",
9 | "dev": "vite",
10 | "format": "biome lint --error-on-warnings",
11 | "lint": "biome lint --error-on-warnings",
12 | "preview": "npm run build && vite preview",
13 | "start": "npm run dev",
14 | "type-check": "tsc --noEmit"
15 | },
16 | "dependencies": {
17 | "ai": "^5.0.106",
18 | "hono": "^4.10.7",
19 | "react": "^19.2.1",
20 | "react-dom": "^19.2.1",
21 | "workers-ai-provider": "^2.0.0",
22 | "zod": "^3.25.76"
23 | },
24 | "devDependencies": {
25 | "@cloudflare/vite-plugin": "^1.16.1",
26 | "@types/react": "^19.2.7",
27 | "@types/react-dom": "^19.2.3",
28 | "@vitejs/plugin-react": "^5.1.1",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "wrangler": "^4.52.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/demos/python-workers-mcp/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fastapi-worker",
3 | "main": "src/worker.py",
4 | "compatibility_flags": [
5 | "python_workers",
6 | ],
7 | "compatibility_date": "2025-04-10",
8 | "vars": {
9 | "API_HOST": "example.com"
10 | },
11 | "rules": [
12 | {
13 | "globs": [
14 | "vendor/**/"
15 | ],
16 | "type": "Data",
17 | "fallthrough": true
18 | }
19 | ],
20 | "durable_objects": {
21 | "bindings": [
22 | {
23 | "name": "ns",
24 | "class_name": "FastMCPServer"
25 | }
26 | ]
27 | },
28 | "migrations": [
29 | {
30 | "tag": "v1",
31 | "new_sqlite_classes": [
32 | "FastMCPServer"
33 | ]
34 | }
35 | ],
36 | "observability": {
37 | "enabled": true
38 | }
39 | }
--------------------------------------------------------------------------------
/demos/agent-scheduler/src/llm/extract-schedule-id.ts:
--------------------------------------------------------------------------------
1 | import type { Schedule } from "agents";
2 | import { generateObject, type LanguageModel } from "ai";
3 | import z from "zod";
4 |
5 | export async function extractScheduleId(
6 | model: LanguageModel,
7 | query: string,
8 | schedules: Schedule[],
9 | ) {
10 | const { object } = await generateObject({
11 | model,
12 | schema: z.object({
13 | scheduleId: z.string().optional(),
14 | }),
15 | prompt: `
16 | You are an intelligent schedule manager. The user requested cancelling a schedule.
17 | Try to figure out which schedule ID from the list below is the best match.
18 |
19 | Prompt: "${query}"
20 |
21 | Current schedules: ${JSON.stringify(schedules)}
22 |
23 | Respond with a JSON object of the form:
24 |
25 | - if you find a match:
26 | { "scheduleId": "[id]" }
27 |
28 | - if not:
29 | { "scheduleId": undefined }
30 | `,
31 | });
32 |
33 | return object.scheduleId;
34 | }
35 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4 | "target": "ES2020",
5 | "useDefineForClassFields": true,
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "module": "ESNext",
8 | "skipLibCheck": true,
9 |
10 | /* Bundler mode */
11 | "moduleResolution": "bundler",
12 | "allowImportingTsExtensions": true,
13 | "isolatedModules": true,
14 | "moduleDetection": "force",
15 | "noEmit": true,
16 | "jsx": "react-jsx",
17 |
18 | /* Linting */
19 | "strict": true,
20 | "noUnusedLocals": true,
21 | "noUnusedParameters": true,
22 | "noFallthroughCasesInSwitch": true,
23 | "noUncheckedSideEffectImports": true,
24 |
25 | /* Since we include the Hono app for client typegen we also need the worker types here */
26 | "types": ["./worker-configuration.d.ts"]
27 | },
28 | "include": ["src"]
29 | }
30 |
--------------------------------------------------------------------------------
/demos/remote-mcp-authkit/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "remote-mcp-authkit",
8 | "main": "src/index.ts",
9 | "compatibility_flags": ["nodejs_compat"],
10 | "compatibility_date": "2024-09-23",
11 | "migrations": [
12 | {
13 | "new_sqlite_classes": ["MyMCP"],
14 | "tag": "v1"
15 | }
16 | ],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "kv_namespaces": [
26 | {
27 | "binding": "OAUTH_KV",
28 | "id": ""
29 | }
30 | ],
31 | "ai": {
32 | "binding": "AI"
33 | },
34 | "observability": {
35 | "enabled": true
36 | },
37 | "dev": {
38 | "port": 8788
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/demos/remote-mcp-cf-access/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | /**
2 | * For more details on how to configure Wrangler, refer to:
3 | * https://developers.cloudflare.com/workers/wrangler/configuration/
4 | */
5 | {
6 | "$schema": "node_modules/wrangler/config-schema.json",
7 | "name": "mcp-access-oauth",
8 | "main": "src/index.ts",
9 | "compatibility_date": "2025-03-10",
10 | "migrations": [
11 | {
12 | "new_sqlite_classes": ["MyMCP"],
13 | "tag": "v1"
14 | }
15 | ],
16 | "compatibility_flags": ["nodejs_compat"],
17 | "durable_objects": {
18 | "bindings": [
19 | {
20 | "class_name": "MyMCP",
21 | "name": "MCP_OBJECT"
22 | }
23 | ]
24 | },
25 | "kv_namespaces": [
26 | {
27 | "binding": "OAUTH_KV",
28 | "id": ""
29 | }
30 | ],
31 | "ai": {
32 | "binding": "AI"
33 | },
34 | "observability": {
35 | "enabled": true
36 | },
37 | "dev": {
38 | "port": 8788
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/src/index.ts:
--------------------------------------------------------------------------------
1 | import { streamText } from "ai";
2 | import { Hono } from "hono";
3 | import { cors } from "hono/cors";
4 | import { createWorkersAI } from "workers-ai-provider";
5 | import type { Variables } from "./types/hono";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/", async (c) => {
11 | const { prompt } = (await c.req.json()) as { prompt: string };
12 | const workersai = createWorkersAI({ binding: c.env.AI });
13 | const model = workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast");
14 |
15 | const result = streamText({
16 | model,
17 | prompt,
18 | });
19 |
20 | return result.toUIMessageStreamResponse({
21 | headers: {
22 | "Content-Type": "text/x-unknown",
23 | "content-encoding": "identity",
24 | "transfer-encoding": "chunked",
25 | },
26 | });
27 | });
28 |
29 | export default {
30 | fetch: app.fetch,
31 | } satisfies ExportedHandler;
32 |
--------------------------------------------------------------------------------
/demos/text-generation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "text-generation",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "vite": "^7.2.6",
30 | "vitest": "~3.2.4",
31 | "wrangler": "^4.52.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream-traditional/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tool-calling-stream-traditional",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "zod": "^3.25.76"
23 | },
24 | "devDependencies": {
25 | "@biomejs/biome": "^2.3.8",
26 | "@cloudflare/vite-plugin": "^1.16.1",
27 | "@cloudflare/vitest-pool-workers": "^0.10.13",
28 | "typescript": "5.9.3",
29 | "vite": "^7.2.6",
30 | "vitest": "~3.2.4",
31 | "wrangler": "^4.52.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "agent-scheduler",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/parallelisation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "parallelisation",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/prompt-chaining/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prompt-chaining",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/agent-task-manager/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "agent-task-manager",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/evaluator-optimiser/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "evaluator-optimiser",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/orchestrator-workers/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "orchestrator-workers",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/tool-calling-stream/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tool-calling-stream",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/mcp-client/README.md:
--------------------------------------------------------------------------------
1 | # Build an AI Agent that acts as an MCP Client
2 |
3 | An example of how to build an `Agent` that acts as an MCP Client, so that it can connect to external services via MCP.
4 |
5 | [](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/ai/tree/main/demos/mcp-client)
6 |
7 | This demo showcases how to:
8 | - Connect an AI agent to a remote MCP server
9 | - Handle authentication check using the built-in OAuth flow
10 | - Discover and use tools exposed by remote MCP servers
11 |
12 | [Learn more](https://blog.cloudflare.com/building-ai-agents-with-mcp-authn-authz-and-durable-objects/)
13 |
14 | ## Instructions
15 |
16 | First, start an MCP server. A simple example can be found in `examples/mcp`, which already has valid binding setup.
17 |
18 | ```sh
19 | npm install
20 | npm start
21 | ```
22 |
23 | Tap "O + enter" to open the front end. It should list out all the tools, prompts, and resources available.
24 |
--------------------------------------------------------------------------------
/demos/mcp-client/src/server.ts:
--------------------------------------------------------------------------------
1 | import { Agent, type AgentNamespace, routeAgentRequest } from "agents";
2 |
3 | type Env = {
4 | MyAgent: AgentNamespace;
5 | HOST: string;
6 | };
7 |
8 | export class MyAgent extends Agent {
9 | async onRequest(request: Request): Promise {
10 | const reqUrl = new URL(request.url);
11 | console.log(this.getMcpServers());
12 | if (reqUrl.pathname.endsWith("add-mcp") && request.method === "POST") {
13 | const mcpServer = (await request.json()) as { url: string; name: string };
14 | await this.addMcpServer(mcpServer.name, mcpServer.url, this.env.HOST);
15 | return new Response("Ok", { status: 200 });
16 | }
17 |
18 | return new Response("Not found", { status: 404 });
19 | }
20 | }
21 |
22 | export default {
23 | async fetch(request: Request, env: Env) {
24 | return (
25 | (await routeAgentRequest(request, env, { cors: true })) ||
26 | new Response("Not found", { status: 404 })
27 | );
28 | },
29 | } satisfies ExportedHandler;
30 |
--------------------------------------------------------------------------------
/demos/text-generation-stream/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "text-generation-stream",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/remote-mcp-auth0/mcp-auth0-oidc/worker-configuration.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by Wrangler by running `wrangler types`
2 |
3 | interface Env {
4 | NODE_ENV: string
5 | OAUTH_KV: KVNamespace
6 | AUTH0_DOMAIN: string
7 | AUTH0_AUDIENCE: string
8 | AUTH0_SCOPE: string
9 | AUTH0_CLIENT_ID: string
10 | AUTH0_CLIENT_SECRET: string
11 | API_BASE_URL: string
12 | COOKIE_ENCRYPTION_KEY: string
13 | MCP_OBJECT: DurableObjectNamespace
14 | AI: Ai
15 | }
16 |
17 | declare namespace Cloudflare {
18 | interface Env {
19 | NODE_ENV: string
20 | OAUTH_KV: KVNamespace
21 | AUTH0_DOMAIN: string
22 | AUTH0_AUDIENCE: string
23 | AUTH0_SCOPE: string
24 | AUTH0_CLIENT_ID: string
25 | AUTH0_CLIENT_SECRET: string
26 | API_BASE_URL: string
27 | COOKIE_ENCRYPTION_KEY: string
28 | MCP_OBJECT: DurableObjectNamespace
29 | AI: Ai
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/demos/routing/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | export { RoutingWorkflow } from "./routing-workflow";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/", async (c) => {
11 | const { prompt } = (await c.req.json()) as { prompt: string };
12 | const instance = await c.env.ROUTING_WORKFLOW.create({ params: { prompt } });
13 | const status = await instance.status();
14 | return c.json({ id: instance.id, details: status });
15 | });
16 |
17 | app.get("/:id", async (c) => {
18 | const instanceId = c.req.param("id");
19 | if (instanceId) {
20 | const instance = await c.env.ROUTING_WORKFLOW.get(instanceId);
21 | const status = await instance.status();
22 | return c.json({ status });
23 | }
24 |
25 | return c.json({ error: "Instance ID not provided" }, 400);
26 | });
27 |
28 | export default {
29 | fetch: app.fetch,
30 | } satisfies ExportedHandler;
31 |
--------------------------------------------------------------------------------
/tools/create-demo/scaffolding/worker-with-client/package.json.ejs:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= projectName -%>",
3 | "type": "module",
4 | "scripts": {
5 | "build": "vite build",
6 | "cf-typegen": "wrangler types",
7 | "deploy": "npm run build && wrangler deploy",
8 | "dev": "vite",
9 | "format": "biome lint --error-on-warnings",
10 | "lint": "biome lint --error-on-warnings",
11 | "preview": "npm run build && vite preview",
12 | "start": "npm run dev",
13 | "test": "vitest",
14 | "test:ci": "vitest --watch=false",
15 | "type-check": "tsc --noEmit"
16 | },
17 | "dependencies": {
18 | "react": "^19.0.0",
19 | "react-dom": "^19.0.0"
20 | },
21 | "devDependencies": {
22 | "@cloudflare/vitest-pool-workers": "^0.7.5",
23 | "@types/react": "^19.0.8",
24 | "@types/react-dom": "^19.0.3",
25 | "typescript": "^5.5.2",
26 | "vitest": "~3.0.7",
27 | "wrangler": "^4.2.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "agent-task-manager-human-in-the-loop",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "cf-typegen": "wrangler types",
14 | "lint": "biome lint --error-on-warnings",
15 | "lint:fix": "biome lint --fix",
16 | "type-check": "tsc --noEmit"
17 | },
18 | "dependencies": {
19 | "agents": "^0.2.29",
20 | "ai": "^5.0.106",
21 | "hono": "^4.10.7",
22 | "workers-ai-provider": "^2.0.0",
23 | "zod": "^3.25.76"
24 | },
25 | "devDependencies": {
26 | "@biomejs/biome": "^2.3.8",
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@cloudflare/vitest-pool-workers": "^0.10.13",
29 | "typescript": "5.9.3",
30 | "vite": "^7.2.6",
31 | "vitest": "~3.2.4",
32 | "wrangler": "^4.52.1"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/structured-output/src/index.ts:
--------------------------------------------------------------------------------
1 | import { generateObject } from "ai";
2 | import { Hono } from "hono";
3 | import { cors } from "hono/cors";
4 | import { createWorkersAI } from "workers-ai-provider";
5 | import z from "zod";
6 | import type { Variables } from "./types/hono";
7 |
8 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
9 | app.use(cors());
10 | app.get("/", (c) => c.json("ok"));
11 |
12 | app.post("/", async (c) => {
13 | const { prompt } = (await c.req.json()) as { prompt: string };
14 | const workersai = createWorkersAI({ binding: c.env.AI });
15 | const { object } = await generateObject({
16 | model: workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
17 | schema: z.object({
18 | recipe: z.object({
19 | name: z.string(),
20 | ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
21 | steps: z.array(z.string()),
22 | }),
23 | }),
24 | prompt,
25 | });
26 |
27 | return c.json(object);
28 | });
29 |
30 | export default {
31 | fetch: app.fetch,
32 | } satisfies ExportedHandler;
33 |
--------------------------------------------------------------------------------
/demos/tool-calling/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tool-calling",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "test:smoke": "vitest --watch=false --config=vitest.smoke.config.ts",
14 | "cf-typegen": "wrangler types",
15 | "lint": "biome lint --error-on-warnings",
16 | "lint:fix": "biome lint --fix",
17 | "type-check": "tsc --noEmit"
18 | },
19 | "dependencies": {
20 | "agents": "^0.2.29",
21 | "ai": "^5.0.106",
22 | "hono": "^4.10.7",
23 | "workers-ai-provider": "^2.0.0",
24 | "zod": "^3.25.76"
25 | },
26 | "devDependencies": {
27 | "@biomejs/biome": "^2.3.8",
28 | "@cloudflare/vite-plugin": "^1.16.1",
29 | "@cloudflare/vitest-pool-workers": "^0.10.13",
30 | "typescript": "5.9.3",
31 | "vite": "^7.2.6",
32 | "vitest": "~3.2.4",
33 | "wrangler": "^4.52.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/demos/structured-output/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "structured-output",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vite build",
8 | "preview": "npm run build && vite preview",
9 | "deploy": "npm run build && wrangler deploy",
10 | "format": "biome format --write",
11 | "test": "vitest",
12 | "test:ci": "vitest --watch=false",
13 | "test:smoke": "vitest --watch=false --config=vitest.smoke.config.ts",
14 | "cf-typegen": "wrangler types",
15 | "lint": "biome lint --error-on-warnings",
16 | "lint:fix": "biome lint --fix",
17 | "type-check": "tsc --noEmit"
18 | },
19 | "dependencies": {
20 | "agents": "^0.2.29",
21 | "ai": "^5.0.106",
22 | "hono": "^4.10.7",
23 | "workers-ai-provider": "^2.0.0",
24 | "zod": "^3.25.76"
25 | },
26 | "devDependencies": {
27 | "@biomejs/biome": "^2.3.8",
28 | "@cloudflare/vite-plugin": "^1.16.1",
29 | "@cloudflare/vitest-pool-workers": "^0.10.13",
30 | "typescript": "5.9.3",
31 | "vite": "^7.2.6",
32 | "vitest": "~3.2.4",
33 | "wrangler": "^4.52.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/api/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import { stytchBearerTokenAuthMiddleware } from "./lib/auth";
4 | import { TodoAPI } from "./TodoAPI.ts";
5 | import { TodoMCP } from "./TodoMCP.ts";
6 |
7 | // Export the TodoMCP class so the Worker runtime can find it
8 | export { TodoMCP };
9 |
10 | export default new Hono<{ Bindings: Env }>()
11 | .use(cors())
12 |
13 | // Mount the TODO API underneath us
14 | .route("/api", TodoAPI)
15 |
16 | // Serve the OAuth Authorization Server response for Dynamic Client Registration
17 | .get("/.well-known/oauth-protected-resource", async (c) => {
18 | const url = new URL(c.req.url);
19 | return c.json({
20 | resource: url.origin,
21 | authorization_servers: [`https://${c.env.STYTCH_DOMAIN}`],
22 | });
23 | })
24 |
25 | // Let the MCP Server have a go at handling the request
26 | .use("/sse/*", stytchBearerTokenAuthMiddleware)
27 | .route("/sse", new Hono().mount("/", TodoMCP.mount("/sse").fetch))
28 |
29 | // Finally - serve static assets from Vite
30 | .mount("/", (req, env) => env.ASSETS.fetch(req));
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Andy Jessop
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/api/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import { stytchBearerTokenAuthMiddleware } from "./lib/auth";
4 | import { OKRAPI } from "./OKRAPI.ts";
5 | import { OKRManagerMCP } from "./OKRManagerMCP.ts";
6 |
7 | // Export the OKRManagerMCP class so the Worker runtime can find it
8 | export { OKRManagerMCP };
9 |
10 | export default new Hono<{ Bindings: Env }>()
11 | .use(cors())
12 |
13 | // Mount the API underneath us
14 | .route("/api", OKRAPI)
15 |
16 | // Serve the OAuth Authorization Server response for Dynamic Client Registration
17 | .get("/.well-known/oauth-protected-resource", async (c) => {
18 | const url = new URL(c.req.url);
19 | return c.json({
20 | resource: url.origin,
21 | authorization_servers: [c.env.STYTCH_DOMAIN],
22 | });
23 | })
24 |
25 | // Let the MCP Server have a go at handling the request
26 | .use("/sse/*", stytchBearerTokenAuthMiddleware)
27 | .route("/sse", new Hono().mount("/", OKRManagerMCP.mount("/sse").fetch))
28 |
29 | // Finally - serve static assets from Vite
30 | .mount("/", (req, env) => env.ASSETS.fetch(req));
31 |
--------------------------------------------------------------------------------
/demos/structured-output-node/src/index.ts:
--------------------------------------------------------------------------------
1 | import { generateObject } from "ai";
2 | import { createWorkersAI } from "workers-ai-provider";
3 | import z from "zod";
4 |
5 | if (!process.env.CLOUDFLARE_API_TOKEN) {
6 | throw new Error("CLOUDFLARE_API_TOKEN is not set");
7 | }
8 |
9 | if (!process.env.CLOUDFLARE_ACCOUNT_ID) {
10 | throw new Error("CLOUDFLARE_ACCOUNT_ID is not set");
11 | }
12 |
13 | const workersai = createWorkersAI({
14 | accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
15 | apiKey: process.env.CLOUDFLARE_API_TOKEN,
16 | });
17 |
18 | console.log("Generating structured output for a sourdough recipe...");
19 |
20 | const { object } = await generateObject({
21 | // @ts-expect-error - this is a valid model, we need to fix this
22 | model: workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
23 | prompt: "Please give me a recipe for sourdough bread.",
24 | schema: z.object({
25 | recipe: z.object({
26 | ingredients: z.array(z.object({ amount: z.string(), name: z.string() })),
27 | name: z.string(),
28 | steps: z.array(z.string()),
29 | }),
30 | }),
31 | });
32 |
33 | console.log(JSON.stringify(object, null, 2));
34 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-b2b-okr-manager/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 stytchauth
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 stytchauth
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/demos/structured-output-node/biome.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3 | "assist": {
4 | "actions": {
5 | "source": {
6 | "useSortedKeys": "off"
7 | }
8 | },
9 | "enabled": true
10 | },
11 | "formatter": {
12 | "enabled": true,
13 | "indentWidth": 4,
14 | "lineWidth": 100
15 | },
16 | "linter": {
17 | "enabled": true,
18 | "rules": {
19 | "recommended": true,
20 | "style": {
21 | "noInferrableTypes": "error",
22 | "noNonNullAssertion": "off",
23 | "noParameterAssign": "error",
24 | "noUnusedTemplateLiteral": "error",
25 | "noUselessElse": "error",
26 | "useAsConstAssertion": "error",
27 | "useDefaultParameterLast": "error",
28 | "useEnumInitializers": "error",
29 | "useNumberNamespace": "error",
30 | "useSelfClosingElements": "error",
31 | "useSingleVarDeclarator": "error"
32 | },
33 | "suspicious": {
34 | "noConfusingVoidType": "off",
35 | "noDebugger": "off",
36 | "noExplicitAny": "off"
37 | }
38 | }
39 | },
40 | "root": false,
41 | "vcs": {
42 | "clientKind": "git",
43 | "enabled": true,
44 | "useIgnoreFile": true
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | export { SchedulerAgent } from "./SchedulerAgent";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/query", async (c) => {
11 | const { agentId, prompt } = await c.req.json<{
12 | agentId: string;
13 | prompt: string;
14 | }>();
15 | const id = c.env.SCHEDULER_AGENT.idFromName(agentId);
16 | const agent = c.env.SCHEDULER_AGENT.get(id);
17 |
18 | const result = await agent.query(prompt);
19 | return c.json(result);
20 | });
21 |
22 | app.post("/confirmations/:confirmationId", async (c) => {
23 | const { agentId, confirm } = await c.req.json<{
24 | agentId: string;
25 | confirm: boolean;
26 | }>();
27 | const confirmationId = c.req.param("confirmationId");
28 | const id = c.env.SCHEDULER_AGENT.idFromName(agentId);
29 | const agent = c.env.SCHEDULER_AGENT.get(id);
30 |
31 | const result = await agent.confirm(confirmationId, confirm);
32 | return c.json(result);
33 | });
34 |
35 | export default {
36 | fetch: app.fetch,
37 | } satisfies ExportedHandler;
38 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/src/App.tsx:
--------------------------------------------------------------------------------
1 | import { StytchProvider } from "@stytch/react";
2 | import { StytchUIClient } from "@stytch/vanilla-js";
3 | import { Navigate, Route, BrowserRouter as Router, Routes } from "react-router-dom";
4 | import { Authenticate, Authorize, Login, Logout } from "./Auth.tsx";
5 | import TodoEditor from "./Todos.tsx";
6 |
7 | const stytch = new StytchUIClient(import.meta.env.VITE_STYTCH_PUBLIC_TOKEN ?? "", {
8 | endpointOptions: {
9 | testApiDomain: import.meta.env.VITE_STYTCH_DOMAIN,
10 | },
11 | });
12 |
13 | function App() {
14 | return (
15 |
16 |
17 | TODO App MCP Demo
18 |
19 |
20 | } />
21 | } />
22 | } />
23 | } />
24 | } />
25 |
26 |
27 |
28 |
31 |
32 | );
33 | }
34 |
35 | export default App;
36 |
--------------------------------------------------------------------------------
/demos/model-scraper/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "model-scraper",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "dev": "CLOUDFLARE_ENV=development vite",
7 | "start": "npm run dev",
8 | "build": "vite build",
9 | "preview": "npm run build && vite preview",
10 | "deploy": "npm run build && npm run deploy:production",
11 | "deploy:production": "wrangler deploy -e production",
12 | "deploy:staging": "wrangler deploy -e staging",
13 | "format": "biome format --write",
14 | "test": "vitest",
15 | "cf-typegen": "wrangler types",
16 | "lint": "biome lint --error-on-warnings",
17 | "lint:fix": "biome lint --fix",
18 | "test:ci": "vitest --watch=false",
19 | "type-check": "tsc --noEmit"
20 | },
21 | "dependencies": {
22 | "@ai-sdk/openai": "^2.0.77",
23 | "agents": "^0.2.29",
24 | "ai": "^5.0.106",
25 | "hono": "^4.10.7",
26 | "workers-ai-provider": "^2.0.0",
27 | "zod": "^3.25.76"
28 | },
29 | "devDependencies": {
30 | "@biomejs/biome": "^2.3.8",
31 | "@cloudflare/vite-plugin": "^1.16.1",
32 | "@cloudflare/vitest-pool-workers": "^0.10.13",
33 | "typescript": "5.9.3",
34 | "vite": "^7.2.6",
35 | "vitest": "~3.2.4",
36 | "wrangler": "^4.52.1"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/demos/agent-scheduler/src/llm/extract-alarm-message.ts:
--------------------------------------------------------------------------------
1 | import { generateObject, type LanguageModel } from "ai";
2 | import z from "zod";
3 |
4 | export async function extractAlarmMessage(model: LanguageModel, query: string) {
5 | const { object } = await generateObject({
6 | model,
7 | schema: z.object({
8 | message: z.string(),
9 | }),
10 | prompt: `
11 | You are an intelligent alarm scheduler manager. What follows is a user prompt for creating an alarm. Your job is to extract a message to relay to the user when the alarm is triggered.
12 |
13 | Prompt: "${query}"
14 |
15 | Respond with a JSON object:
16 |
17 | - If you can extract a message for the alarm:
18 | { "message": "[message]" }
19 | - If not:
20 | { "message": undefined }
21 |
22 | Example:
23 |
24 | User prompt: please remind me to take the bins out on Sunday night
25 | Your response: { "message": "Take the bins out" }
26 |
27 | User prompt: set an alarm for 12pm every Tuesday
28 | Your response: { "message": "alarm" }
29 |
30 | User prompt: remind me in 10 minutes to turn off the oven
31 | Your response: { "message": "Turn off the oven" }
32 | `,
33 | });
34 |
35 | return object.message;
36 | }
37 |
--------------------------------------------------------------------------------
/demos/model-scraper/wrangler.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/wrangler/config-schema.json",
3 | "name": "model-scraper",
4 | "main": "src/index.ts",
5 | "compatibility_date": "2025-02-24",
6 | "observability": {
7 | "enabled": true
8 | },
9 | "vars": {
10 | "ENVIRONMENT": "production"
11 | },
12 | "env": {
13 | "development": {
14 | "name": "model-scraper-dev",
15 | "vars": {
16 | "ENVIRONMENT": "development"
17 | },
18 | "ai": {
19 | "binding": "AI"
20 | },
21 | "kv_namespaces": [
22 | {
23 | "binding": "JSON_DATA",
24 | "id": "06aed493623c4f3da74003ac7ad85e26",
25 | "preview_id": "8b2a23da30bf45f0ba592780a9c0c320"
26 | }
27 | ]
28 | },
29 | "staging": {
30 | "name": "model-scraper-staging",
31 | "vars": {
32 | "ENVIRONMENT": "staging"
33 | },
34 | "ai": {
35 | "binding": "AI"
36 | },
37 | "kv_namespaces": [
38 | {
39 | "binding": "JSON_DATA",
40 | "id": "06aed493623c4f3da74003ac7ad85e26"
41 | }
42 | ]
43 | }
44 | },
45 | "ai": {
46 | "binding": "AI"
47 | },
48 | "kv_namespaces": [
49 | {
50 | "binding": "JSON_DATA",
51 | "id": "06aed493623c4f3da74003ac7ad85e26"
52 | }
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/libs/test-utils/src/DevServerTestHelper.ts:
--------------------------------------------------------------------------------
1 | import { type ChildProcess, spawn } from "node:child_process";
2 | import getPort from "get-port";
3 | import waitOn from "wait-on";
4 |
5 | export class DevServerTestHelper {
6 | private serverProcess?: ChildProcess;
7 | private port?: number;
8 | private serverUrl?: string;
9 |
10 | /**
11 | * Spins up the local dev server on a dynamically allocated port,
12 | * waits until the server is reachable, then returns the server URL.
13 | */
14 | public async start(): Promise {
15 | // 1. Get an available port.
16 | this.port = await getPort();
17 | this.serverUrl = `http://localhost:${this.port}`;
18 |
19 | // 2. Spawn the dev server, discarding its output.
20 | this.serverProcess = spawn("npm", ["run", "dev", "--", `--port=${this.port}`], {
21 | shell: true,
22 | stdio: "ignore",
23 | });
24 |
25 | // 3. Wait until the server is responding.
26 | await waitOn({ resources: [this.serverUrl] });
27 |
28 | return this.serverUrl;
29 | }
30 |
31 | /**
32 | * Cleans up by killing the spawned server process.
33 | */
34 | public stop(): void {
35 | if (this.serverProcess) {
36 | this.serverProcess.kill("SIGTERM");
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/demos/agent-task-manager-human-in-the-loop/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from "hono";
2 | import { cors } from "hono/cors";
3 | import type { Variables } from "./types/hono";
4 |
5 | export { TaskManagerAgent } from "./TaskManagerAgent";
6 |
7 | const app = new Hono<{ Bindings: Env; Variables: Variables }>();
8 | app.use(cors());
9 |
10 | app.post("/query", async (c) => {
11 | const { agentId, prompt } = await c.req.json<{
12 | agentId: string;
13 | prompt: string;
14 | }>();
15 | const id = c.env.TASK_MANAGER_AGENT.idFromName(agentId);
16 | const agent = c.env.TASK_MANAGER_AGENT.get(id);
17 |
18 | const result = await agent.query(prompt);
19 | return c.json(result);
20 | });
21 |
22 | app.post("/confirmations/:confirmationId", async (c) => {
23 | const { agentId, confirm } = await c.req.json<{
24 | agentId: string;
25 | confirm: boolean;
26 | }>();
27 | const confirmationId = c.req.param("confirmationId");
28 | const id = c.env.TASK_MANAGER_AGENT.idFromName(agentId);
29 | const agent = c.env.TASK_MANAGER_AGENT.get(id);
30 |
31 | const result = await agent.confirm(confirmationId, confirm);
32 | return c.json(result);
33 | });
34 |
35 | export default {
36 | fetch: app.fetch,
37 | } satisfies ExportedHandler;
38 |
--------------------------------------------------------------------------------
/demos/mcp-stytch-consumer-todo-list/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mcp-stytch-consumer-todo-list",
3 | "private": true,
4 | "version": "0.0.0",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "vite build",
9 | "lint": "eslint .",
10 | "type-check": "tsc --noEmit",
11 | "preview": "npm run build && vite preview",
12 | "deploy": "npm run build && wrangler deploy",
13 | "cf-typegen": "wrangler types"
14 | },
15 | "dependencies": {
16 | "@stytch/react": "^19.16.0",
17 | "@stytch/vanilla-js": "^5.42.0",
18 | "agents": "^0.2.29",
19 | "hono": "^4.10.7",
20 | "jose": "^6.1.3",
21 | "react": "^19.2.1",
22 | "react-dom": "^19.2.1",
23 | "react-router-dom": "^7.10.1",
24 | "zod": "^3.25.76"
25 | },
26 | "devDependencies": {
27 | "@cloudflare/vite-plugin": "^1.16.1",
28 | "@eslint/js": "^9.39.1",
29 | "@types/react": "^19.2.7",
30 | "@types/react-dom": "^19.2.3",
31 | "@vitejs/plugin-react": "^5.1.1",
32 | "eslint": "^9.39.1",
33 | "eslint-plugin-react-hooks": "^7.0.1",
34 | "eslint-plugin-react-refresh": "^0.4.24",
35 | "globals": "^16.5.0",
36 | "typescript": "5.9.3",
37 | "typescript-eslint": "^8.48.1",
38 | "vite": "^7.2.6",
39 | "wrangler": "^4.52.1"
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/demos/vision/biome.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3 | "assist": {
4 | "actions": {
5 | "source": {
6 | "useSortedKeys": "off"
7 | }
8 | },
9 | "enabled": true
10 | },
11 | "files": {
12 | "includes": [
13 | "src/**/*.ts",
14 | "test/**/*.ts",
15 | "!node_modules/**/*",
16 | "!dist/**/*"
17 | ]
18 | },
19 | "formatter": {
20 | "enabled": true,
21 | "indentStyle": "tab",
22 | "indentWidth": 4,
23 | "lineWidth": 100
24 | },
25 | "linter": {
26 | "enabled": true,
27 | "rules": {
28 | "recommended": true,
29 | "style": {
30 | "noInferrableTypes": "error",
31 | "noNonNullAssertion": "off",
32 | "noParameterAssign": "error",
33 | "noUnusedTemplateLiteral": "error",
34 | "noUselessElse": "error",
35 | "useAsConstAssertion": "error",
36 | "useDefaultParameterLast": "error",
37 | "useEnumInitializers": "error",
38 | "useNumberNamespace": "error",
39 | "useSelfClosingElements": "error",
40 | "useSingleVarDeclarator": "error"
41 | },
42 | "suspicious": {
43 | "noConfusingVoidType": "off",
44 | "noDebugger": "off",
45 | "noExplicitAny": "off"
46 | }
47 | }
48 | },
49 | "root": false
50 | }
51 |
--------------------------------------------------------------------------------