refactor: centralize EJClaw runtime env names (#192)
This commit is contained in:
@@ -18,6 +18,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { query } from '@anthropic-ai/claude-agent-sdk';
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
||||||
import {
|
import {
|
||||||
|
EJCLAW_ENV,
|
||||||
IPC_CLOSE_SENTINEL,
|
IPC_CLOSE_SENTINEL,
|
||||||
IPC_INPUT_SUBDIR,
|
IPC_INPUT_SUBDIR,
|
||||||
IPC_POLL_MS,
|
IPC_POLL_MS,
|
||||||
@@ -78,12 +79,12 @@ interface RunnerInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Paths configurable via env vars.
|
// Paths configurable via env vars.
|
||||||
const GROUP_DIR = process.env.EJCLAW_GROUP_DIR || '/workspace/group';
|
const GROUP_DIR = process.env[EJCLAW_ENV.groupDir] || '/workspace/group';
|
||||||
const IPC_DIR = process.env.EJCLAW_IPC_DIR || '/workspace/ipc';
|
const IPC_DIR = process.env[EJCLAW_ENV.ipcDir] || '/workspace/ipc';
|
||||||
const HOST_IPC_DIR = process.env.EJCLAW_HOST_IPC_DIR || IPC_DIR;
|
const HOST_IPC_DIR = process.env[EJCLAW_ENV.hostIpcDir] || IPC_DIR;
|
||||||
// Optional: override cwd (agent works in this directory instead of GROUP_DIR)
|
// Optional: override cwd (agent works in this directory instead of GROUP_DIR)
|
||||||
const WORK_DIR = process.env.EJCLAW_WORK_DIR || '';
|
const WORK_DIR = process.env[EJCLAW_ENV.workDir] || '';
|
||||||
const GROUP_FOLDER = process.env.EJCLAW_GROUP_FOLDER || '';
|
const GROUP_FOLDER = process.env[EJCLAW_ENV.groupFolder] || '';
|
||||||
|
|
||||||
const IPC_INPUT_DIR = path.join(IPC_DIR, IPC_INPUT_SUBDIR);
|
const IPC_INPUT_DIR = path.join(IPC_DIR, IPC_INPUT_SUBDIR);
|
||||||
const IPC_INPUT_CLOSE_SENTINEL = path.join(IPC_INPUT_DIR, IPC_CLOSE_SENTINEL);
|
const IPC_INPUT_CLOSE_SENTINEL = path.join(IPC_INPUT_DIR, IPC_CLOSE_SENTINEL);
|
||||||
@@ -333,10 +334,10 @@ async function runQuery(
|
|||||||
chatJid: runnerInput.chatJid,
|
chatJid: runnerInput.chatJid,
|
||||||
groupFolder: runnerInput.groupFolder,
|
groupFolder: runnerInput.groupFolder,
|
||||||
isMain: runnerInput.isMain,
|
isMain: runnerInput.isMain,
|
||||||
agentType: process.env.EJCLAW_AGENT_TYPE || 'claude-code',
|
agentType: process.env[EJCLAW_ENV.agentType] || 'claude-code',
|
||||||
roomRole: runnerInput.roomRoleContext?.role || '',
|
roomRole: runnerInput.roomRoleContext?.role || '',
|
||||||
ipcDir: process.env.EJCLAW_IPC_DIR,
|
ipcDir: process.env[EJCLAW_ENV.ipcDir],
|
||||||
hostIpcDir: process.env.EJCLAW_HOST_IPC_DIR,
|
hostIpcDir: process.env[EJCLAW_ENV.hostIpcDir],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
hooks: {
|
hooks: {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { z } from 'zod';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import { CronExpressionParser } from 'cron-parser';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
import {
|
import {
|
||||||
buildCiWatchPrompt,
|
buildCiWatchPrompt,
|
||||||
DEFAULT_WATCH_CI_CONTEXT_MODE,
|
DEFAULT_WATCH_CI_CONTEXT_MODE,
|
||||||
@@ -34,15 +35,15 @@ const MESSAGES_DIR = path.join(HOST_IPC_DIR, 'messages');
|
|||||||
const TASKS_DIR = path.join(HOST_IPC_DIR, 'tasks');
|
const TASKS_DIR = path.join(HOST_IPC_DIR, 'tasks');
|
||||||
const HOST_EVIDENCE_RESPONSES_DIR =
|
const HOST_EVIDENCE_RESPONSES_DIR =
|
||||||
resolveHostEvidenceResponsesDir(HOST_IPC_DIR);
|
resolveHostEvidenceResponsesDir(HOST_IPC_DIR);
|
||||||
const REPO_ROOT = process.env.EJCLAW_WORK_DIR || process.cwd();
|
const REPO_ROOT = process.env[EJCLAW_ENV.workDir] || process.cwd();
|
||||||
|
|
||||||
// Context from environment variables (set by the agent runner)
|
// Context from environment variables (set by the agent runner)
|
||||||
const chatJid = process.env.EJCLAW_CHAT_JID!;
|
const chatJid = process.env[EJCLAW_ENV.chatJid]!;
|
||||||
const groupFolder = process.env.EJCLAW_GROUP_FOLDER!;
|
const groupFolder = process.env[EJCLAW_ENV.groupFolder]!;
|
||||||
const isMain = process.env.EJCLAW_IS_MAIN === '1';
|
const isMain = process.env[EJCLAW_ENV.isMain] === '1';
|
||||||
const agentType = process.env.EJCLAW_AGENT_TYPE || 'claude-code';
|
const agentType = process.env[EJCLAW_ENV.agentType] || 'claude-code';
|
||||||
const roomRole = process.env.EJCLAW_ROOM_ROLE;
|
const roomRole = process.env[EJCLAW_ENV.roomRole];
|
||||||
const runtimeTaskId = process.env.EJCLAW_RUNTIME_TASK_ID;
|
const runtimeTaskId = process.env[EJCLAW_ENV.runtimeTaskId];
|
||||||
const allowGenericScheduling = agentType !== 'codex';
|
const allowGenericScheduling = agentType !== 'codex';
|
||||||
|
|
||||||
function currentAgentType(): 'claude-code' | 'codex' {
|
function currentAgentType(): 'claude-code' | 'codex' {
|
||||||
@@ -93,8 +94,8 @@ server.tool(
|
|||||||
chatJid,
|
chatJid,
|
||||||
text: args.text,
|
text: args.text,
|
||||||
sender: args.sender || undefined,
|
sender: args.sender || undefined,
|
||||||
senderRole: process.env.EJCLAW_ROOM_ROLE || undefined,
|
senderRole: process.env[EJCLAW_ENV.roomRole] || undefined,
|
||||||
runId: process.env.EJCLAW_RUN_ID || undefined,
|
runId: process.env[EJCLAW_ENV.runId] || undefined,
|
||||||
groupFolder,
|
groupFolder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
export interface ResolvedIpcDirectories {
|
export interface ResolvedIpcDirectories {
|
||||||
ipcDir: string;
|
ipcDir: string;
|
||||||
@@ -13,8 +14,8 @@ export function isTaskScopedIpcDir(ipcDir: string): boolean {
|
|||||||
export function resolveIpcDirectories(
|
export function resolveIpcDirectories(
|
||||||
env: NodeJS.ProcessEnv,
|
env: NodeJS.ProcessEnv,
|
||||||
): ResolvedIpcDirectories {
|
): ResolvedIpcDirectories {
|
||||||
const ipcDir = env.EJCLAW_IPC_DIR || '/workspace/ipc';
|
const ipcDir = env[EJCLAW_ENV.ipcDir] || '/workspace/ipc';
|
||||||
const hostIpcDir = env.EJCLAW_HOST_IPC_DIR;
|
const hostIpcDir = env[EJCLAW_ENV.hostIpcDir];
|
||||||
|
|
||||||
if (!hostIpcDir && isTaskScopedIpcDir(ipcDir)) {
|
if (!hostIpcDir && isTaskScopedIpcDir(ipcDir)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { McpStdioServerConfig } from '@anthropic-ai/claude-agent-sdk';
|
import type { McpStdioServerConfig } from '@anthropic-ai/claude-agent-sdk';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
export interface EjclawMcpServerConfigInput {
|
export interface EjclawMcpServerConfigInput {
|
||||||
chatJid: string;
|
chatJid: string;
|
||||||
@@ -19,16 +20,16 @@ export function buildEjclawMcpServerConfig(
|
|||||||
args: [mcpServerPath],
|
args: [mcpServerPath],
|
||||||
alwaysLoad: true,
|
alwaysLoad: true,
|
||||||
env: {
|
env: {
|
||||||
EJCLAW_CHAT_JID: input.chatJid,
|
[EJCLAW_ENV.chatJid]: input.chatJid,
|
||||||
EJCLAW_GROUP_FOLDER: input.groupFolder,
|
[EJCLAW_ENV.groupFolder]: input.groupFolder,
|
||||||
EJCLAW_IS_MAIN: input.isMain ? '1' : '0',
|
[EJCLAW_ENV.isMain]: input.isMain ? '1' : '0',
|
||||||
EJCLAW_AGENT_TYPE: input.agentType,
|
[EJCLAW_ENV.agentType]: input.agentType,
|
||||||
EJCLAW_ROOM_ROLE: input.roomRole,
|
[EJCLAW_ENV.roomRole]: input.roomRole,
|
||||||
...(input.ipcDir && {
|
...(input.ipcDir && {
|
||||||
EJCLAW_IPC_DIR: input.ipcDir,
|
[EJCLAW_ENV.ipcDir]: input.ipcDir,
|
||||||
}),
|
}),
|
||||||
...(input.hostIpcDir && {
|
...(input.hostIpcDir && {
|
||||||
EJCLAW_HOST_IPC_DIR: input.hostIpcDir,
|
[EJCLAW_ENV.hostIpcDir]: input.hostIpcDir,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
import { buildEjclawMcpServerConfig } from '../src/mcp-config.js';
|
import { buildEjclawMcpServerConfig } from '../src/mcp-config.js';
|
||||||
|
|
||||||
@@ -19,13 +20,13 @@ describe('ejclaw MCP config', () => {
|
|||||||
args: ['/runner/dist/ipc-mcp-stdio.js'],
|
args: ['/runner/dist/ipc-mcp-stdio.js'],
|
||||||
alwaysLoad: true,
|
alwaysLoad: true,
|
||||||
env: {
|
env: {
|
||||||
EJCLAW_CHAT_JID: 'dc:room',
|
[EJCLAW_ENV.chatJid]: 'dc:room',
|
||||||
EJCLAW_GROUP_FOLDER: 'ejclaw',
|
[EJCLAW_ENV.groupFolder]: 'ejclaw',
|
||||||
EJCLAW_IS_MAIN: '1',
|
[EJCLAW_ENV.isMain]: '1',
|
||||||
EJCLAW_AGENT_TYPE: 'claude-code',
|
[EJCLAW_ENV.agentType]: 'claude-code',
|
||||||
EJCLAW_ROOM_ROLE: 'reviewer',
|
[EJCLAW_ENV.roomRole]: 'reviewer',
|
||||||
EJCLAW_IPC_DIR: '/tmp/ipc/task',
|
[EJCLAW_ENV.ipcDir]: '/tmp/ipc/task',
|
||||||
EJCLAW_HOST_IPC_DIR: '/tmp/ipc/host',
|
[EJCLAW_ENV.hostIpcDir]: '/tmp/ipc/host',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
EJCLAW_ENV,
|
||||||
extractImageTagPaths,
|
extractImageTagPaths,
|
||||||
IPC_CLOSE_SENTINEL,
|
IPC_CLOSE_SENTINEL,
|
||||||
IPC_INPUT_SUBDIR,
|
IPC_INPUT_SUBDIR,
|
||||||
@@ -71,9 +72,9 @@ interface RunnerOutput {
|
|||||||
|
|
||||||
// ── Constants ──────────────────────────────────────────────────────
|
// ── Constants ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
const GROUP_DIR = process.env.EJCLAW_GROUP_DIR || '/workspace/group';
|
const GROUP_DIR = process.env[EJCLAW_ENV.groupDir] || '/workspace/group';
|
||||||
const IPC_DIR = process.env.EJCLAW_IPC_DIR || '/workspace/ipc';
|
const IPC_DIR = process.env[EJCLAW_ENV.ipcDir] || '/workspace/ipc';
|
||||||
const WORK_DIR = process.env.EJCLAW_WORK_DIR || '';
|
const WORK_DIR = process.env[EJCLAW_ENV.workDir] || '';
|
||||||
const IPC_INPUT_DIR = path.join(IPC_DIR, IPC_INPUT_SUBDIR);
|
const IPC_INPUT_DIR = path.join(IPC_DIR, IPC_INPUT_SUBDIR);
|
||||||
const IPC_INPUT_CLOSE_SENTINEL = path.join(IPC_INPUT_DIR, IPC_CLOSE_SENTINEL);
|
const IPC_INPUT_CLOSE_SENTINEL = path.join(IPC_INPUT_DIR, IPC_CLOSE_SENTINEL);
|
||||||
|
|
||||||
|
|||||||
16
runners/shared/src/ejclaw-env.ts
Normal file
16
runners/shared/src/ejclaw-env.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
export const EJCLAW_ENV = {
|
||||||
|
agentType: 'EJCLAW_AGENT_TYPE',
|
||||||
|
chatJid: 'EJCLAW_CHAT_JID',
|
||||||
|
globalDir: 'EJCLAW_GLOBAL_DIR',
|
||||||
|
groupDir: 'EJCLAW_GROUP_DIR',
|
||||||
|
groupFolder: 'EJCLAW_GROUP_FOLDER',
|
||||||
|
hostIpcDir: 'EJCLAW_HOST_IPC_DIR',
|
||||||
|
ipcDir: 'EJCLAW_IPC_DIR',
|
||||||
|
isMain: 'EJCLAW_IS_MAIN',
|
||||||
|
roomRole: 'EJCLAW_ROOM_ROLE',
|
||||||
|
runId: 'EJCLAW_RUN_ID',
|
||||||
|
runtimeTaskId: 'EJCLAW_RUNTIME_TASK_ID',
|
||||||
|
workDir: 'EJCLAW_WORK_DIR',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type EjclawEnvName = (typeof EJCLAW_ENV)[keyof typeof EJCLAW_ENV];
|
||||||
@@ -2,6 +2,7 @@ export {
|
|||||||
prependRoomRoleHeader,
|
prependRoomRoleHeader,
|
||||||
type RoomRoleContext,
|
type RoomRoleContext,
|
||||||
} from './room-role-context.js';
|
} from './room-role-context.js';
|
||||||
|
export { EJCLAW_ENV, type EjclawEnvName } from './ejclaw-env.js';
|
||||||
export {
|
export {
|
||||||
extractMarkdownImageAttachments,
|
extractMarkdownImageAttachments,
|
||||||
extractMediaAttachments,
|
extractMediaAttachments,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
const { mockReadEnvFile, mockGetActiveCodexAuthPath } = vi.hoisted(() => ({
|
const { mockReadEnvFile, mockGetActiveCodexAuthPath } = vi.hoisted(() => ({
|
||||||
mockReadEnvFile: vi.fn<() => Record<string, string>>(),
|
mockReadEnvFile: vi.fn<() => Record<string, string>>(),
|
||||||
@@ -455,7 +456,7 @@ describe('prepareGroupEnvironment Codex MCP room role env', () => {
|
|||||||
roomRole: 'owner',
|
roomRole: 'owner',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(readCodexConfigToml()).toContain('EJCLAW_ROOM_ROLE = "owner"');
|
expect(readCodexConfigToml()).toContain(`${EJCLAW_ENV.roomRole} = "owner"`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('omits room role from non-paired Codex MCP config env', () => {
|
it('omits room role from non-paired Codex MCP config env', () => {
|
||||||
@@ -464,7 +465,7 @@ describe('prepareGroupEnvironment Codex MCP room role env', () => {
|
|||||||
|
|
||||||
prepareGroupEnvironment(group, true, 'dc:test');
|
prepareGroupEnvironment(group, true, 'dc:test');
|
||||||
|
|
||||||
expect(readCodexConfigToml()).not.toContain('EJCLAW_ROOM_ROLE');
|
expect(readCodexConfigToml()).not.toContain(EJCLAW_ENV.roomRole);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -741,7 +742,7 @@ command = "node"
|
|||||||
args = ["old-ipc.js"]
|
args = ["old-ipc.js"]
|
||||||
|
|
||||||
[mcp_servers.ejclaw.env]
|
[mcp_servers.ejclaw.env]
|
||||||
EJCLAW_IPC_DIR = "/old/ipc"
|
${EJCLAW_ENV.ipcDir} = "/old/ipc"
|
||||||
|
|
||||||
[mcp_servers.other]
|
[mcp_servers.other]
|
||||||
command = "node"
|
command = "node"
|
||||||
@@ -780,10 +781,10 @@ args = ["other.js"]
|
|||||||
expect(toml).toContain('model = "gpt-5.4"');
|
expect(toml).toContain('model = "gpt-5.4"');
|
||||||
expect(toml).toContain('[mcp_servers.other]');
|
expect(toml).toContain('[mcp_servers.other]');
|
||||||
expect(toml).toContain('[mcp_servers.ejclaw]');
|
expect(toml).toContain('[mcp_servers.ejclaw]');
|
||||||
expect(toml).toContain('EJCLAW_IPC_DIR = "/workspace/ipc"');
|
expect(toml).toContain(`${EJCLAW_ENV.ipcDir} = "/workspace/ipc"`);
|
||||||
expect(toml).toContain('EJCLAW_GROUP_FOLDER = "codex-test-group"');
|
expect(toml).toContain(`${EJCLAW_ENV.groupFolder} = "codex-test-group"`);
|
||||||
expect(toml).toContain('EJCLAW_ROOM_ROLE = "reviewer"');
|
expect(toml).toContain(`${EJCLAW_ENV.roomRole} = "reviewer"`);
|
||||||
expect(toml).toContain('EJCLAW_WORK_DIR = "/workspace/project"');
|
expect(toml).toContain(`${EJCLAW_ENV.workDir} = "/workspace/project"`);
|
||||||
expect(toml).not.toContain('old-ipc.js');
|
expect(toml).not.toContain('old-ipc.js');
|
||||||
expect(toml).not.toContain('"/old/ipc"');
|
expect(toml).not.toContain('"/old/ipc"');
|
||||||
expect(toml.match(/\[mcp_servers\.ejclaw\]/g)).toHaveLength(1);
|
expect(toml.match(/\[mcp_servers\.ejclaw\]/g)).toHaveLength(1);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
GROUPS_DIR,
|
GROUPS_DIR,
|
||||||
@@ -210,20 +211,22 @@ function upsertEjclawMcpServerSection(args: {
|
|||||||
? fs.readFileSync(args.sessionConfigPath, 'utf-8')
|
? fs.readFileSync(args.sessionConfigPath, 'utf-8')
|
||||||
: '';
|
: '';
|
||||||
toml = stripEjclawMcpServerSections(toml);
|
toml = stripEjclawMcpServerSections(toml);
|
||||||
|
const tomlEnvLine = (name: string, value: string): string =>
|
||||||
|
`${name} = ${JSON.stringify(value)}`;
|
||||||
const mcpSection = `
|
const mcpSection = `
|
||||||
[mcp_servers.ejclaw]
|
[mcp_servers.ejclaw]
|
||||||
command = "node"
|
command = "node"
|
||||||
args = [${JSON.stringify(args.mcpServerPath)}]
|
args = [${JSON.stringify(args.mcpServerPath)}]
|
||||||
|
|
||||||
[mcp_servers.ejclaw.env]
|
[mcp_servers.ejclaw.env]
|
||||||
EJCLAW_IPC_DIR = ${JSON.stringify(args.ipcDir)}
|
${tomlEnvLine(EJCLAW_ENV.ipcDir, args.ipcDir)}
|
||||||
EJCLAW_HOST_IPC_DIR = ${JSON.stringify(args.hostIpcDir)}
|
${tomlEnvLine(EJCLAW_ENV.hostIpcDir, args.hostIpcDir)}
|
||||||
EJCLAW_CHAT_JID = ${JSON.stringify(args.chatJid)}
|
${tomlEnvLine(EJCLAW_ENV.chatJid, args.chatJid)}
|
||||||
EJCLAW_GROUP_FOLDER = ${JSON.stringify(args.groupFolder)}
|
${tomlEnvLine(EJCLAW_ENV.groupFolder, args.groupFolder)}
|
||||||
EJCLAW_IS_MAIN = ${JSON.stringify(args.isMain ? '1' : '0')}
|
${tomlEnvLine(EJCLAW_ENV.isMain, args.isMain ? '1' : '0')}
|
||||||
EJCLAW_AGENT_TYPE = ${JSON.stringify(args.agentType)}
|
${tomlEnvLine(EJCLAW_ENV.agentType, args.agentType)}
|
||||||
${args.roomRole ? `EJCLAW_ROOM_ROLE = ${JSON.stringify(args.roomRole)}\n` : ''}
|
${args.roomRole ? `${tomlEnvLine(EJCLAW_ENV.roomRole, args.roomRole)}\n` : ''}
|
||||||
${args.workDir ? `EJCLAW_WORK_DIR = ${JSON.stringify(args.workDir)}\n` : ''}
|
${args.workDir ? `${tomlEnvLine(EJCLAW_ENV.workDir, args.workDir)}\n` : ''}
|
||||||
`;
|
`;
|
||||||
fs.writeFileSync(args.sessionConfigPath, toml.trimEnd() + '\n' + mcpSection);
|
fs.writeFileSync(args.sessionConfigPath, toml.trimEnd() + '\n' + mcpSection);
|
||||||
}
|
}
|
||||||
@@ -263,18 +266,18 @@ function buildBaseRunnerEnv(args: {
|
|||||||
: currentPath,
|
: currentPath,
|
||||||
TZ: TIMEZONE,
|
TZ: TIMEZONE,
|
||||||
HOME: os.homedir(),
|
HOME: os.homedir(),
|
||||||
EJCLAW_GROUP_DIR: args.groupDir,
|
[EJCLAW_ENV.groupDir]: args.groupDir,
|
||||||
EJCLAW_IPC_DIR: args.groupIpcDir,
|
[EJCLAW_ENV.ipcDir]: args.groupIpcDir,
|
||||||
EJCLAW_HOST_IPC_DIR: args.hostIpcDir,
|
[EJCLAW_ENV.hostIpcDir]: args.hostIpcDir,
|
||||||
EJCLAW_GLOBAL_DIR: args.globalDir,
|
[EJCLAW_ENV.globalDir]: args.globalDir,
|
||||||
...(args.group.workDir ? { EJCLAW_WORK_DIR: args.group.workDir } : {}),
|
...(args.group.workDir ? { [EJCLAW_ENV.workDir]: args.group.workDir } : {}),
|
||||||
EJCLAW_CHAT_JID: args.chatJid,
|
[EJCLAW_ENV.chatJid]: args.chatJid,
|
||||||
EJCLAW_GROUP_FOLDER: args.group.folder,
|
[EJCLAW_ENV.groupFolder]: args.group.folder,
|
||||||
EJCLAW_IS_MAIN: args.isMain ? '1' : '0',
|
[EJCLAW_ENV.isMain]: args.isMain ? '1' : '0',
|
||||||
EJCLAW_AGENT_TYPE: args.agentType,
|
[EJCLAW_ENV.agentType]: args.agentType,
|
||||||
CLAUDE_CONFIG_DIR: args.groupSessionsDir,
|
CLAUDE_CONFIG_DIR: args.groupSessionsDir,
|
||||||
...(args.runtimeTaskId
|
...(args.runtimeTaskId
|
||||||
? { EJCLAW_RUNTIME_TASK_ID: args.runtimeTaskId }
|
? { [EJCLAW_ENV.runtimeTaskId]: args.runtimeTaskId }
|
||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -486,15 +489,15 @@ function prepareCodexSessionEnvironment(args: {
|
|||||||
upsertEjclawMcpServerSection({
|
upsertEjclawMcpServerSection({
|
||||||
sessionConfigPath,
|
sessionConfigPath,
|
||||||
mcpServerPath,
|
mcpServerPath,
|
||||||
ipcDir: args.env.EJCLAW_IPC_DIR,
|
ipcDir: args.env[EJCLAW_ENV.ipcDir],
|
||||||
hostIpcDir: args.env.EJCLAW_HOST_IPC_DIR,
|
hostIpcDir: args.env[EJCLAW_ENV.hostIpcDir],
|
||||||
chatJid: args.chatJid,
|
chatJid: args.chatJid,
|
||||||
groupFolder: args.group.folder,
|
groupFolder: args.group.folder,
|
||||||
isMain: args.isMain,
|
isMain: args.isMain,
|
||||||
agentType: 'codex',
|
agentType: 'codex',
|
||||||
roomRole: args.roomRole,
|
roomRole: args.roomRole,
|
||||||
workDir:
|
workDir:
|
||||||
args.env.EJCLAW_WORK_DIR || args.group.workDir || args.projectRoot,
|
args.env[EJCLAW_ENV.workDir] || args.group.workDir || args.projectRoot,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import { ChildProcess, spawn } from 'child_process';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { isUnsafeHostPairedModeEnabled } from 'ejclaw-runners-shared';
|
import {
|
||||||
|
EJCLAW_ENV,
|
||||||
|
isUnsafeHostPairedModeEnabled,
|
||||||
|
} from 'ejclaw-runners-shared';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent Process Runner for EJClaw
|
* Agent Process Runner for EJClaw
|
||||||
@@ -122,9 +125,9 @@ export async function runAgentProcess(
|
|||||||
agentType: group.agentType || 'claude-code',
|
agentType: group.agentType || 'claude-code',
|
||||||
memoryBriefing: input.memoryBriefing,
|
memoryBriefing: input.memoryBriefing,
|
||||||
role: input.roomRoleContext.role,
|
role: input.roomRoleContext.role,
|
||||||
ipcDir: env.EJCLAW_IPC_DIR,
|
ipcDir: env[EJCLAW_ENV.ipcDir],
|
||||||
hostIpcDir: env.EJCLAW_HOST_IPC_DIR,
|
hostIpcDir: env[EJCLAW_ENV.hostIpcDir],
|
||||||
workDir: envOverrides.EJCLAW_WORK_DIR || env.EJCLAW_WORK_DIR,
|
workDir: envOverrides[EJCLAW_ENV.workDir] || env[EJCLAW_ENV.workDir],
|
||||||
skillOverrides,
|
skillOverrides,
|
||||||
});
|
});
|
||||||
if ((group.agentType || 'claude-code') === 'codex') {
|
if ((group.agentType || 'claude-code') === 'codex') {
|
||||||
@@ -135,7 +138,7 @@ export async function runAgentProcess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input.runId) {
|
if (input.runId) {
|
||||||
env.EJCLAW_RUN_ID = input.runId;
|
env[EJCLAW_ENV.runId] = input.runId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const safeName = group.folder.replace(/[^a-zA-Z0-9-]/g, '-');
|
const safeName = group.folder.replace(/[^a-zA-Z0-9-]/g, '-');
|
||||||
@@ -179,7 +182,7 @@ export async function runAgentProcess(
|
|||||||
env,
|
env,
|
||||||
});
|
});
|
||||||
|
|
||||||
onProcess(proc, processName, env.EJCLAW_IPC_DIR);
|
onProcess(proc, processName, env[EJCLAW_ENV.ipcDir]);
|
||||||
|
|
||||||
const runnerInput: AgentInput = {
|
const runnerInput: AgentInput = {
|
||||||
...input,
|
...input,
|
||||||
|
|||||||
Reference in New Issue
Block a user