Unified · Split
| @@ -1,4 +1,17 @@ | ||
| 1 | 1 | { |
| 2 | + "sources": { | |
| 3 | + "github": { | |
| 4 | + "kind": "openapi", | |
| 5 | + "name": "GitHub", | |
| 6 | + "connection": { | |
| 7 | + "endpoint": "https://api.github.com/" | |
| 8 | + }, | |
| 9 | + "binding": { | |
| 10 | + "specUrl": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json", | |
| 11 | + "defaultHeaders": null | |
| 12 | + } | |
| 13 | + } | |
| 14 | + }, | |
| 2 | 15 | "policies": { |
| 3 | 16 | "demo.*": { |
| 4 | 17 | "match": "demo.*", |
| @@ -27,6 +27,8 @@ const { VITE_APP_VERSION, VITE_GITHUB_URL } = (import.meta as ImportMeta & { · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | type UpdateChannel = "latest" | "beta"; |
| 29 | 29 | |
| 30 | +const EXECUTOR_DIST_TAGS_PATH = "/v1/app/npm/dist-tags"; | |
| 31 | + | |
| 30 | 32 | type ParsedVersion = { |
| 31 | 33 | readonly major: number; |
| 32 | 34 | readonly minor: number; |
| @@ -139,8 +141,13 @@ function useLatestVersion(currentVersion: string) { · 106 unmodified lines | ||
| 139 | 141 | |
| 140 | 142 | useEffect(() => { |
| 141 | 143 | let cancelled = false; |
| 142 | − fetch("https://registry.npmjs.org/-/package/executor/dist-tags") | |
| 143 | − .then((res) => res.json()) | |
| 144 | + fetch(EXECUTOR_DIST_TAGS_PATH) | |
| 145 | + .then(async (res) => { | |
| 146 | + if (!res.ok) { | |
| 147 | + throw new Error(`Failed to load dist tags: ${res.status}`); | |
| 148 | + } | |
| 149 | + return res.json() as Promise<Partial<Record<UpdateChannel, string>>>; | |
| 150 | + }) | |
| 144 | 151 | .then((data: Partial<Record<UpdateChannel, string>>) => { |
| 145 | 152 | if (!cancelled) { |
| 146 | 153 | setLatestVersion(data[channel] ?? null); |
| @@ -122,12 +122,50 @@ const readBindingTransport = (source: Source): "auto" | "streamable-http" | "sse · 121 unmodified lines | ||
| 122 | 122 | : undefined; |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | +type RefreshableHttpAuth = | |
| 126 | + | { kind: "none" } | |
| 127 | + | { | |
| 128 | + kind: "bearer"; | |
| 129 | + headerName?: string | null; | |
| 130 | + prefix?: string | null; | |
| 131 | + token?: string | null; | |
| 132 | + tokenRef?: { providerId: string; handle: string } | null; | |
| 133 | + } | |
| 134 | + | { | |
| 135 | + kind: "oauth2"; | |
| 136 | + headerName?: string | null; | |
| 137 | + prefix?: string | null; | |
| 138 | + accessToken?: string | null; | |
| 139 | + accessTokenRef?: { providerId: string; handle: string } | null; | |
| 140 | + refreshToken?: string | null; | |
| 141 | + refreshTokenRef?: { providerId: string; handle: string } | null; | |
| 142 | + }; | |
| 143 | + | |
| 125 | 144 | const refreshableHttpAuth = ( |
| 126 | 145 | auth: Source["auth"], |
| 127 | −): Extract<Source["auth"], { kind: "none" | "bearer" | "oauth2" }> | undefined => | |
| 128 | − auth.kind === "none" || auth.kind === "bearer" || auth.kind === "oauth2" | |
| 129 | − ? auth | |
| 130 | − : undefined; | |
| 146 | +): RefreshableHttpAuth | undefined => { | |
| 147 | + switch (auth.kind) { | |
| 148 | + case "none": | |
| 149 | + return { kind: "none" }; | |
| 150 | + case "bearer": | |
| 151 | + return { | |
| 152 | + kind: "bearer", | |
| 153 | + headerName: auth.headerName, | |
| 154 | + prefix: auth.prefix, | |
| 155 | + tokenRef: auth.token, | |
| 156 | + }; | |
| 157 | + case "oauth2": | |
| 158 | + return { | |
| 159 | + kind: "oauth2", | |
| 160 | + headerName: auth.headerName, | |
| 161 | + prefix: auth.prefix, | |
| 162 | + accessTokenRef: auth.accessToken, | |
| 163 | + refreshTokenRef: auth.refreshToken, | |
| 164 | + }; | |
| 165 | + default: | |
| 166 | + return undefined; | |
| 167 | + } | |
| 168 | +}; | |
| 131 | 169 | |
| 132 | 170 | const refreshPayloadFromSource = (source: Source): ConnectSourcePayload | null => { |
| 133 | 171 | switch (source.kind) { |
| @@ -193,6 +231,8 @@ const refreshPayloadFromSource = (source: Source): ConnectSourcePayload | null = · 59 unmodified lines | ||
| 193 | 231 | auth: refreshableHttpAuth(source.auth), |
| 194 | 232 | }; |
| 195 | 233 | } |
| 234 | + default: | |
| 235 | + return null; | |
| 196 | 236 | } |
| 197 | 237 | }; |
| 198 | 238 | |
| @@ -325,8 +325,6 @@ · 324 unmodified lines | ||
| 325 | 325 | }, |
| 326 | 326 | "devDependencies": { |
| 327 | 327 | "@effect/vitest": "catalog:", |
| 328 | − "@executor/platform-api": "workspace:*", | |
| 329 | − "@executor/platform-internal": "workspace:*", | |
| 330 | 328 | "@modelcontextprotocol/sdk": "^1.26.0", |
| 331 | 329 | "@types/node": "catalog:", |
| 332 | 330 | "bun-types": "catalog:", |
| @@ -3,12 +3,14 @@ import type * as Registry from "@effect-atom/atom/Registry"; · 2 unmodified lines | ||
| 3 | 3 | import { RegistryContext, RegistryProvider, useAtomValue } from "@effect-atom/atom-react"; |
| 4 | 4 | import { |
| 5 | 5 | createControlPlaneClient, |
| 6 | + type ControlPlaneClient, | |
| 7 | +} from "@executor/platform-api/client"; | |
| 8 | +import { | |
| 6 | 9 | type CompleteSourceOAuthResult, |
| 7 | 10 | type ConnectSourceBatchPayload, |
| 8 | 11 | type ConnectSourceBatchResult, |
| 9 | 12 | type ConnectSourcePayload, |
| 10 | 13 | type ConnectSourceResult, |
| 11 | − type ControlPlaneClient, | |
| 12 | 14 | type CreateSecretPayload, |
| 13 | 15 | type CreateSecretResult, |
| 14 | 16 | type CreateSourcePayload, |
| @@ -49,8 +49,6 @@ · 48 unmodified lines | ||
| 49 | 49 | }, |
| 50 | 50 | "devDependencies": { |
| 51 | 51 | "@effect/vitest": "catalog:", |
| 52 | − "@executor/platform-api": "workspace:*", | |
| 53 | − "@executor/platform-internal": "workspace:*", | |
| 54 | 52 | "@modelcontextprotocol/sdk": "^1.26.0", |
| 55 | 53 | "@types/node": "catalog:", |
| 56 | 54 | "bun-types": "catalog:", |
| @@ -23,7 +23,7 @@ import { · 22 unmodified lines | ||
| 23 | 23 | import type { ToolPath } from "@executor/codemode-core"; |
| 24 | 24 | import { createCatalogImportMetadata } from "@executor/source-core"; |
| 25 | 25 | import { createGraphqlCatalogFragment } from "@executor/source-graphql"; |
| 26 | −import { createExecutorAdminToolMap } from "@executor/platform-internal"; | |
| 26 | +import { createExecutorAdminToolMap } from "../../../internal/src/index"; | |
| 27 | 27 | |
| 28 | 28 | import { |
| 29 | 29 | type ControlPlaneRuntime, |
| @@ -6,7 +6,7 @@ import { NodeHttpServer } from "@effect/platform-node"; · 5 unmodified lines | ||
| 6 | 6 | import { |
| 7 | 7 | ControlPlaneApi, |
| 8 | 8 | createControlPlaneApiLayer, |
| 9 | −} from "@executor/platform-api"; | |
| 9 | +} from "../../../../api/src/index"; | |
| 10 | 10 | import * as Effect from "effect/Effect"; |
| 11 | 11 | import * as Layer from "effect/Layer"; |
| 12 | 12 | |
| @@ -98,6 +98,10 @@ export type LocalExecutorRequestHandler = { · 97 unmodified lines | ||
| 98 | 98 | type ControlPlaneWebHandler = ReturnType<typeof HttpApiBuilder.toWebHandler>; |
| 99 | 99 | type ExecutorMcpHandler = ReturnType<typeof createExecutorMcpRequestHandler>; |
| 100 | 100 | |
| 101 | +const EXECUTOR_NPM_DIST_TAGS_PATHNAME = "/v1/app/npm/dist-tags"; | |
| 102 | +const EXECUTOR_NPM_DIST_TAGS_URL = | |
| 103 | + "https://registry.npmjs.org/-/package/executor/dist-tags"; | |
| 104 | + | |
| 101 | 105 | const disposeRuntime = (runtime: ControlPlaneRuntime) => |
| 102 | 106 | Effect.tryPromise({ |
| 103 | 107 | try: () => runtime.close(), |
| @@ -306,6 +310,34 @@ const isApiRequest = (request: Request): boolean => { · 202 unmodified lines | ||
| 306 | 310 | return pathname === "/mcp" || pathname === "/v1" || pathname.startsWith("/v1/"); |
| 307 | 311 | }; |
| 308 | 312 | |
| 313 | +const handleExecutorNpmDistTagsRequest = async (): Promise<Response> => { | |
| 314 | + try { | |
| 315 | + const upstream = await fetch(EXECUTOR_NPM_DIST_TAGS_URL, { | |
| 316 | + headers: { | |
| 317 | + accept: "application/json", | |
| 318 | + }, | |
| 319 | + }); | |
| 320 | + const body = upstream.ok ? await upstream.text() : "{}"; | |
| 321 | + return new Response(body, { | |
| 322 | + status: upstream.ok ? 200 : 502, | |
| 323 | + headers: { | |
| 324 | + "cache-control": upstream.ok | |
| 325 | + ? upstream.headers.get("cache-control") ?? "public, max-age=300" | |
| 326 | + : "no-store", | |
| 327 | + "content-type": "application/json; charset=utf-8", | |
| 328 | + }, | |
| 329 | + }); | |
| 330 | + } catch { | |
| 331 | + return new Response("{}", { | |
| 332 | + status: 502, | |
| 333 | + headers: { | |
| 334 | + "cache-control": "no-store", | |
| 335 | + "content-type": "application/json; charset=utf-8", | |
| 336 | + }, | |
| 337 | + }); | |
| 338 | + } | |
| 339 | +}; | |
| 340 | + | |
| 309 | 341 | export const createLocalExecutorRequestHandler = ( |
| 310 | 342 | options: StartLocalExecutorServerOptions = {}, |
| 311 | 343 | ): Effect.Effect<LocalExecutorRequestHandler, Error, Scope.Scope> => |
| @@ -359,6 +391,9 @@ export const createLocalExecutorRequestHandler = ( · 47 unmodified lines | ||
| 359 | 391 | runtime, |
| 360 | 392 | handleApiRequest: (request) => { |
| 361 | 393 | const pathname = new URL(request.url).pathname; |
| 394 | + if (pathname === EXECUTOR_NPM_DIST_TAGS_PATHNAME) { | |
| 395 | + return handleExecutorNpmDistTagsRequest(); | |
| 396 | + } | |
| 362 | 397 | return pathname === "/mcp" |
| 363 | 398 | ? mcpHandler.handleRequest(request) |
| 364 | 399 | : apiHandler.handler(request); |