- 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].
Showing the changes to apps/local/src (2 of 25 files). Show all
Unified · Split
| @@ -84,10 +84,16 @@ const addSourceFromConfig = ( · 83 unmodified lines | |||
| 84 | executor: LocalExecutor, | 84 | executor: LocalExecutor, |
| 85 | source: SourceConfig, | 85 | source: SourceConfig, |
| 86 | ): Effect.Effect<void, unknown> => { | 86 | ): Effect.Effect<void, unknown> => { |
| 87 | // `executor.jsonc` is a single-scope artifact today — the file isn't | ||
| 88 | // aware of per-user tenancy. Pin replayed sources to the outermost | ||
| 89 | // scope so a future `[user, org]` stack still sees them via org | ||
| 90 | // fall-through. | ||
| 91 | const scope = executor.scopes.at(-1)!.id as string; | ||
| 87 | switch (source.kind) { | 92 | switch (source.kind) { |
| 88 | case "openapi": | 93 | case "openapi": |
| 89 | return executor.openapi.addSpec({ | 94 | return executor.openapi.addSpec({ |
| 90 | spec: source.spec, | 95 | spec: source.spec, |
| 96 | scope, | ||
| 91 | baseUrl: source.baseUrl, | 97 | baseUrl: source.baseUrl, |
| 92 | namespace: source.namespace, | 98 | namespace: source.namespace, |
| 93 | headers: translateHeaders(source.headers), | 99 | headers: translateHeaders(source.headers), |
| @@ -96,6 +102,7 @@ const addSourceFromConfig = ( · 2 unmodified lines | |||
| 96 | case "graphql": | 102 | case "graphql": |
| 97 | return executor.graphql.addSource({ | 103 | return executor.graphql.addSource({ |
| 98 | endpoint: source.endpoint, | 104 | endpoint: source.endpoint, |
| 105 | scope, | ||
| 99 | namespace: source.namespace, | 106 | namespace: source.namespace, |
| 100 | headers: translateHeaders(source.headers) as Record<string, string> | undefined, | 107 | headers: translateHeaders(source.headers) as Record<string, string> | undefined, |
| 101 | }).pipe(Effect.asVoid); | 108 | }).pipe(Effect.asVoid); |
| @@ -104,6 +111,7 @@ const addSourceFromConfig = ( · 2 unmodified lines | |||
| 104 | if (source.transport === "stdio") { | 111 | if (source.transport === "stdio") { |
| 105 | return executor.mcp.addSource({ | 112 | return executor.mcp.addSource({ |
| 106 | transport: "stdio", | 113 | transport: "stdio", |
| 114 | scope, | ||
| 107 | name: source.name, | 115 | name: source.name, |
| 108 | command: source.command, | 116 | command: source.command, |
| 109 | args: source.args ? [...source.args] : undefined, | 117 | args: source.args ? [...source.args] : undefined, |
| @@ -114,6 +122,7 @@ const addSourceFromConfig = ( · 4 unmodified lines | |||
| 114 | } | 122 | } |
| 115 | return executor.mcp.addSource({ | 123 | return executor.mcp.addSource({ |
| 116 | transport: "remote", | 124 | transport: "remote", |
| 125 | scope, | ||
| 117 | name: source.name, | 126 | name: source.name, |
| 118 | endpoint: source.endpoint, | 127 | endpoint: source.endpoint, |
| 119 | remoteTransport: source.remoteTransport, | 128 | remoteTransport: source.remoteTransport, |
| @@ -154,7 +154,7 @@ const createLocalExecutorLayer = () => { · 153 unmodified lines | |||
| 154 | }); | 154 | }); |
| 155 | 155 | ||
| 156 | const executor = yield* createExecutor({ | 156 | const executor = yield* createExecutor({ |
| 157 | scope, | 157 | scopes: [scope], |
| 158 | adapter, | 158 | adapter, |
| 159 | blobs, | 159 | blobs, |
| 160 | plugins, | 160 | plugins, |