Skip to content

feat(cloudflare): add authored deployment and agent extensions#194

Merged
FredKSchott merged 5 commits into
mainfrom
feat/cloudflare-deployment-extensions
Jun 3, 2026
Merged

feat(cloudflare): add authored deployment and agent extensions#194
FredKSchott merged 5 commits into
mainfrom
feat/cloudflare-deployment-extensions

Conversation

@FredKSchott
Copy link
Copy Markdown
Member

@FredKSchott FredKSchott commented Jun 2, 2026

Summary

  • add colocated addressable-agent extensions through cloudflare = extend({ base, wrap }), with native Agents SDK subclasses beneath Flue-owned routing and prototype-preserving wrappers such as Sentry around the final generated Durable Object class
  • discover an optional source-root cloudflare.ts module whose named exports become Worker exports and whose optional default export contributes non-HTTP handlers while app.ts remains the HTTP composition surface
  • replace implicit Cloudflare Sandbox suffix wiring with explicit deployment-module exports
  • preserve stable Wrangler class names and Agents SDK runtime identities, reject generated export and binding collisions, and validate generated deployment inputs before writing

Agent-local extension example

import * as Sentry from '@sentry/cloudflare';
import { createAgent } from '@flue/runtime';
import { extend } from '@flue/runtime/cloudflare';

export default createAgent(() => ({
  model: 'anthropic/claude-sonnet-4-6',
}));

export const cloudflare = extend({
  base: (Base) =>
    class extends Base {
      async onStart() {
        await this.scheduleEvery(60, 'heartbeat');
      }

      async heartbeat() {
        this.setState({ ...this.state, lastHeartbeatAt: Date.now() });
      }
    },
  wrap: (Final) =>
    Sentry.instrumentDurableObjectWithSentry(
      (env: Env) => ({ dsn: env.SENTRY_DSN }),
      Final,
    ),
});

Review notes

Validation

  • pnpm run build && pnpm run check:types && pnpm run test && pnpm run test:integration:cloudflare in packages/runtime
  • pnpm run build && pnpm run check:types && pnpm run test in packages/cli
  • pnpm run check:types && pnpm run build in apps/docs
  • pnpm run check:types at repository root
  • pnpm run check:lint at repository root
  • pnpm exec flue build --target cloudflare in examples/assistant
  • git diff --check origin/main...HEAD

Closes #187

@FredKSchott FredKSchott merged commit fe92e6d into main Jun 3, 2026
@FredKSchott FredKSchott deleted the feat/cloudflare-deployment-extensions branch June 3, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface the inherited Cloudflare Agents scheduler/queue (schedule/scheduleEvery/queue) to author code

1 participant