History

cloud/local/examples: thread per-user ScopeStack through HTTP + MCP

- cloud: resolves userId from the authenticated session and builds a [userOrgScope, orgScope] stack via createScopedExecutor(userId, orgId, orgName). userId threaded through execution-stack, mcp-session, and MCP dispatch init. - cloud env refactor: deletes the lazy Proxy apps/cloud/src/env.ts in favor of cloudflare:workers env imported at call sites; adds env-augment.d.ts to type secrets not present in generated wrangler types. - cloud/server.ts: env-guarded OTEL wiring (skips instrument() when AXIOM_TOKEN absent); captures rawFetch before instrument() mutates it so dev requests still land on the Hono app. - cloud/services/db.ts: prefers DATABASE_URL over the hyperdrive proxy so local dev works without the tunnel. - vite.config.ts: devCrashGuard plugin that prints uncaught Worker errors with a stable exit. - hosts/mcp: optional debug flag surfaces verbose session logging, wired up from cloud mcp-session. - local/examples/marketing: migrated to scopes: [scope].

Rhys Sullivan committed 6 months ago

Commit d4e311e1 parent 427699c25 files · +320 −174Browse files

Showing the changes to apps/cloud/src/org (1 of 25 files). Show all

Unified · Split

apps/cloud/src/org/handlers.ts+2−2
@@ -3,8 +3,8 @@ import { Effect } from "effect"; · 2 unmodified lines
33
44 import { UserStoreService } from "../auth/context";
55 import { AuthContext } from "../auth/middleware";
6+import { env } from "cloudflare:workers";
67 import { WorkOSAuth } from "../auth/workos";
7−import { server } from "../env";
88 import { AutumnService } from "../services/autumn";
99 import { OrgHttpApi } from "./compose";
1010 import { Forbidden } from "./api";
@@ -144,7 +144,7 @@ export const OrgHandlers = HttpApiBuilder.group(OrgHttpApi, "org", (handlers) => · 133 unmodified lines
144144 const workos = yield* WorkOSAuth;
145145 const { link } = yield* workos.generateDomainVerificationPortalLink(
146146 auth.organizationId,
147− server.VITE_PUBLIC_SITE_URL ? `${server.VITE_PUBLIC_SITE_URL}/org` : "/org",
147+ env.VITE_PUBLIC_SITE_URL ? `${env.VITE_PUBLIC_SITE_URL}/org` : "/org",
148148 );
149149 return { link };
150150 }),