Align runtime naming with the current architecture by replacing PM-prefixed runtime services/env wiring with runtime-host terminology while keeping legacy PM env vars as fallbacks for compatibility.
Showing the changes to apps/cli/src (1 of 18 files). Show all
Unified · Split
| @@ -36,20 +36,6 @@ type WorkspaceRecord = { · 35 unmodified lines | |||
| 36 | id: string; | 36 | id: string; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | type SourceRecord = { | ||
| 40 | id: string; | ||
| 41 | name: string; | ||
| 42 | endpoint: string; | ||
| 43 | configJson: string; | ||
| 44 | }; | ||
| 45 | |||
| 46 | type SourceToolSummaryRecord = { | ||
| 47 | toolId: string; | ||
| 48 | method: string; | ||
| 49 | path: string; | ||
| 50 | name: string; | ||
| 51 | }; | ||
| 52 | |||
| 53 | type DeviceAuthorizationResponse = { | 39 | type DeviceAuthorizationResponse = { |
| 54 | device_code: string; | 40 | device_code: string; |
| 55 | user_code: string; | 41 | user_code: string; |
| @@ -78,10 +64,6 @@ type CommonTargetOptions = { · 22 unmodified lines | |||
| 78 | 64 | ||
| 79 | const DEFAULT_LOCAL_BASE_URL = "http://127.0.0.1:8788"; | 65 | const DEFAULT_LOCAL_BASE_URL = "http://127.0.0.1:8788"; |
| 80 | const DEFAULT_WORKOS_AUTH_BASE_URL = "https://api.workos.com"; | 66 | const DEFAULT_WORKOS_AUTH_BASE_URL = "https://api.workos.com"; |
| 81 | const DEFAULT_GITHUB_OPENAPI_SPEC_URL = | ||
| 82 | "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json"; | ||
| 83 | const DEFAULT_GITHUB_API_BASE_URL = "https://api.github.com"; | ||
| 84 | const DEFAULT_GITHUB_OPENAPI_SOURCE_ID = "src_github_openapi"; | ||
| 85 | const CONFIG_PATH = join(homedir(), ".config", "executor", "cli.json"); | 67 | const CONFIG_PATH = join(homedir(), ".config", "executor", "cli.json"); |
| 86 | 68 | ||
| 87 | const toErrorMessage = (cause: unknown): string => | 69 | const toErrorMessage = (cause: unknown): string => |
| @@ -518,6 +500,8 @@ class ExecutorServerClient { · 430 unmodified lines | |||
| 518 | const childEnv = { | 500 | const childEnv = { |
| 519 | ...cleanEnv(), | 501 | ...cleanEnv(), |
| 520 | PORT: localPort, | 502 | PORT: localPort, |
| 503 | EXECUTOR_RUNTIME_KIND: | ||
| 504 | process.env.EXECUTOR_LOCAL_RUNTIME_KIND?.trim() || "local-inproc", | ||
| 521 | PM_RUNTIME_KIND: | 505 | PM_RUNTIME_KIND: |
| 522 | process.env.EXECUTOR_LOCAL_RUNTIME_KIND?.trim() || "local-inproc", | 506 | process.env.EXECUTOR_LOCAL_RUNTIME_KIND?.trim() || "local-inproc", |
| 523 | }; | 507 | }; |
| @@ -597,87 +581,6 @@ const ensureWorkspaceId = async ( · 73 unmodified lines | |||
| 597 | return workspaceId; | 581 | return workspaceId; |
| 598 | }; | 582 | }; |
| 599 | 583 | ||
| 600 | const deriveSourceName = (kind: string, endpoint: string): string => { | ||
| 601 | try { | ||
| 602 | const url = new URL(endpoint); | ||
| 603 | const host = url.hostname.replace(/^api\./, ""); | ||
| 604 | return `${kind}:${host}`; | ||
| 605 | } catch { | ||
| 606 | return `${kind}:source`; | ||
| 607 | } | ||
| 608 | }; | ||
| 609 | |||
| 610 | const bootstrapOpenApiSource = async (input: { | ||
| 611 | client: ExecutorServerClient; | ||
| 612 | config: ExecutorCliConfig; | ||
| 613 | workspaceOverride?: string; | ||
| 614 | specUrl: string; | ||
| 615 | baseUrl: string; | ||
| 616 | name?: string; | ||
| 617 | sourceId?: string; | ||
| 618 | }): Promise<{ | ||
| 619 | workspaceId: string; | ||
| 620 | source: SourceRecord; | ||
| 621 | tools: Array<SourceToolSummaryRecord>; | ||
| 622 | sampleToolPath: string | null; | ||
| 623 | }> => { | ||
| 624 | const workspaceId = await ensureWorkspaceId( | ||
| 625 | input.client, | ||
| 626 | input.config, | ||
| 627 | input.workspaceOverride, | ||
| 628 | ); | ||
| 629 | const normalizedSpecUrl = input.specUrl.trim(); | ||
| 630 | const normalizedBaseUrl = input.baseUrl.trim(); | ||
| 631 | |||
| 632 | if (normalizedSpecUrl.length === 0) { | ||
| 633 | throw new Error("OpenAPI bootstrap requires --spec-url."); | ||
| 634 | } | ||
| 635 | |||
| 636 | if (normalizedBaseUrl.length === 0) { | ||
| 637 | throw new Error("OpenAPI bootstrap requires --source-base-url."); | ||
| 638 | } | ||
| 639 | |||
| 640 | const source = await input.client.runControlPlane((api) => | ||
| 641 | api.sources.upsert({ | ||
| 642 | path: { workspaceId }, | ||
| 643 | payload: { | ||
| 644 | ...(input.sourceId && input.sourceId.trim().length > 0 | ||
| 645 | ? { id: input.sourceId.trim() } | ||
| 646 | : {}), | ||
| 647 | name: | ||
| 648 | input.name && input.name.trim().length > 0 | ||
| 649 | ? input.name.trim() | ||
| 650 | : deriveSourceName("openapi", normalizedBaseUrl), | ||
| 651 | kind: "openapi", | ||
| 652 | endpoint: normalizedSpecUrl, | ||
| 653 | status: "connected", | ||
| 654 | enabled: true, | ||
| 655 | configJson: JSON.stringify({ baseUrl: normalizedBaseUrl }), | ||
| 656 | }, | ||
| 657 | }), | ||
| 658 | ) as SourceRecord; | ||
| 659 | |||
| 660 | const tools = await input.client.runControlPlane((api) => | ||
| 661 | api.tools.listSourceTools({ | ||
| 662 | path: { | ||
| 663 | workspaceId, | ||
| 664 | sourceId: source.id, | ||
| 665 | }, | ||
| 666 | }), | ||
| 667 | ) as Array<SourceToolSummaryRecord>; | ||
| 668 | |||
| 669 | const sampleToolPath = tools[0]?.toolId | ||
| 670 | ? `source.${source.id}.${tools[0].toolId}` | ||
| 671 | : null; | ||
| 672 | |||
| 673 | return { | ||
| 674 | workspaceId, | ||
| 675 | source, | ||
| 676 | tools, | ||
| 677 | sampleToolPath, | ||
| 678 | }; | ||
| 679 | }; | ||
| 680 | |||
| 681 | const postForm = async ( | 584 | const postForm = async ( |
| 682 | url: string, | 585 | url: string, |
| 683 | params: Record<string, string>, | 586 | params: Record<string, string>, |
| @@ -859,8 +762,9 @@ const commonTargetOptions = () => ({ · 175 unmodified lines | |||
| 859 | }); | 762 | }); |
| 860 | 763 | ||
| 861 | const startEmbeddedLocalServer = async (port: number): Promise<void> => { | 764 | const startEmbeddedLocalServer = async (port: number): Promise<void> => { |
| 862 | process.env.PM_RUNTIME_KIND = | 765 | process.env.EXECUTOR_RUNTIME_KIND = |
| 863 | process.env.EXECUTOR_LOCAL_RUNTIME_KIND?.trim() || "local-inproc"; | 766 | process.env.EXECUTOR_LOCAL_RUNTIME_KIND?.trim() || "local-inproc"; |
| 767 | process.env.PM_RUNTIME_KIND = process.env.EXECUTOR_RUNTIME_KIND; | ||
| 864 | 768 | ||
| 865 | const { | 769 | const { |
| 866 | createLocalPrincipal, | 770 | createLocalPrincipal, |
| @@ -1254,134 +1158,8 @@ const runExecuteCommand = Command.make( · 387 unmodified lines | |||
| 1254 | Command.withDescription("Execute TypeScript code through Executor runtime"), | 1158 | Command.withDescription("Execute TypeScript code through Executor runtime"), |
| 1255 | ); | 1159 | ); |
| 1256 | 1160 | ||
| 1257 | const runBootstrapOpenApiCommand = Command.make( | ||
| 1258 | "openapi", | ||
| 1259 | { | ||
| 1260 | ...commonTargetOptions(), | ||
| 1261 | specUrl: Options.text("spec-url"), | ||
| 1262 | sourceBaseUrl: Options.text("source-base-url"), | ||
| 1263 | name: Options.text("name").pipe(Options.optional), | ||
| 1264 | sourceId: Options.text("source-id").pipe(Options.optional), | ||
| 1265 | }, | ||
| 1266 | (input) => | ||
| 1267 | Effect.tryPromise({ | ||
| 1268 | try: async () => { | ||
| 1269 | const common: CommonTargetOptions = { | ||
| 1270 | target: input.target, | ||
| 1271 | workspace: input.workspace, | ||
| 1272 | baseUrl: input.baseUrl, | ||
| 1273 | json: input.json, | ||
| 1274 | }; | ||
| 1275 | |||
| 1276 | await withClient(common, async ({ client, config, workspaceOverride, asJson }) => { | ||
| 1277 | const setup = await bootstrapOpenApiSource({ | ||
| 1278 | client, | ||
| 1279 | config, | ||
| 1280 | workspaceOverride, | ||
| 1281 | specUrl: input.specUrl, | ||
| 1282 | baseUrl: input.sourceBaseUrl, | ||
| 1283 | name: optionToUndefined(input.name), | ||
| 1284 | sourceId: optionToUndefined(input.sourceId), | ||
| 1285 | }); | ||
| 1286 | |||
| 1287 | printOutput( | ||
| 1288 | { | ||
| 1289 | ok: true, | ||
| 1290 | workspaceId: setup.workspaceId, | ||
| 1291 | source: { | ||
| 1292 | id: setup.source.id, | ||
| 1293 | name: setup.source.name, | ||
| 1294 | endpoint: setup.source.endpoint, | ||
| 1295 | configJson: setup.source.configJson, | ||
| 1296 | }, | ||
| 1297 | toolCount: setup.tools.length, | ||
| 1298 | sampleToolPath: setup.sampleToolPath, | ||
| 1299 | }, | ||
| 1300 | asJson, | ||
| 1301 | ); | ||
| 1302 | }); | ||
| 1303 | }, | ||
| 1304 | catch: toErrorMessage, | ||
| 1305 | }), | ||
| 1306 | ).pipe( | ||
| 1307 | Command.withDescription("Bootstrap an OpenAPI source with runtime base URL"), | ||
| 1308 | ); | ||
| 1309 | |||
| 1310 | const runBootstrapGithubCommand = Command.make( | ||
| 1311 | "github", | ||
| 1312 | { | ||
| 1313 | ...commonTargetOptions(), | ||
| 1314 | name: Options.text("name").pipe(Options.optional), | ||
| 1315 | sourceId: Options.text("source-id").pipe(Options.optional), | ||
| 1316 | specUrl: Options.text("spec-url").pipe(Options.withDefault(DEFAULT_GITHUB_OPENAPI_SPEC_URL)), | ||
| 1317 | sourceBaseUrl: Options.text("source-base-url").pipe(Options.withDefault(DEFAULT_GITHUB_API_BASE_URL)), | ||
| 1318 | }, | ||
| 1319 | (input) => | ||
| 1320 | Effect.tryPromise({ | ||
| 1321 | try: async () => { | ||
| 1322 | const common: CommonTargetOptions = { | ||
| 1323 | target: input.target, | ||
| 1324 | workspace: input.workspace, | ||
| 1325 | baseUrl: input.baseUrl, | ||
| 1326 | json: input.json, | ||
| 1327 | }; | ||
| 1328 | |||
| 1329 | await withClient(common, async ({ client, config, workspaceOverride, asJson }) => { | ||
| 1330 | const setup = await bootstrapOpenApiSource({ | ||
| 1331 | client, | ||
| 1332 | config, | ||
| 1333 | workspaceOverride, | ||
| 1334 | specUrl: input.specUrl, | ||
| 1335 | baseUrl: input.sourceBaseUrl, | ||
| 1336 | name: optionToUndefined(input.name) ?? "github:openapi", | ||
| 1337 | sourceId: optionToUndefined(input.sourceId) ?? DEFAULT_GITHUB_OPENAPI_SOURCE_ID, | ||
| 1338 | }); | ||
| 1339 | |||
| 1340 | const suggestedTool = | ||
| 1341 | setup.tools.find((tool) => | ||
| 1342 | tool.toolId.includes("issues-and-pull-requests"), | ||
| 1343 | ) | ||
| 1344 | ?? setup.tools[0] | ||
| 1345 | ?? null; | ||
| 1346 | |||
| 1347 | printOutput( | ||
| 1348 | { | ||
| 1349 | ok: true, | ||
| 1350 | workspaceId: setup.workspaceId, | ||
| 1351 | source: { | ||
| 1352 | id: setup.source.id, | ||
| 1353 | name: setup.source.name, | ||
| 1354 | endpoint: setup.source.endpoint, | ||
| 1355 | configJson: setup.source.configJson, | ||
| 1356 | }, | ||
| 1357 | toolCount: setup.tools.length, | ||
| 1358 | suggestedToolPath: suggestedTool | ||
| 1359 | ? `source.${setup.source.id}.${suggestedTool.toolId}` | ||
| 1360 | : null, | ||
| 1361 | executeHint: suggestedTool | ||
| 1362 | ? `executor run execute --code \"return await tools['source.${setup.source.id}.${suggestedTool.toolId}']({ q: 'repo:owner/repo is:issue state:open', per_page: 5 });\"` | ||
| 1363 | : null, | ||
| 1364 | }, | ||
| 1365 | asJson, | ||
| 1366 | ); | ||
| 1367 | }); | ||
| 1368 | }, | ||
| 1369 | catch: toErrorMessage, | ||
| 1370 | }), | ||
| 1371 | ).pipe( | ||
| 1372 | Command.withDescription("Bootstrap GitHub OpenAPI source for public issue queries"), | ||
| 1373 | ); | ||
| 1374 | |||
| 1375 | const runBootstrapCommand = Command.make("bootstrap").pipe( | ||
| 1376 | Command.withSubcommands([ | ||
| 1377 | runBootstrapOpenApiCommand, | ||
| 1378 | runBootstrapGithubCommand, | ||
| 1379 | ] as any), | ||
| 1380 | Command.withDescription("Bootstrap source setup shortcuts for execution workflows"), | ||
| 1381 | ); | ||
| 1382 | |||
| 1383 | const runCommand = Command.make("run").pipe( | 1161 | const runCommand = Command.make("run").pipe( |
| 1384 | Command.withSubcommands([runExecuteCommand, runBootstrapCommand] as any), | 1162 | Command.withSubcommands([runExecuteCommand] as any), |
| 1385 | Command.withDescription("Code execution commands"), | 1163 | Command.withDescription("Code execution commands"), |
| 1386 | ); | 1164 | ); |
| 1387 | 1165 | ||