Implement explicit session lifecycle and task-scoped worktrees
This commit is contained in:
18
src/mcp.ts
18
src/mcp.ts
@@ -1,5 +1,5 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { isAbsolute, resolve } from "node:path";
|
||||
import type { CodexOptions } from "@openai/codex-sdk";
|
||||
import { getConfig, type AppConfig } from "./config.js";
|
||||
import { normalizeSharedMcpConfigFile } from "./mcp/converters.js";
|
||||
@@ -23,12 +23,17 @@ import type {
|
||||
import { parseMcpConfig } from "./mcp/types.js";
|
||||
import type { ToolClearancePolicy } from "./security/schemas.js";
|
||||
|
||||
function readConfigFile(configPath: string): {
|
||||
function readConfigFile(input: {
|
||||
configPath: string;
|
||||
workingDirectory?: string;
|
||||
}): {
|
||||
config?: SharedMcpConfigFile;
|
||||
sourcePath?: string;
|
||||
} {
|
||||
const candidatePath = configPath.trim() || "./mcp.config.json";
|
||||
const resolvedPath = resolve(process.cwd(), candidatePath);
|
||||
const candidatePath = input.configPath.trim() || "./mcp.config.json";
|
||||
const resolvedPath = isAbsolute(candidatePath)
|
||||
? candidatePath
|
||||
: resolve(input.workingDirectory ?? process.cwd(), candidatePath);
|
||||
|
||||
if (!existsSync(resolvedPath)) {
|
||||
if (candidatePath !== "./mcp.config.json") {
|
||||
@@ -83,7 +88,10 @@ export function loadMcpConfigFromEnv(
|
||||
const registry = options?.registry ?? defaultMcpRegistry;
|
||||
const warn = options?.warn ?? ((message: string) => console.warn(message));
|
||||
|
||||
const { config, sourcePath } = readConfigFile(runtimeConfig.mcp.configPath);
|
||||
const { config, sourcePath } = readConfigFile({
|
||||
configPath: runtimeConfig.mcp.configPath,
|
||||
workingDirectory: context.workingDirectory,
|
||||
});
|
||||
if (!config) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user