cyrus-codex-runner 0.2.64-test.7 → 0.2.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodexEventMapper.d.ts +56 -0
- package/dist/CodexEventMapper.d.ts.map +1 -0
- package/dist/CodexEventMapper.js +469 -0
- package/dist/CodexEventMapper.js.map +1 -0
- package/dist/CodexRunner.d.ts +37 -46
- package/dist/CodexRunner.d.ts.map +1 -1
- package/dist/CodexRunner.js +136 -851
- package/dist/CodexRunner.js.map +1 -1
- package/dist/CodexSkillStager.d.ts +42 -0
- package/dist/CodexSkillStager.d.ts.map +1 -0
- package/dist/CodexSkillStager.js +182 -0
- package/dist/CodexSkillStager.js.map +1 -0
- package/dist/backend/AppServerCodexBackend.d.ts +74 -0
- package/dist/backend/AppServerCodexBackend.d.ts.map +1 -0
- package/dist/backend/AppServerCodexBackend.js +352 -0
- package/dist/backend/AppServerCodexBackend.js.map +1 -0
- package/dist/backend/appServerClient.d.ts +75 -0
- package/dist/backend/appServerClient.d.ts.map +1 -0
- package/dist/backend/appServerClient.js +223 -0
- package/dist/backend/appServerClient.js.map +1 -0
- package/dist/backend/appServerEvents.d.ts +9 -0
- package/dist/backend/appServerEvents.d.ts.map +1 -0
- package/dist/backend/appServerEvents.js +110 -0
- package/dist/backend/appServerEvents.js.map +1 -0
- package/dist/backend/appServerProcess.d.ts +38 -0
- package/dist/backend/appServerProcess.d.ts.map +1 -0
- package/dist/backend/appServerProcess.js +283 -0
- package/dist/backend/appServerProcess.js.map +1 -0
- package/dist/backend/codexBinary.d.ts +24 -0
- package/dist/backend/codexBinary.d.ts.map +1 -0
- package/dist/backend/codexBinary.js +44 -0
- package/dist/backend/codexBinary.js.map +1 -0
- package/dist/backend/types.d.ts +210 -0
- package/dist/backend/types.d.ts.map +1 -0
- package/dist/backend/types.js +2 -0
- package/dist/backend/types.js.map +1 -0
- package/dist/config/CodexConfigBuilder.d.ts +40 -0
- package/dist/config/CodexConfigBuilder.d.ts.map +1 -0
- package/dist/config/CodexConfigBuilder.js +182 -0
- package/dist/config/CodexConfigBuilder.js.map +1 -0
- package/dist/config/mcpConfigTranslator.d.ts +17 -0
- package/dist/config/mcpConfigTranslator.d.ts.map +1 -0
- package/dist/config/mcpConfigTranslator.js +245 -0
- package/dist/config/mcpConfigTranslator.js.map +1 -0
- package/dist/config/sandboxPolicy.d.ts +43 -0
- package/dist/config/sandboxPolicy.d.ts.map +1 -0
- package/dist/config/sandboxPolicy.js +56 -0
- package/dist/config/sandboxPolicy.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const CODEX_MCP_DOCS_URL = "https://platform.openai.com/docs/docs-mcp";
|
|
4
|
+
const CODEX_MCP_APPROVE_MODE = "approve";
|
|
5
|
+
function autoDetectMcpConfigPath(workingDirectory) {
|
|
6
|
+
if (!workingDirectory) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const mcpPath = join(workingDirectory, ".mcp.json");
|
|
10
|
+
if (!existsSync(mcpPath)) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
JSON.parse(readFileSync(mcpPath, "utf8"));
|
|
15
|
+
return mcpPath;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
console.warn(`[CodexRunner] Found .mcp.json at ${mcpPath} but it is invalid JSON, skipping`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function loadMcpConfigFromPaths(configPaths) {
|
|
23
|
+
if (!configPaths) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
const paths = Array.isArray(configPaths) ? configPaths : [configPaths];
|
|
27
|
+
let mcpServers = {};
|
|
28
|
+
for (const configPath of paths) {
|
|
29
|
+
try {
|
|
30
|
+
const mcpConfigContent = readFileSync(configPath, "utf8");
|
|
31
|
+
const mcpConfig = JSON.parse(mcpConfigContent);
|
|
32
|
+
const servers = mcpConfig &&
|
|
33
|
+
typeof mcpConfig === "object" &&
|
|
34
|
+
!Array.isArray(mcpConfig) &&
|
|
35
|
+
mcpConfig.mcpServers &&
|
|
36
|
+
typeof mcpConfig.mcpServers === "object" &&
|
|
37
|
+
!Array.isArray(mcpConfig.mcpServers)
|
|
38
|
+
? mcpConfig.mcpServers
|
|
39
|
+
: {};
|
|
40
|
+
mcpServers = { ...mcpServers, ...servers };
|
|
41
|
+
console.log(`[CodexRunner] Loaded MCP config from ${configPath}: ${Object.keys(servers).join(", ")}`);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.warn(`[CodexRunner] Failed to load MCP config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return mcpServers;
|
|
48
|
+
}
|
|
49
|
+
function parseMcpAllowedTool(toolPattern) {
|
|
50
|
+
const trimmed = toolPattern.trim();
|
|
51
|
+
if (!trimmed.startsWith("mcp__")) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const parts = trimmed.split("__");
|
|
55
|
+
const serverName = parts[1]?.trim();
|
|
56
|
+
if (!serverName) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (parts.length === 2) {
|
|
60
|
+
return { serverName };
|
|
61
|
+
}
|
|
62
|
+
const toolName = parts.slice(2).join("__").trim();
|
|
63
|
+
return toolName ? { serverName, toolName } : { serverName };
|
|
64
|
+
}
|
|
65
|
+
function buildMcpAllowedToolsFilters(allowedTools) {
|
|
66
|
+
const filters = new Map();
|
|
67
|
+
for (const allowedTool of allowedTools ?? []) {
|
|
68
|
+
const parsed = parseMcpAllowedTool(allowedTool);
|
|
69
|
+
if (!parsed) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const filter = filters.get(parsed.serverName) ?? {
|
|
73
|
+
allowAll: false,
|
|
74
|
+
tools: [],
|
|
75
|
+
};
|
|
76
|
+
if (!parsed.toolName) {
|
|
77
|
+
filter.allowAll = true;
|
|
78
|
+
filter.tools = [];
|
|
79
|
+
}
|
|
80
|
+
else if (!filter.allowAll && !filter.tools.includes(parsed.toolName)) {
|
|
81
|
+
filter.tools.push(parsed.toolName);
|
|
82
|
+
}
|
|
83
|
+
filters.set(parsed.serverName, filter);
|
|
84
|
+
}
|
|
85
|
+
return filters;
|
|
86
|
+
}
|
|
87
|
+
function normalizeMcpServerFilterName(serverName) {
|
|
88
|
+
return serverName.replace(/[-_]+/g, "").toLowerCase();
|
|
89
|
+
}
|
|
90
|
+
function mergeMcpAllowedToolsFilters(filters) {
|
|
91
|
+
if (filters.length === 0) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const merged = {
|
|
95
|
+
allowAll: false,
|
|
96
|
+
tools: [],
|
|
97
|
+
};
|
|
98
|
+
for (const filter of filters) {
|
|
99
|
+
if (filter.allowAll) {
|
|
100
|
+
return { allowAll: true, tools: [] };
|
|
101
|
+
}
|
|
102
|
+
for (const tool of filter.tools) {
|
|
103
|
+
if (!merged.tools.includes(tool)) {
|
|
104
|
+
merged.tools.push(tool);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return merged;
|
|
109
|
+
}
|
|
110
|
+
function getMcpAllowedToolsFilter(filters, serverName) {
|
|
111
|
+
const matchingFilters = [];
|
|
112
|
+
const exact = filters.get(serverName);
|
|
113
|
+
if (exact) {
|
|
114
|
+
matchingFilters.push(exact);
|
|
115
|
+
}
|
|
116
|
+
const normalizedServerName = normalizeMcpServerFilterName(serverName);
|
|
117
|
+
for (const [allowedServerName, filter] of filters.entries()) {
|
|
118
|
+
if (allowedServerName === serverName) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (normalizeMcpServerFilterName(allowedServerName) === normalizedServerName) {
|
|
122
|
+
matchingFilters.push(filter);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return mergeMcpAllowedToolsFilters(matchingFilters);
|
|
126
|
+
}
|
|
127
|
+
function applyCyrusMcpAllowedToolsSemantics(mapped, allowedToolsFilter, options) {
|
|
128
|
+
const shouldGenerateToolFilter = !allowedToolsFilter.allowAll &&
|
|
129
|
+
allowedToolsFilter.tools.length > 0 &&
|
|
130
|
+
!options.hasNativeToolFilter;
|
|
131
|
+
if (shouldGenerateToolFilter) {
|
|
132
|
+
mapped.enabled_tools = allowedToolsFilter.tools;
|
|
133
|
+
}
|
|
134
|
+
// Codex separates tool visibility (`enabled_tools`) from MCP approval. Cyrus
|
|
135
|
+
// allowedTools are already the operator's allow-list, so generated allowances
|
|
136
|
+
// must also be approved for non-interactive Codex exec runs.
|
|
137
|
+
if (!Object.hasOwn(mapped, "default_tools_approval_mode")) {
|
|
138
|
+
mapped.default_tools_approval_mode = CODEX_MCP_APPROVE_MODE;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function copyConfigString(target, source, key) {
|
|
142
|
+
if (typeof source[key] === "string") {
|
|
143
|
+
target[key] = source[key];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function copyConfigNumber(target, source, key) {
|
|
147
|
+
if (typeof source[key] === "number") {
|
|
148
|
+
target[key] = source[key];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function copyConfigBoolean(target, source, key) {
|
|
152
|
+
if (typeof source[key] === "boolean") {
|
|
153
|
+
target[key] = source[key];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function copyConfigArray(target, source, key) {
|
|
157
|
+
if (Array.isArray(source[key])) {
|
|
158
|
+
target[key] = source[key];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function copyConfigObject(target, source, sourceKey, targetKey = sourceKey) {
|
|
162
|
+
const value = source[sourceKey];
|
|
163
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
164
|
+
target[targetKey] =
|
|
165
|
+
value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Translate Cyrus MCP server configs (file-based + inline) and Cyrus
|
|
170
|
+
* `allowedTools` semantics into Codex-native `mcp_servers` config overrides.
|
|
171
|
+
*
|
|
172
|
+
* Reference: {@link https://platform.openai.com/docs/docs-mcp}
|
|
173
|
+
*/
|
|
174
|
+
export function buildCodexMcpServersConfig(input) {
|
|
175
|
+
const autoDetectedPath = autoDetectMcpConfigPath(input.workingDirectory);
|
|
176
|
+
const configPaths = autoDetectedPath ? [autoDetectedPath] : [];
|
|
177
|
+
if (input.mcpConfigPath) {
|
|
178
|
+
const explicitPaths = Array.isArray(input.mcpConfigPath)
|
|
179
|
+
? input.mcpConfigPath
|
|
180
|
+
: [input.mcpConfigPath];
|
|
181
|
+
configPaths.push(...explicitPaths);
|
|
182
|
+
}
|
|
183
|
+
const fileBasedServers = loadMcpConfigFromPaths(configPaths);
|
|
184
|
+
const mergedServers = input.mcpConfig
|
|
185
|
+
? { ...fileBasedServers, ...input.mcpConfig }
|
|
186
|
+
: fileBasedServers;
|
|
187
|
+
if (Object.keys(mergedServers).length === 0) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const allowedToolsFilters = buildMcpAllowedToolsFilters(input.allowedTools);
|
|
191
|
+
const codexServers = {};
|
|
192
|
+
for (const [serverName, rawConfig] of Object.entries(mergedServers)) {
|
|
193
|
+
const configAny = rawConfig;
|
|
194
|
+
if (typeof configAny.listTools === "function" ||
|
|
195
|
+
typeof configAny.callTool === "function") {
|
|
196
|
+
console.warn(`[CodexRunner] Skipping MCP server '${serverName}' because in-process SDK server instances cannot be mapped to codex config`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const mapped = {};
|
|
200
|
+
copyConfigString(mapped, configAny, "command");
|
|
201
|
+
copyConfigArray(mapped, configAny, "args");
|
|
202
|
+
copyConfigObject(mapped, configAny, "env");
|
|
203
|
+
copyConfigArray(mapped, configAny, "env_vars");
|
|
204
|
+
copyConfigString(mapped, configAny, "cwd");
|
|
205
|
+
copyConfigString(mapped, configAny, "experimental_environment");
|
|
206
|
+
copyConfigString(mapped, configAny, "url");
|
|
207
|
+
copyConfigObject(mapped, configAny, "http_headers");
|
|
208
|
+
copyConfigObject(mapped, configAny, "headers", "http_headers");
|
|
209
|
+
copyConfigObject(mapped, configAny, "env_http_headers");
|
|
210
|
+
copyConfigString(mapped, configAny, "bearer_token_env_var");
|
|
211
|
+
copyConfigNumber(mapped, configAny, "timeout");
|
|
212
|
+
copyConfigNumber(mapped, configAny, "startup_timeout_sec");
|
|
213
|
+
copyConfigNumber(mapped, configAny, "tool_timeout_sec");
|
|
214
|
+
copyConfigBoolean(mapped, configAny, "enabled");
|
|
215
|
+
copyConfigBoolean(mapped, configAny, "required");
|
|
216
|
+
copyConfigArray(mapped, configAny, "enabled_tools");
|
|
217
|
+
copyConfigArray(mapped, configAny, "disabled_tools");
|
|
218
|
+
copyConfigString(mapped, configAny, "default_tools_approval_mode");
|
|
219
|
+
copyConfigObject(mapped, configAny, "tools");
|
|
220
|
+
if (!mapped.command && !mapped.url) {
|
|
221
|
+
console.warn(`[CodexRunner] Skipping MCP server '${serverName}' because it has no command/url transport`);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const allowedToolsFilter = getMcpAllowedToolsFilter(allowedToolsFilters, serverName);
|
|
225
|
+
const hasNativeToolFilter = Object.hasOwn(mapped, "enabled_tools") ||
|
|
226
|
+
Object.hasOwn(mapped, "disabled_tools");
|
|
227
|
+
if (allowedToolsFilter) {
|
|
228
|
+
applyCyrusMcpAllowedToolsSemantics(mapped, allowedToolsFilter, {
|
|
229
|
+
hasNativeToolFilter,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// If the MCP config already contains Codex-native enabled_tools or
|
|
233
|
+
// disabled_tools, keep those exact filters. They are more specific to
|
|
234
|
+
// Codex than Claude-style Cyrus allowedTools entries. A bare
|
|
235
|
+
// `mcp__server` intentionally emits no enabled_tools filter because it
|
|
236
|
+
// means "allow every tool exposed by this configured server".
|
|
237
|
+
codexServers[serverName] = mapped;
|
|
238
|
+
}
|
|
239
|
+
if (Object.keys(codexServers).length === 0) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
console.log(`[CodexRunner] Configured ${Object.keys(codexServers).length} MCP server(s) for codex config (docs: ${CODEX_MCP_DOCS_URL})`);
|
|
243
|
+
return codexServers;
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=mcpConfigTranslator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpConfigTranslator.js","sourceRoot":"","sources":["../../src/config/mcpConfigTranslator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AACvE,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAezC,SAAS,uBAAuB,CAC/B,gBAAyB;IAEzB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACJ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1C,OAAO,OAAO,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACR,O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E,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE7C,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CACX,sCAAsC,UAAU,2CAA2C,CAC3F,CAAC;YACF,SAAS;QACV,CAAC;QAED,MAAM,kBAAkB,GAAG,wBAAwB,CAClD,mBAAmB,EACnB,UAAU,CACV,CAAC;QACF,MAAM,mBAAmB,GACxB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACzC,IAAI,kBAAkB,EAAE,CAAC;YACxB,kCAAkC,CAAC,MAAM,EAAE,kBAAkB,EAAE;gBAC9D,mBAAmB;aACnB,CAAC,CAAC;QACJ,CAAC;QACD,mEAAmE;QACnE,sEAAsE;QACtE,6DAA6D;QAC7D,uEAAuE;QACvE,8DAA8D;QAE9D,YAAY,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;IACnC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CACV,4BAA4B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,0CAA0C,kBAAkB,GAAG,CAC3H,CAAC;IACF,OAAO,YAAY,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SandboxMode } from "@openai/codex-sdk";
|
|
2
|
+
import type { ResolvedCodexSandbox } from "../backend/types.js";
|
|
3
|
+
/** Stable id for the per-thread permission profile Cyrus builds. */
|
|
4
|
+
export declare const CYRUS_SANDBOX_PROFILE_ID = "cyrus-sandbox";
|
|
5
|
+
/**
|
|
6
|
+
* Cyrus filesystem sandbox intent (subset of the agent SDK `SandboxSettings`).
|
|
7
|
+
* Paths are expected absolute by the time they reach here (the EdgeWorker layer
|
|
8
|
+
* resolves `~`/`.`/relative entries before plumbing them in).
|
|
9
|
+
*
|
|
10
|
+
* Reads are an allow-list: a path is readable only if it is the worktree
|
|
11
|
+
* (`:workspace_roots`), a platform default (`:minimal`), or appears in
|
|
12
|
+
* `allowRead`/`allowWrite`. Anything else (e.g. the home directory) is denied.
|
|
13
|
+
* `denyRead` is honored by omission — a denied path simply never appears in the
|
|
14
|
+
* allow-list. Sub-path denies inside an allowed root are not expressible (and
|
|
15
|
+
* not needed by Cyrus's deny-broad / allow-narrow posture).
|
|
16
|
+
*/
|
|
17
|
+
export interface CyrusSandboxFilesystem {
|
|
18
|
+
allowRead?: string[];
|
|
19
|
+
allowWrite?: string[];
|
|
20
|
+
denyRead?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface SandboxResolveInput {
|
|
23
|
+
/** Coarse Codex sandbox mode (defaults to workspace-write upstream). */
|
|
24
|
+
mode: SandboxMode;
|
|
25
|
+
/** Session working directory (the worktree; maps to `:workspace_roots`). */
|
|
26
|
+
workingDirectory?: string;
|
|
27
|
+
/** Extra writable roots (e.g. multi-repo sub-worktrees), already absolute. */
|
|
28
|
+
writableRoots: string[];
|
|
29
|
+
networkAccess: boolean;
|
|
30
|
+
/** When present, produces a granular `profile`; otherwise a `workspace-mode`. */
|
|
31
|
+
sandboxSettings?: CyrusSandboxFilesystem;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the per-thread sandbox decision.
|
|
35
|
+
*
|
|
36
|
+
* - No `sandboxSettings` → `workspace-mode` (the coarse Codex mode with broad
|
|
37
|
+
* reads — unchanged default behavior).
|
|
38
|
+
* - `sandboxSettings` present → a granular permission `profile` that restricts
|
|
39
|
+
* reads to an allow-list (worktree + platform defaults + explicit reads) and
|
|
40
|
+
* writes to the worktree + explicit writable roots.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveCodexSandbox(input: SandboxResolveInput): ResolvedCodexSandbox;
|
|
43
|
+
//# sourceMappingURL=sandboxPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandboxPolicy.d.ts","sourceRoot":"","sources":["../../src/config/sandboxPolicy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAEX,oBAAoB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAsB;IACtC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IACnC,wEAAwE;IACxE,IAAI,EAAE,WAAW,CAAC;IAClB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,eAAe,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAMD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,mBAAmB,GACxB,oBAAoB,CAiDtB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isAbsolute } from "node:path";
|
|
2
|
+
/** Stable id for the per-thread permission profile Cyrus builds. */
|
|
3
|
+
export const CYRUS_SANDBOX_PROFILE_ID = "cyrus-sandbox";
|
|
4
|
+
function uniqueAbsolute(paths) {
|
|
5
|
+
return [...new Set(paths.filter((p) => p && isAbsolute(p)))];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the per-thread sandbox decision.
|
|
9
|
+
*
|
|
10
|
+
* - No `sandboxSettings` → `workspace-mode` (the coarse Codex mode with broad
|
|
11
|
+
* reads — unchanged default behavior).
|
|
12
|
+
* - `sandboxSettings` present → a granular permission `profile` that restricts
|
|
13
|
+
* reads to an allow-list (worktree + platform defaults + explicit reads) and
|
|
14
|
+
* writes to the worktree + explicit writable roots.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveCodexSandbox(input) {
|
|
17
|
+
const { mode, workingDirectory, writableRoots, networkAccess } = input;
|
|
18
|
+
if (!input.sandboxSettings) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "workspace-mode",
|
|
21
|
+
mode,
|
|
22
|
+
writableRoots: uniqueAbsolute([
|
|
23
|
+
...(workingDirectory ? [workingDirectory] : []),
|
|
24
|
+
...writableRoots,
|
|
25
|
+
]),
|
|
26
|
+
networkAccess,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const { allowRead = [], allowWrite = [] } = input.sandboxSettings;
|
|
30
|
+
const cwd = workingDirectory;
|
|
31
|
+
// Extra writable roots beyond the worktree (cwd is covered by :workspace_roots).
|
|
32
|
+
const writableAbs = uniqueAbsolute([...writableRoots, ...allowWrite]).filter((p) => p !== cwd);
|
|
33
|
+
// Readable-only roots: explicit reads not already writable / the worktree.
|
|
34
|
+
const readableAbs = uniqueAbsolute(allowRead).filter((p) => p !== cwd && !writableAbs.includes(p));
|
|
35
|
+
// Danger-full-access keeps broad access; read-only forbids writes; the
|
|
36
|
+
// default (workspace-write) makes the worktree writable.
|
|
37
|
+
const dangerFull = mode === "danger-full-access";
|
|
38
|
+
const workspaceAccess = mode === "read-only" ? "read" : "write";
|
|
39
|
+
const filesystem = dangerFull
|
|
40
|
+
? { ":root": "write" }
|
|
41
|
+
: {
|
|
42
|
+
":minimal": "read",
|
|
43
|
+
":workspace_roots": workspaceAccess,
|
|
44
|
+
":tmpdir": "write",
|
|
45
|
+
":slash_tmp": "write",
|
|
46
|
+
...Object.fromEntries(writableAbs.map((p) => [p, "write"])),
|
|
47
|
+
...Object.fromEntries(readableAbs.map((p) => [p, "read"])),
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
kind: "profile",
|
|
51
|
+
profileId: CYRUS_SANDBOX_PROFILE_ID,
|
|
52
|
+
filesystem,
|
|
53
|
+
networkAccess,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sandboxPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandboxPolicy.js","sourceRoot":"","sources":["../../src/config/sandboxPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAOvC,oEAAoE;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AAgCxD,SAAS,cAAc,CAAC,KAAe;IACtC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAClC,KAA0B;IAE1B,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAEvE,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC5B,OAAO;YACN,IAAI,EAAE,gBAAgB;YACtB,IAAI;YACJ,aAAa,EAAE,cAAc,CAAC;gBAC7B,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,GAAG,aAAa;aAChB,CAAC;YACF,aAAa;SACb,CAAC;IACH,CAAC;IAED,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC;IAClE,MAAM,GAAG,G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CodexItem, } from "./backend/types.js";
|
|
2
|
+
export { CodexEventMapper, type MapperContext } from "./CodexEventMapper.js";
|
|
1
3
|
export { CodexRunner } from "./CodexRunner.js";
|
|
2
4
|
export { SimpleCodexRunner } from "./SimpleCodexRunner.js";
|
|
3
|
-
export type {
|
|
5
|
+
export type { CodexRunnerConfig, CodexRunnerEvents, CodexSessionInfo, } from "./types.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACX,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,oBAAoB,EACpB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type { ApprovalMode, ModelReasoningEffort, SandboxMode,
|
|
1
|
+
import type { ApprovalMode, ModelReasoningEffort, SandboxMode, WebSearchMode } from "@openai/codex-sdk";
|
|
2
2
|
import type { AgentRunnerConfig, AgentSessionInfo, SDKMessage } from "cyrus-core";
|
|
3
|
+
import type { CyrusSandboxFilesystem } from "./config/sandboxPolicy.js";
|
|
3
4
|
export type CodexConfigValue = string | number | boolean | CodexConfigValue[] | {
|
|
4
5
|
[key: string]: CodexConfigValue;
|
|
5
6
|
};
|
|
6
7
|
export type CodexConfigOverrides = {
|
|
7
8
|
[key: string]: CodexConfigValue;
|
|
8
9
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Typed event shape emitted by Codex SDK thread streams.
|
|
11
|
-
*/
|
|
12
|
-
export type CodexJsonEvent = ThreadEvent;
|
|
13
10
|
/**
|
|
14
11
|
* Configuration for CodexRunner.
|
|
15
12
|
*/
|
|
@@ -38,8 +35,14 @@ export interface CodexRunnerConfig extends AgentRunnerConfig {
|
|
|
38
35
|
skipGitRepoCheck?: boolean;
|
|
39
36
|
/** Additional global Codex config overrides passed through SDK `config` */
|
|
40
37
|
configOverrides?: CodexConfigOverrides;
|
|
41
|
-
/** JSON Schema for structured output (passed to
|
|
38
|
+
/** JSON Schema for structured output (passed to turn/start as outputSchema) */
|
|
42
39
|
outputSchema?: unknown;
|
|
40
|
+
/**
|
|
41
|
+
* Filesystem sandbox intent (allow/deny read, allow write). When present, the
|
|
42
|
+
* session runs under a granular per-thread sandbox policy instead of the
|
|
43
|
+
* coarse default mode. Paths must be absolute.
|
|
44
|
+
*/
|
|
45
|
+
sandboxSettings?: CyrusSandboxFilesystem;
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Session metadata for CodexRunner.
|
|
@@ -54,6 +57,5 @@ export interface CodexRunnerEvents {
|
|
|
54
57
|
message: (message: SDKMessage) => void;
|
|
55
58
|
error: (error: Error) => void;
|
|
56
59
|
complete: (messages: SDKMessage[]) => void;
|
|
57
|
-
streamEvent: (event: CodexJsonEvent) => void;
|
|
58
60
|
}
|
|
59
61
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACzB,MAAM,GACN,MAAM,GACN,OAAO,GACP,gBAAgB,EAAE,GAClB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,CAAC;AAEvC,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,kDAAkD;IAClD,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,qDAAqD;IACrD,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACzD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyrus-codex-runner",
|
|
3
|
-
"version": "0.2.64
|
|
3
|
+
"version": "0.2.64",
|
|
4
4
|
"description": "Codex CLI process wrapper for Cyrus",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@openai/codex
|
|
13
|
-
"
|
|
14
|
-
"cyrus-
|
|
12
|
+
"@openai/codex": "^0.137.0",
|
|
13
|
+
"@openai/codex-sdk": "^0.137.0",
|
|
14
|
+
"cyrus-core": "0.2.64",
|
|
15
|
+
"cyrus-simple-agent-runner": "0.2.64"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@types/node": "^20.0.0",
|