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 examples (2 of 25 files). Show all

Unified · Split

2 files
  1. examples/all-plugins/src/main.ts +4 −1
  2. examples/promise-sdk/src/main.ts +5 −1
examples/all-plugins/src/main.ts+4−1
@@ -83,7 +83,7 @@ const plugins = [ · 82 unmodified lines
8383 ] as const;
8484
8585 const config = {
86− scope,
86+ scopes: [scope],
8787 adapter: makeMemoryAdapter({ schema: collectSchemas(plugins) }),
8888 blobs: makeInMemoryBlobStore(),
8989 plugins,
@@ -208,6 +208,7 @@ const program = Effect.gen(function* () { · 118 unmodified lines
208208 yield* executor.secrets.set(
209209 new SetSecretInput({
210210 id: SecretId.make("example-api-token"),
211+ scope: "example-scope" as SetSecretInput["scope"],
211212 name: "Example API Token",
212213 value: "sk-example-redacted",
213214 provider: "file",
@@ -262,6 +263,7 @@ const program = Effect.gen(function* () { · 48 unmodified lines
262263 spec: exampleOpenApiSpec,
263264 namespace: "example-api",
264265 baseUrl: "https://example.com/api",
266+ scope: "example-scope",
265267 });
266268 console.log("Registered OpenAPI source:", addSpecResult);
267269
@@ -371,6 +373,7 @@ const program = Effect.gen(function* () { · 103 unmodified lines
371373 endpoint: "https://example.com/graphql",
372374 introspectionJson,
373375 namespace: "example-graphql",
376+ scope: "example-scope",
374377 });
375378 console.log("Registered GraphQL source:", gqlResult);
376379
examples/promise-sdk/src/main.ts+5−1
@@ -12,7 +12,7 @@ import { graphqlPlugin } from "@executor/plugin-graphql/promise"; · 11 unmodified lines
1212 // ---------------------------------------------------------------------------
1313
1414 const executor = await createExecutor({
15− scope: { name: "my-app" },
15+ scopes: [{ id: "my-app", name: "my-app" }],
1616 plugins: [mcpPlugin(), openApiPlugin(), graphqlPlugin()] as const,
1717 });
1818
@@ -24,6 +24,7 @@ await executor.mcp.addSource({ · 5 unmodified lines
2424 transport: "remote",
2525 name: "Context7",
2626 endpoint: "https://mcp.context7.com/mcp",
27+ scope: "my-app",
2728 });
2829
2930 // Stdio server
@@ -41,6 +42,7 @@ await executor.mcp.addSource({ · 11 unmodified lines
4142 await executor.openapi.addSpec({
4243 spec: "https://petstore3.swagger.io/api/v3/openapi.json",
4344 namespace: "petstore",
45+ scope: "my-app",
4446 });
4547
4648 // With auth headers (static or secret-backed)
@@ -62,6 +64,7 @@ await executor.openapi.addSpec({ · 15 unmodified lines
6264 await executor.graphql.addSource({
6365 endpoint: "https://graphql.anilist.co",
6466 namespace: "anilist",
67+ scope: "my-app",
6568 });
6669
6770 // ---------------------------------------------------------------------------
@@ -97,6 +100,7 @@ if (anilistTool) { · 29 unmodified lines
97100 await executor.secrets.set(
98101 new SetSecretInput({
99102 id: SecretId.make("api-key"),
103+ scope: "my-app" as SetSecretInput["scope"],
100104 name: "Shared API Key",
101105 value: "sk_...",
102106 }),