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
3 3
4import { UserStoreService } from "../auth/context";4import { UserStoreService } from "../auth/context";
5import { AuthContext } from "../auth/middleware";5import { AuthContext } from "../auth/middleware";
6import { env } from "cloudflare:workers";
6import { WorkOSAuth } from "../auth/workos";7import { WorkOSAuth } from "../auth/workos";
7import { server } from "../env";
8import { AutumnService } from "../services/autumn";8import { AutumnService } from "../services/autumn";
9import { OrgHttpApi } from "./compose";9import { OrgHttpApi } from "./compose";
10import { Forbidden } from "./api";10import { Forbidden } from "./api";
@@ -144,7 +144,7 @@ export const OrgHandlers = HttpApiBuilder.group(OrgHttpApi, "org", (handlers) => · 133 unmodified lines
144 const workos = yield* WorkOSAuth;144 const workos = yield* WorkOSAuth;
145 const { link } = yield* workos.generateDomainVerificationPortalLink(145 const { link } = yield* workos.generateDomainVerificationPortalLink(
146 auth.organizationId,146 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",
148 );148 );
149 return { link };149 return { link };
150 }),150 }),