Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/worker/src/run-task/__tests__/run-task.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions apps/worker/src/run-task/agent-home.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions apps/worker/src/run-task/agent-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,55 @@ export function activateSkillsFolder({
return true;
}

const MISE_GLOBAL_CONFIG_RELATIVE_PATH = ['.config', 'mise', 'config.toml'];

/**
* Seeds the task runtime HOME with the worker home's global mise config.
*
* Mise shims (node, npx, ...) resolve tool versions from the global config at
* `$HOME/.config/mise/config.toml` when no repo-level mise config applies to
* the process cwd. The task runtime HOME starts empty, so without this seed
* any process spawned with the runtime HOME outside a version-pinned
* repository — including environment-defined stdio MCP servers
* (`npx -y ...`) — fails with "mise ERROR No version is set for shim: node".
*
* An existing runtime-home config (restored from a snapshot, or written by
* the agent via `mise use -g`) is left untouched. Best-effort: returns
* whether the config was seeded.
*/
export function seedRuntimeHomeMiseGlobalConfig({
homeDir,
sourceHomeDir,
}: {
homeDir: string;
sourceHomeDir: string;
}): boolean {
if (!homeDir || !sourceHomeDir || homeDir === sourceHomeDir) {
return false;
}

const sourceConfigPath = path.join(
sourceHomeDir,
...MISE_GLOBAL_CONFIG_RELATIVE_PATH,
);
const targetConfigPath = path.join(
homeDir,
...MISE_GLOBAL_CONFIG_RELATIVE_PATH,
);

try {
if (!fs.existsSync(sourceConfigPath) || fs.existsSync(targetConfigPath)) {
return false;
}

fs.mkdirSync(path.dirname(targetConfigPath), { recursive: true });
fs.copyFileSync(sourceConfigPath, targetConfigPath);
return true;
} catch {
return false;
}
}

interface GenerateOpenCodeConfigOptions {
homeDir: string;
runtimeEnv: Record<string, string>;
Expand Down
12 changes: 12 additions & 0 deletions apps/worker/src/run-task/run-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { TaskCancellationController } from './task-cancellation-controller';
import {
activateSkillsFolder,
resolvePackagedSkillsFolder,
seedRuntimeHomeMiseGlobalConfig,
} from './agent-home';
import { installZeroCli } from '../commands/setup/agent-clis';

Expand Down Expand Up @@ -766,6 +767,17 @@ export const runTask = async ({

if (workerHomeDir) {
runtimeEnv.HOME = resolveTaskRuntimeHomeDir(workspacePath);

if (
seedRuntimeHomeMiseGlobalConfig({
homeDir: runtimeEnv.HOME,
sourceHomeDir: workerHomeDir,
})
) {
logger.info(
`[runTask] Seeded runtime home mise global config from ${workerHomeDir}`,
);
}
}

delete runtimeEnv.ROOMOTE_TASK_TERMINAL;
Expand Down
Loading