diff --git a/.github/workflows/cookbook.yml b/.github/workflows/examples.yml similarity index 69% rename from .github/workflows/cookbook.yml rename to .github/workflows/examples.yml index abb976652..bb2afc5c4 100644 --- a/.github/workflows/cookbook.yml +++ b/.github/workflows/examples.yml @@ -1,15 +1,15 @@ -name: Cookbook +name: Examples on: pull_request: paths: - - 'cookbook/**' - - '.github/workflows/cookbook.yml' + - 'examples/**' + - '.github/workflows/examples.yml' push: branches: [main] paths: - - 'cookbook/**' - - '.github/workflows/cookbook.yml' + - 'examples/**' + - '.github/workflows/examples.yml' permissions: contents: read @@ -22,14 +22,14 @@ jobs: example: [node-chat, browser-agent, nextjs-agent, nuxt-agent] defaults: run: - working-directory: cookbook/${{ matrix.example }} + working-directory: examples/${{ matrix.example }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 cache: npm - cache-dependency-path: cookbook/${{ matrix.example }}/package-lock.json + cache-dependency-path: examples/${{ matrix.example }}/package-lock.json - run: npm ci - if: matrix.example == 'node-chat' run: node --test ../shared/*.test.mjs diff --git a/README.md b/README.md index d1fe7b84c..4047ce54a 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ fx builds as a native binary or WebAssembly. Applications embedding fx can provi The WebAssembly SDK is experimental. See the [WebAssembly SDK](sdk/README.md) and [ACP documentation](https://fx.sh/docs/using-fx/acp). -For runnable Node.js, browser, Next.js, and Nuxt applications, see the [libfx cookbook](cookbook/README.md). +For runnable Node.js, browser, Next.js, and Nuxt applications, see the [libfx examples](examples/README.md). ## Extend fx diff --git a/cookbook/nextjs-agent/next.config.mjs b/cookbook/nextjs-agent/next.config.mjs deleted file mode 100644 index 8be68ab8c..000000000 --- a/cookbook/nextjs-agent/next.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { fileURLToPath } from 'node:url' - -const cookbook = fileURLToPath(new URL('..', import.meta.url)) -export default { - turbopack: { root: cookbook }, - outputFileTracingRoot: cookbook, -} diff --git a/cookbook/.gitignore b/examples/.gitignore similarity index 100% rename from cookbook/.gitignore rename to examples/.gitignore diff --git a/cookbook/README.md b/examples/README.md similarity index 94% rename from cookbook/README.md rename to examples/README.md index e5a3d16f6..261d753b9 100644 --- a/cookbook/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ -# libfx cookbook +# libfx examples Small applications built with [libfx](https://fx.sh/docs/lib). Each example keeps the agent calls in its entry point. Start with the one that matches your runtime. @@ -17,7 +17,7 @@ Clone this repository, then open the example directory: ```sh git clone https://github.com/vercel-labs/fx.git -cd fx/cookbook/node-chat +cd fx/examples/node-chat npm install ``` @@ -43,7 +43,7 @@ public-demo model and transport policy, not another agent framework. Create a Vercel project for each example, with its directory as the project root. Enable **Include source files outside of the Root Directory in the Build Step** -so the project can load `cookbook/shared/`. Use Node.js 24. +so the project can load `examples/shared/`. Use Node.js 24. Set `AI_GATEWAY_API_KEY` as a server-only environment variable. Use a dedicated Gateway key with a daily budget. Never place a provider credential in a browser @@ -63,7 +63,7 @@ and usage policy when adapting the examples. From the repository root: ```sh -node --test cookbook/shared/*.test.mjs +node --test examples/shared/*.test.mjs ``` Build the browser, Next.js, and Nuxt examples with `npm run build` in their diff --git a/cookbook/browser-agent/api/gateway.js b/examples/browser-agent/api/gateway.js similarity index 100% rename from cookbook/browser-agent/api/gateway.js rename to examples/browser-agent/api/gateway.js diff --git a/cookbook/browser-agent/index.html b/examples/browser-agent/index.html similarity index 95% rename from cookbook/browser-agent/index.html rename to examples/browser-agent/index.html index 0e3922401..5496c81f6 100644 --- a/cookbook/browser-agent/index.html +++ b/examples/browser-agent/index.html @@ -2,7 +2,7 @@ -Browser agent · fx cookbook +Browser agent · fx examples

Browser agent

libfx runs in this browser through WebAssembly. Reload to start a new conversation.

diff --git a/cookbook/browser-agent/main.js b/examples/browser-agent/main.js similarity index 100% rename from cookbook/browser-agent/main.js rename to examples/browser-agent/main.js diff --git a/cookbook/browser-agent/package-lock.json b/examples/browser-agent/package-lock.json similarity index 100% rename from cookbook/browser-agent/package-lock.json rename to examples/browser-agent/package-lock.json diff --git a/cookbook/browser-agent/package.json b/examples/browser-agent/package.json similarity index 100% rename from cookbook/browser-agent/package.json rename to examples/browser-agent/package.json diff --git a/cookbook/examples.json b/examples/examples.json similarity index 100% rename from cookbook/examples.json rename to examples/examples.json diff --git a/cookbook/nextjs-agent/app/api/chat/route.js b/examples/nextjs-agent/app/api/chat/route.js similarity index 100% rename from cookbook/nextjs-agent/app/api/chat/route.js rename to examples/nextjs-agent/app/api/chat/route.js diff --git a/cookbook/nextjs-agent/app/layout.js b/examples/nextjs-agent/app/layout.js similarity index 62% rename from cookbook/nextjs-agent/app/layout.js rename to examples/nextjs-agent/app/layout.js index 55ac73305..70f076294 100644 --- a/cookbook/nextjs-agent/app/layout.js +++ b/examples/nextjs-agent/app/layout.js @@ -1,4 +1,4 @@ -export const metadata = { title: 'Next.js agent · fx cookbook' } +export const metadata = { title: 'Next.js agent · fx examples' } export default function Layout({ children }) { return {children} diff --git a/cookbook/nextjs-agent/app/page.js b/examples/nextjs-agent/app/page.js similarity index 100% rename from cookbook/nextjs-agent/app/page.js rename to examples/nextjs-agent/app/page.js diff --git a/examples/nextjs-agent/next.config.mjs b/examples/nextjs-agent/next.config.mjs new file mode 100644 index 000000000..2e314113f --- /dev/null +++ b/examples/nextjs-agent/next.config.mjs @@ -0,0 +1,7 @@ +import { fileURLToPath } from 'node:url' + +const examplesRoot = fileURLToPath(new URL('..', import.meta.url)) +export default { + turbopack: { root: examplesRoot }, + outputFileTracingRoot: examplesRoot, +} diff --git a/cookbook/nextjs-agent/package-lock.json b/examples/nextjs-agent/package-lock.json similarity index 100% rename from cookbook/nextjs-agent/package-lock.json rename to examples/nextjs-agent/package-lock.json diff --git a/cookbook/nextjs-agent/package.json b/examples/nextjs-agent/package.json similarity index 100% rename from cookbook/nextjs-agent/package.json rename to examples/nextjs-agent/package.json diff --git a/cookbook/node-chat/chat.mjs b/examples/node-chat/chat.mjs similarity index 100% rename from cookbook/node-chat/chat.mjs rename to examples/node-chat/chat.mjs diff --git a/cookbook/node-chat/handler.mjs b/examples/node-chat/handler.mjs similarity index 100% rename from cookbook/node-chat/handler.mjs rename to examples/node-chat/handler.mjs diff --git a/cookbook/node-chat/index.html b/examples/node-chat/index.html similarity index 97% rename from cookbook/node-chat/index.html rename to examples/node-chat/index.html index 7bbf983fb..21cfe6af6 100644 --- a/cookbook/node-chat/index.html +++ b/examples/node-chat/index.html @@ -2,7 +2,7 @@ -Node.js agent · fx cookbook +Node.js agent · fx examples

Node.js agent

A native libfx agent. Each request starts a new conversation.

diff --git a/cookbook/node-chat/package-lock.json b/examples/node-chat/package-lock.json similarity index 100% rename from cookbook/node-chat/package-lock.json rename to examples/node-chat/package-lock.json diff --git a/cookbook/node-chat/package.json b/examples/node-chat/package.json similarity index 100% rename from cookbook/node-chat/package.json rename to examples/node-chat/package.json diff --git a/cookbook/node-chat/server.mjs b/examples/node-chat/server.mjs similarity index 100% rename from cookbook/node-chat/server.mjs rename to examples/node-chat/server.mjs diff --git a/cookbook/nuxt-agent/app/app.vue b/examples/nuxt-agent/app/app.vue similarity index 96% rename from cookbook/nuxt-agent/app/app.vue rename to examples/nuxt-agent/app/app.vue index 964261066..c1b92d86b 100644 --- a/cookbook/nuxt-agent/app/app.vue +++ b/examples/nuxt-agent/app/app.vue @@ -7,7 +7,7 @@ const status = ref('') const busy = ref(false) const ready = ref(false) onMounted(() => { ready.value = true }) -useHead({ title: 'Nuxt agent · fx cookbook', htmlAttrs: { lang: 'en' } }) +useHead({ title: 'Nuxt agent · fx examples', htmlAttrs: { lang: 'en' } }) async function send() { busy.value = true diff --git a/cookbook/nuxt-agent/nuxt.config.ts b/examples/nuxt-agent/nuxt.config.ts similarity index 100% rename from cookbook/nuxt-agent/nuxt.config.ts rename to examples/nuxt-agent/nuxt.config.ts diff --git a/cookbook/nuxt-agent/package-lock.json b/examples/nuxt-agent/package-lock.json similarity index 100% rename from cookbook/nuxt-agent/package-lock.json rename to examples/nuxt-agent/package-lock.json diff --git a/cookbook/nuxt-agent/package.json b/examples/nuxt-agent/package.json similarity index 100% rename from cookbook/nuxt-agent/package.json rename to examples/nuxt-agent/package.json diff --git a/cookbook/nuxt-agent/server/api/chat.post.js b/examples/nuxt-agent/server/api/chat.post.js similarity index 100% rename from cookbook/nuxt-agent/server/api/chat.post.js rename to examples/nuxt-agent/server/api/chat.post.js diff --git a/cookbook/shared/gateway.mjs b/examples/shared/gateway.mjs similarity index 100% rename from cookbook/shared/gateway.mjs rename to examples/shared/gateway.mjs diff --git a/cookbook/shared/gateway.test.mjs b/examples/shared/gateway.test.mjs similarity index 100% rename from cookbook/shared/gateway.test.mjs rename to examples/shared/gateway.test.mjs diff --git a/cookbook/shared/model.mjs b/examples/shared/model.mjs similarity index 100% rename from cookbook/shared/model.mjs rename to examples/shared/model.mjs diff --git a/cookbook/shared/read-reply.mjs b/examples/shared/read-reply.mjs similarity index 100% rename from cookbook/shared/read-reply.mjs rename to examples/shared/read-reply.mjs diff --git a/cookbook/shared/read-reply.test.mjs b/examples/shared/read-reply.test.mjs similarity index 100% rename from cookbook/shared/read-reply.test.mjs rename to examples/shared/read-reply.test.mjs