mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
app-server: add host config layer
git-stack-id: dev/aaronl/per-host-config---4iq5iwu8x2lp1i git-stack-title: app-server: add host config layer
This commit is contained in:
@@ -413,6 +413,19 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigHostSetParams": {
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": true,
|
||||
"description": "Full replacement app-server host config layer, shaped like config.toml. An empty object clears the host config layer.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigReadParams": {
|
||||
"properties": {
|
||||
"cwd": {
|
||||
@@ -5981,6 +5994,30 @@
|
||||
"title": "Config/readRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"config/host/set"
|
||||
],
|
||||
"title": "Config/host/setRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/ConfigHostSetParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Config/host/setRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
+61
@@ -1981,6 +1981,30 @@
|
||||
"title": "Config/readRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"config/host/set"
|
||||
],
|
||||
"title": "Config/host/setRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/ConfigHostSetParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Config/host/setRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -7479,6 +7503,26 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigHostSetParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": true,
|
||||
"description": "Full replacement app-server host config layer, shaped like config.toml. An empty object clears the host config layer.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config"
|
||||
],
|
||||
"title": "ConfigHostSetParams",
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigHostSetResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ConfigHostSetResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigLayer": {
|
||||
"properties": {
|
||||
"config": true,
|
||||
@@ -7603,6 +7647,23 @@
|
||||
"title": "UserConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "In-memory host-supplied config for the current app-server instance.",
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"appServerHost"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSourceType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
|
||||
"properties": {
|
||||
|
||||
+61
@@ -2707,6 +2707,30 @@
|
||||
"title": "Config/readRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"config/host/set"
|
||||
],
|
||||
"title": "Config/host/setRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/ConfigHostSetParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Config/host/setRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -3848,6 +3872,26 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigHostSetParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": true,
|
||||
"description": "Full replacement app-server host config layer, shaped like config.toml. An empty object clears the host config layer.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config"
|
||||
],
|
||||
"title": "ConfigHostSetParams",
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigHostSetResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ConfigHostSetResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ConfigLayer": {
|
||||
"properties": {
|
||||
"config": true,
|
||||
@@ -3972,6 +4016,23 @@
|
||||
"title": "UserConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "In-memory host-supplied config for the current app-server instance.",
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"appServerHost"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSourceType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
|
||||
"properties": {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": true,
|
||||
"description": "Full replacement app-server host config layer, shaped like config.toml. An empty object clears the host config layer.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config"
|
||||
],
|
||||
"title": "ConfigHostSetParams",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ConfigHostSetResponse",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -544,6 +544,23 @@
|
||||
"title": "UserConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "In-memory host-supplied config for the current app-server instance.",
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"appServerHost"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSourceType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
|
||||
"properties": {
|
||||
|
||||
@@ -106,6 +106,23 @@
|
||||
"title": "UserConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "In-memory host-supplied config for the current app-server instance.",
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"appServerHost"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSourceType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "AppServerHostConfigLayerSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
|
||||
"properties": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { JsonValue } from "../serde_json/JsonValue";
|
||||
|
||||
export type ConfigHostSetParams = {
|
||||
/**
|
||||
* Full replacement app-server host config layer, shaped like config.toml.
|
||||
* An empty object clears the host config layer.
|
||||
*/
|
||||
config: { [key in string]?: JsonValue }, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ConfigHostSetResponse = Record<string, never>;
|
||||
@@ -18,4 +18,4 @@ file: AbsolutePathBuf,
|
||||
* Name of the selected profile-v2 config layered on top of the base
|
||||
* user config, when this layer represents one.
|
||||
*/
|
||||
profile: string | null, } | { "type": "project", dotCodexFolder: AbsolutePathBuf, } | { "type": "sessionFlags" } | { "type": "legacyManagedConfigTomlFromFile", file: AbsolutePathBuf, } | { "type": "legacyManagedConfigTomlFromMdm" };
|
||||
profile: string | null, } | { "type": "appServerHost" } | { "type": "project", dotCodexFolder: AbsolutePathBuf, } | { "type": "sessionFlags" } | { "type": "legacyManagedConfigTomlFromFile", file: AbsolutePathBuf, } | { "type": "legacyManagedConfigTomlFromMdm" };
|
||||
|
||||
@@ -66,6 +66,8 @@ export type { ComputerUseRequirements } from "./ComputerUseRequirements";
|
||||
export type { Config } from "./Config";
|
||||
export type { ConfigBatchWriteParams } from "./ConfigBatchWriteParams";
|
||||
export type { ConfigEdit } from "./ConfigEdit";
|
||||
export type { ConfigHostSetParams } from "./ConfigHostSetParams";
|
||||
export type { ConfigHostSetResponse } from "./ConfigHostSetResponse";
|
||||
export type { ConfigLayer } from "./ConfigLayer";
|
||||
export type { ConfigLayerMetadata } from "./ConfigLayerMetadata";
|
||||
export type { ConfigLayerSource } from "./ConfigLayerSource";
|
||||
|
||||
@@ -991,6 +991,11 @@ client_request_definitions! {
|
||||
serialization: global_shared_read("config"),
|
||||
response: v2::ConfigReadResponse,
|
||||
},
|
||||
ConfigHostSet => "config/host/set" {
|
||||
params: v2::ConfigHostSetParams,
|
||||
serialization: global("config"),
|
||||
response: v2::ConfigHostSetResponse,
|
||||
},
|
||||
ExternalAgentConfigDetect => "externalAgentConfig/detect" {
|
||||
params: v2::ExternalAgentConfigDetectParams,
|
||||
serialization: global("config"),
|
||||
|
||||
@@ -58,6 +58,9 @@ pub enum ConfigLayerSource {
|
||||
profile: Option<String>,
|
||||
},
|
||||
|
||||
/// In-memory host-supplied config for the current app-server instance.
|
||||
AppServerHost,
|
||||
|
||||
/// Path to a .codex/ folder within a project. There could be multiple of
|
||||
/// these between `cwd` and the project/repo root.
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -96,6 +99,7 @@ impl ConfigLayerSource {
|
||||
20
|
||||
}
|
||||
}
|
||||
ConfigLayerSource::AppServerHost => 22,
|
||||
ConfigLayerSource::Project { .. } => 25,
|
||||
ConfigLayerSource::SessionFlags => 30,
|
||||
ConfigLayerSource::LegacyManagedConfigTomlFromFile { .. } => 40,
|
||||
@@ -377,6 +381,20 @@ pub struct ConfigReadResponse {
|
||||
pub layers: Option<Vec<ConfigLayer>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ConfigHostSetParams {
|
||||
/// Full replacement app-server host config layer, shaped like config.toml.
|
||||
/// An empty object clears the host config layer.
|
||||
pub config: HashMap<String, JsonValue>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ConfigHostSetResponse {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS, ExperimentalApi)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
||||
@@ -221,13 +221,25 @@ Example with notification opt-out:
|
||||
- `mcpServer/tool/call` — call a tool on a thread's configured MCP server by `threadId`, `server`, `tool`, optional `arguments`, and optional `_meta`, returning the MCP tool result.
|
||||
- `windowsSandbox/setupStart` — start Windows sandbox setup for the selected mode (`elevated` or `unelevated`); accepts an optional absolute `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`.
|
||||
- `feedback/upload` — submit a feedback report (classification + optional reason/logs, conversation_id, and optional `extraLogFiles` attachments array); returns the tracking thread id.
|
||||
- `config/read` — fetch the effective config on disk after resolving config layering, including opaque `desktop` values stored in `config.toml`.
|
||||
- `config/read` — fetch the effective config after resolving config layering, including opaque `desktop` values stored in `config.toml`.
|
||||
- `config/host/set` — replace the in-memory host config layer for this app-server process. The layer is shaped like `config.toml`, sits above user config and below project/session overrides, and `{ "config": {} }` clears it.
|
||||
- `externalAgentConfig/detect` — detect migratable external-agent artifacts with `includeHome` and optional `cwds`; each detected item includes `cwd` (`null` for home), and plugin/session migration items may additionally include structured `details` grouping plugin ids or session metadata.
|
||||
- `externalAgentConfig/import` — apply selected external-agent migration items by passing explicit `migrationItems` with `cwd` (`null` for home) and any plugin/session `details` returned by detect. When a request includes migration items, the server emits `externalAgentConfig/import/completed` once after the full import finishes (immediately after the response when everything completed synchronously, or after background imports finish).
|
||||
- `config/value/write` — write a single config key/value to the user's config.toml on disk; dotted paths such as `desktop.someKey` use the same generic write surface.
|
||||
- `config/batchWrite` — apply multiple config edits atomically to the user's config.toml on disk, with optional `reloadUserConfig: true` to hot-reload loaded threads, including multiple `desktop.*` edits.
|
||||
- `configRequirements/read` — fetch loaded requirements constraints from `requirements.toml` and/or MDM (or `null` if none are configured), including allow-lists (`allowedApprovalPolicies`, `allowedSandboxModes`, `allowedWebSearchModes`), lifecycle hook lockdown (`allowManagedHooksOnly`), computer use policy (`computerUse`), pinned feature values (`featureRequirements`), managed lifecycle hooks (`hooks`), `enforceResidency`, and `network` constraints such as canonical domain/socket permissions plus `managedAllowedDomainsOnly` and `dangerFullAccessDenylistOnly`.
|
||||
|
||||
### Example: Set host config for one app-server process
|
||||
|
||||
Use `config/host/set` when the host needs an app-server-scoped config layer that behaves like an in-memory `config.toml` layer for later config reads and thread creation.
|
||||
|
||||
```json
|
||||
{ "method": "config/host/set", "id": 7, "params": { "config": { "model": "gpt-5.4" } } }
|
||||
{ "id": 7, "result": {} }
|
||||
{ "method": "config/host/set", "id": 8, "params": { "config": {} } }
|
||||
{ "id": 8, "result": {} }
|
||||
```
|
||||
|
||||
### Example: Start or resume a thread
|
||||
|
||||
Start a fresh thread when you need a new Codex conversation.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use codex_config::ConfigLayerSource;
|
||||
use codex_config::ConfigLayerStackOrdering;
|
||||
use codex_config::types::PluginConfig;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigBuilder;
|
||||
@@ -124,13 +126,22 @@ impl ExternalAgentConfigService {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn detect(
|
||||
&self,
|
||||
params: ExternalAgentConfigDetectOptions,
|
||||
) -> io::Result<Vec<ExternalAgentConfigMigrationItem>> {
|
||||
self.detect_with_config(params, /*config*/ None).await
|
||||
}
|
||||
|
||||
pub(crate) async fn detect_with_config(
|
||||
&self,
|
||||
params: ExternalAgentConfigDetectOptions,
|
||||
config: Option<&Config>,
|
||||
) -> io::Result<Vec<ExternalAgentConfigMigrationItem>> {
|
||||
let mut items = Vec::new();
|
||||
if params.include_home {
|
||||
self.detect_migrations(/*repo_root*/ None, &mut items)
|
||||
self.detect_migrations(/*repo_root*/ None, config, &mut items)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -138,7 +149,8 @@ impl ExternalAgentConfigService {
|
||||
let Some(repo_root) = find_repo_root(Some(cwd))? else {
|
||||
continue;
|
||||
};
|
||||
self.detect_migrations(Some(&repo_root), &mut items).await?;
|
||||
self.detect_migrations(Some(&repo_root), config, &mut items)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(items)
|
||||
@@ -261,6 +273,7 @@ impl ExternalAgentConfigService {
|
||||
async fn detect_migrations(
|
||||
&self,
|
||||
repo_root: Option<&Path>,
|
||||
app_server_config: Option<&Config>,
|
||||
items: &mut Vec<ExternalAgentConfigMigrationItem>,
|
||||
) -> io::Result<()> {
|
||||
let cwd = repo_root.map(Path::to_path_buf);
|
||||
@@ -498,49 +511,66 @@ impl ExternalAgentConfigService {
|
||||
}
|
||||
|
||||
if let Some(settings) = settings.as_ref() {
|
||||
match ConfigBuilder::default()
|
||||
.codex_home(self.codex_home.clone())
|
||||
.fallback_cwd(Some(self.codex_home.clone()))
|
||||
.build()
|
||||
.await
|
||||
{
|
||||
Ok(config) => {
|
||||
let configured_plugin_ids = config
|
||||
.config_layer_stack
|
||||
.get_active_user_layer()
|
||||
.and_then(|user_layer| user_layer.config.get("plugins"))
|
||||
.and_then(|plugins| {
|
||||
match plugins.clone().try_into::<HashMap<String, PluginConfig>>() {
|
||||
Ok(plugins) => Some(plugins),
|
||||
Err(err) => {
|
||||
tracing::warn!("invalid plugins config: {err}");
|
||||
None
|
||||
}
|
||||
}
|
||||
})
|
||||
.map(|plugins| plugins.into_keys().collect::<HashSet<_>>())
|
||||
.unwrap_or_default();
|
||||
let configured_marketplace_plugins = configured_marketplace_plugins(
|
||||
&config,
|
||||
&PluginsManager::new(self.codex_home.clone()),
|
||||
)?;
|
||||
if let Some(item) = self.detect_plugin_migration(
|
||||
source_settings.as_path(),
|
||||
repo_root.unwrap_or(self.external_agent_home.as_path()),
|
||||
cwd.clone(),
|
||||
settings,
|
||||
&configured_plugin_ids,
|
||||
&configured_marketplace_plugins,
|
||||
) {
|
||||
items.push(item);
|
||||
let fallback_config = if app_server_config.is_none() {
|
||||
match ConfigBuilder::default()
|
||||
.codex_home(self.codex_home.clone())
|
||||
.fallback_cwd(Some(self.codex_home.clone()))
|
||||
.build()
|
||||
.await
|
||||
{
|
||||
Ok(config) => Some(config),
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
error = %err,
|
||||
settings_path = %source_settings.display(),
|
||||
"skipping external agent plugin migration detection because config load failed"
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
error = %err,
|
||||
settings_path = %source_settings.display(),
|
||||
"skipping external agent plugin migration detection because config load failed"
|
||||
);
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(config) = app_server_config.or(fallback_config.as_ref()) {
|
||||
let configured_plugin_ids = config
|
||||
.config_layer_stack
|
||||
.get_layers(
|
||||
ConfigLayerStackOrdering::LowestPrecedenceFirst,
|
||||
/*include_disabled*/ false,
|
||||
)
|
||||
.into_iter()
|
||||
.filter(|layer| {
|
||||
matches!(
|
||||
layer.name,
|
||||
ConfigLayerSource::User { .. } | ConfigLayerSource::AppServerHost
|
||||
)
|
||||
})
|
||||
.filter_map(|layer| layer.config.get("plugins"))
|
||||
.filter_map(|plugins| {
|
||||
match plugins.clone().try_into::<HashMap<String, PluginConfig>>() {
|
||||
Ok(plugins) => Some(plugins),
|
||||
Err(err) => {
|
||||
tracing::warn!("invalid plugins config: {err}");
|
||||
None
|
||||
}
|
||||
}
|
||||
})
|
||||
.flat_map(HashMap::into_keys)
|
||||
.collect::<HashSet<_>>();
|
||||
let configured_marketplace_plugins = configured_marketplace_plugins(
|
||||
config,
|
||||
&PluginsManager::new(self.codex_home.clone()),
|
||||
)?;
|
||||
if let Some(item) = self.detect_plugin_migration(
|
||||
source_settings.as_path(),
|
||||
repo_root.unwrap_or(self.external_agent_home.as_path()),
|
||||
cwd.clone(),
|
||||
settings,
|
||||
&configured_plugin_ids,
|
||||
&configured_marketplace_plugins,
|
||||
) {
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1531,6 +1531,81 @@ enabled = true
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn detect_repo_skips_plugins_that_are_already_configured_by_app_server_host() {
|
||||
let root = TempDir::new().expect("create tempdir");
|
||||
let external_agent_home = root.path().join(EXTERNAL_AGENT_DIR);
|
||||
let codex_home = root.path().join(".codex");
|
||||
let repo_root = root.path().join("repo");
|
||||
fs::create_dir_all(repo_root.join(".git")).expect("create git dir");
|
||||
fs::create_dir_all(repo_root.join(EXTERNAL_AGENT_DIR)).expect("create repo external agent dir");
|
||||
fs::create_dir_all(&codex_home).expect("create codex home");
|
||||
fs::write(
|
||||
repo_root.join(EXTERNAL_AGENT_DIR).join("settings.json"),
|
||||
r#"{
|
||||
"enabledPlugins": {
|
||||
"formatter@acme-tools": true,
|
||||
"deployer@acme-tools": true
|
||||
},
|
||||
"extraKnownMarketplaces": {
|
||||
"acme-tools": {
|
||||
"source": "acme-corp/external-agent-plugins"
|
||||
}
|
||||
}
|
||||
}"#,
|
||||
)
|
||||
.expect("write repo settings");
|
||||
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.clone())
|
||||
.fallback_cwd(Some(repo_root.clone()))
|
||||
.app_server_host_config(Some(
|
||||
toml::from_str(
|
||||
r#"
|
||||
[plugins."formatter@acme-tools"]
|
||||
enabled = true
|
||||
"#,
|
||||
)
|
||||
.expect("host config toml"),
|
||||
))
|
||||
.build()
|
||||
.await
|
||||
.expect("build config");
|
||||
|
||||
let items = service_for_paths(external_agent_home, codex_home)
|
||||
.detect_with_config(
|
||||
ExternalAgentConfigDetectOptions {
|
||||
include_home: false,
|
||||
cwds: Some(vec![repo_root.clone()]),
|
||||
},
|
||||
Some(&config),
|
||||
)
|
||||
.await
|
||||
.expect("detect");
|
||||
|
||||
assert_eq!(
|
||||
items,
|
||||
vec![ExternalAgentConfigMigrationItem {
|
||||
item_type: ExternalAgentConfigMigrationItemType::Plugins,
|
||||
description: format!(
|
||||
"Migrate enabled plugins from {}",
|
||||
repo_root
|
||||
.join(EXTERNAL_AGENT_DIR)
|
||||
.join("settings.json")
|
||||
.display()
|
||||
),
|
||||
cwd: Some(repo_root),
|
||||
details: Some(MigrationDetails {
|
||||
plugins: vec![PluginsMigration {
|
||||
marketplace_name: "acme-tools".to_string(),
|
||||
plugin_names: vec!["deployer".to_string()],
|
||||
}],
|
||||
..Default::default()
|
||||
}),
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn detect_repo_skips_plugins_that_are_disabled_in_codex() {
|
||||
let root = TempDir::new().expect("create tempdir");
|
||||
|
||||
@@ -29,6 +29,7 @@ pub(crate) struct ConfigManager {
|
||||
codex_home: PathBuf,
|
||||
cli_overrides: Arc<RwLock<Vec<(String, TomlValue)>>>,
|
||||
runtime_feature_enablement: Arc<RwLock<BTreeMap<String, bool>>>,
|
||||
app_server_host_config: Arc<RwLock<Option<TomlValue>>>,
|
||||
loader_overrides: LoaderOverrides,
|
||||
strict_config: bool,
|
||||
cloud_requirements: Arc<RwLock<CloudRequirementsLoader>>,
|
||||
@@ -50,6 +51,7 @@ impl ConfigManager {
|
||||
codex_home,
|
||||
cli_overrides: Arc::new(RwLock::new(cli_overrides)),
|
||||
runtime_feature_enablement: Arc::new(RwLock::new(BTreeMap::new())),
|
||||
app_server_host_config: Arc::new(RwLock::new(None)),
|
||||
loader_overrides,
|
||||
strict_config,
|
||||
cloud_requirements: Arc::new(RwLock::new(cloud_requirements)),
|
||||
@@ -80,6 +82,13 @@ impl ConfigManager {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) fn current_app_server_host_config(&self) -> Option<TomlValue> {
|
||||
self.app_server_host_config
|
||||
.read()
|
||||
.map(|guard| guard.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) fn extend_runtime_feature_enablement<I>(&self, enablement: I) -> Result<(), ()>
|
||||
where
|
||||
I: IntoIterator<Item = (String, bool)>,
|
||||
@@ -115,6 +124,15 @@ impl ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn replace_app_server_host_config(
|
||||
&self,
|
||||
app_server_host_config: Option<TomlValue>,
|
||||
) -> Result<(), ()> {
|
||||
let mut guard = self.app_server_host_config.write().map_err(|_| ())?;
|
||||
*guard = app_server_host_config;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn current_thread_config_loader(&self) -> Arc<dyn ThreadConfigLoader> {
|
||||
self.thread_config_loader
|
||||
.read()
|
||||
@@ -235,6 +253,7 @@ impl ConfigManager {
|
||||
.cli_overrides(merged_cli_overrides)
|
||||
.loader_overrides(self.loader_overrides.clone())
|
||||
.strict_config(self.strict_config)
|
||||
.app_server_host_config(self.current_app_server_host_config())
|
||||
.harness_overrides(typesafe_overrides)
|
||||
.fallback_cwd(fallback_cwd)
|
||||
.cloud_requirements(self.current_cloud_requirements())
|
||||
@@ -256,6 +275,18 @@ impl ConfigManager {
|
||||
pub(crate) async fn load_config_layers(
|
||||
&self,
|
||||
cwd: Option<AbsolutePathBuf>,
|
||||
) -> std::io::Result<ConfigLayerStack> {
|
||||
self.load_config_layers_with_app_server_host_config(
|
||||
cwd,
|
||||
self.current_app_server_host_config(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn load_config_layers_with_app_server_host_config(
|
||||
&self,
|
||||
cwd: Option<AbsolutePathBuf>,
|
||||
app_server_host_config: Option<TomlValue>,
|
||||
) -> std::io::Result<ConfigLayerStack> {
|
||||
let thread_config_loader = self.current_thread_config_loader();
|
||||
load_config_layers_state(
|
||||
@@ -266,6 +297,7 @@ impl ConfigManager {
|
||||
codex_config::ConfigLoadOptions {
|
||||
loader_overrides: self.loader_overrides.clone(),
|
||||
strict_config: self.strict_config,
|
||||
app_server_host_config,
|
||||
},
|
||||
self.current_cloud_requirements(),
|
||||
thread_config_loader.as_ref(),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use crate::config_manager::ConfigManager;
|
||||
use codex_app_server_protocol::Config as ApiConfig;
|
||||
use codex_app_server_protocol::ConfigBatchWriteParams;
|
||||
use codex_app_server_protocol::ConfigHostSetParams;
|
||||
use codex_app_server_protocol::ConfigHostSetResponse;
|
||||
use codex_app_server_protocol::ConfigLayerMetadata;
|
||||
use codex_app_server_protocol::ConfigLayerSource;
|
||||
use codex_app_server_protocol::ConfigReadParams;
|
||||
@@ -29,6 +31,7 @@ use codex_core::path_utils::write_atomically;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use serde_json::Value as JsonValue;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
@@ -190,6 +193,65 @@ impl ConfigManager {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn set_host_config(
|
||||
&self,
|
||||
params: ConfigHostSetParams,
|
||||
) -> Result<ConfigHostSetResponse, ConfigManagerError> {
|
||||
let app_server_host_config = parse_app_server_host_config(params.config)?;
|
||||
|
||||
let layers = self
|
||||
.load_config_layers_with_app_server_host_config(
|
||||
/*cwd*/ None,
|
||||
app_server_host_config.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
ConfigManagerError::write(
|
||||
ConfigWriteErrorCode::ConfigValidationError,
|
||||
format!("Invalid app-server host configuration: {err}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
if let Some(host_config) = app_server_host_config.as_ref() {
|
||||
let host_config_toml =
|
||||
deserialize_config_toml_with_base(host_config.clone(), self.codex_home()).map_err(
|
||||
|err| {
|
||||
ConfigManagerError::write(
|
||||
ConfigWriteErrorCode::ConfigValidationError,
|
||||
format!("Invalid app-server host configuration: {err}"),
|
||||
)
|
||||
},
|
||||
)?;
|
||||
validate_feature_requirements_for_config_toml(
|
||||
&host_config_toml,
|
||||
layers.requirements().feature_requirements.as_ref(),
|
||||
)
|
||||
.map_err(|err| {
|
||||
ConfigManagerError::write(
|
||||
ConfigWriteErrorCode::ConfigValidationError,
|
||||
format!("Invalid app-server host configuration: {err}"),
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
validate_config(&layers.effective_config()).map_err(|err| {
|
||||
ConfigManagerError::write(
|
||||
ConfigWriteErrorCode::ConfigValidationError,
|
||||
format!("Invalid app-server host configuration: {err}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
self.replace_app_server_host_config(app_server_host_config)
|
||||
.map_err(|()| {
|
||||
ConfigManagerError::io(
|
||||
"failed to update app-server host config",
|
||||
std::io::Error::other("app-server host config lock poisoned"),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(ConfigHostSetResponse {})
|
||||
}
|
||||
|
||||
async fn apply_edits(
|
||||
&self,
|
||||
file_path: Option<String>,
|
||||
@@ -399,6 +461,25 @@ fn parse_value(value: JsonValue) -> Result<Option<TomlValue>, String> {
|
||||
.map_err(|err| format!("invalid value: {err}"))
|
||||
}
|
||||
|
||||
fn parse_app_server_host_config(
|
||||
config: HashMap<String, JsonValue>,
|
||||
) -> Result<Option<TomlValue>, ConfigManagerError> {
|
||||
if config.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let host_config = serde_json::to_value(config)
|
||||
.and_then(serde_json::from_value::<TomlValue>)
|
||||
.map_err(|err| {
|
||||
ConfigManagerError::write(
|
||||
ConfigWriteErrorCode::ConfigValidationError,
|
||||
format!("invalid app-server host config: {err}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(Some(host_config))
|
||||
}
|
||||
|
||||
fn parse_key_path(path: &str) -> Result<Vec<String>, String> {
|
||||
if path.trim().is_empty() {
|
||||
return Err("keyPath must not be empty".to_string());
|
||||
@@ -608,6 +689,7 @@ fn override_message(layer: &ConfigLayerSource) -> String {
|
||||
ConfigLayerSource::System { file } => {
|
||||
format!("Overridden by managed config (system): {}", file.display())
|
||||
}
|
||||
ConfigLayerSource::AppServerHost => "Overridden by app-server host config".to_string(),
|
||||
ConfigLayerSource::Project { dot_codex_folder } => format!(
|
||||
"Overridden by project config: {}/{CONFIG_TOML_FILE}",
|
||||
dot_codex_folder.display(),
|
||||
|
||||
@@ -872,6 +872,11 @@ impl MessageProcessor {
|
||||
.read(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::ConfigHostSet { params, .. } => self
|
||||
.config_processor
|
||||
.host_set(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::WindowsSandboxReadiness { .. } => self
|
||||
.windows_sandbox_processor
|
||||
.windows_sandbox_readiness()
|
||||
|
||||
@@ -11,6 +11,8 @@ use codex_app_server_protocol::AppListUpdatedNotification;
|
||||
use codex_app_server_protocol::ClientResponsePayload;
|
||||
use codex_app_server_protocol::ComputerUseRequirements;
|
||||
use codex_app_server_protocol::ConfigBatchWriteParams;
|
||||
use codex_app_server_protocol::ConfigHostSetParams;
|
||||
use codex_app_server_protocol::ConfigHostSetResponse;
|
||||
use codex_app_server_protocol::ConfigReadParams;
|
||||
use codex_app_server_protocol::ConfigReadResponse;
|
||||
use codex_app_server_protocol::ConfigRequirements;
|
||||
@@ -144,6 +146,19 @@ impl ConfigRequestProcessor {
|
||||
.map(ClientResponsePayload::ConfigBatchWrite)
|
||||
}
|
||||
|
||||
pub(crate) async fn host_set(
|
||||
&self,
|
||||
params: ConfigHostSetParams,
|
||||
) -> Result<ConfigHostSetResponse, JSONRPCErrorError> {
|
||||
self.handle_config_mutation_result(
|
||||
self.config_manager
|
||||
.set_host_config(params)
|
||||
.await
|
||||
.map_err(map_error),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn experimental_feature_enablement_set(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
||||
@@ -80,12 +80,29 @@ impl ExternalAgentConfigRequestProcessor {
|
||||
&self,
|
||||
params: ExternalAgentConfigDetectParams,
|
||||
) -> Result<ExternalAgentConfigDetectResponse, JSONRPCErrorError> {
|
||||
let config = match self
|
||||
.config_manager
|
||||
.load_latest_config(/*fallback_cwd*/ None)
|
||||
.await
|
||||
{
|
||||
Ok(config) => Some(config),
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
error = %err,
|
||||
"external agent config detection could not load app-server config"
|
||||
);
|
||||
None
|
||||
}
|
||||
};
|
||||
let items = self
|
||||
.migration_service
|
||||
.detect(ExternalAgentConfigDetectOptions {
|
||||
include_home: params.include_home,
|
||||
cwds: params.cwds,
|
||||
})
|
||||
.detect_with_config(
|
||||
ExternalAgentConfigDetectOptions {
|
||||
include_home: params.include_home,
|
||||
cwds: params.cwds,
|
||||
},
|
||||
config.as_ref(),
|
||||
)
|
||||
.await
|
||||
.map_err(|err| internal_error(err.to_string()))?;
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ fn config_path_for_layer(layer: &ConfigLayerEntry, config_toml_file: &str) -> Op
|
||||
}
|
||||
ConfigLayerSource::LegacyManagedConfigTomlFromFile { file } => Some(file.to_path_buf()),
|
||||
ConfigLayerSource::Mdm { .. }
|
||||
| ConfigLayerSource::AppServerHost
|
||||
| ConfigLayerSource::SessionFlags
|
||||
| ConfigLayerSource::LegacyManagedConfigTomlFromMdm => None,
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ pub async fn load_config_layers_state(
|
||||
let ConfigLoadOptions {
|
||||
loader_overrides: overrides,
|
||||
strict_config,
|
||||
app_server_host_config,
|
||||
} = options.into();
|
||||
let active_user_profile = overrides.user_config_profile.clone();
|
||||
let ignore_managed_requirements = overrides.ignore_managed_requirements;
|
||||
@@ -184,7 +185,11 @@ pub async fn load_config_layers_state(
|
||||
.map(AbsolutePathBuf::as_path)
|
||||
.unwrap_or(codex_home);
|
||||
if strict_config {
|
||||
validate_cli_overrides_strictly(&cli_overrides_layer, base_dir)?;
|
||||
validate_inline_config_layer_strictly(
|
||||
&cli_overrides_layer,
|
||||
base_dir,
|
||||
"-c/--config override",
|
||||
)?;
|
||||
}
|
||||
Some(resolve_relative_paths_in_config_toml(
|
||||
cli_overrides_layer,
|
||||
@@ -256,6 +261,22 @@ pub async fn load_config_layers_state(
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(app_server_host_config) = app_server_host_config {
|
||||
if strict_config {
|
||||
validate_inline_config_layer_strictly(
|
||||
&app_server_host_config,
|
||||
codex_home,
|
||||
"app-server host config override",
|
||||
)?;
|
||||
}
|
||||
let app_server_host_config =
|
||||
resolve_relative_paths_in_config_toml(app_server_host_config, codex_home)?;
|
||||
layers.push(ConfigLayerEntry::new(
|
||||
ConfigLayerSource::AppServerHost,
|
||||
app_server_host_config,
|
||||
));
|
||||
}
|
||||
|
||||
let mut startup_warnings = None;
|
||||
if let Some(cwd) = cwd {
|
||||
let mut merged_so_far = TomlValue::Table(toml::map::Map::new());
|
||||
@@ -502,23 +523,23 @@ fn validate_config_toml_strictly(
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_cli_overrides_strictly(
|
||||
cli_overrides_layer: &TomlValue,
|
||||
fn validate_inline_config_layer_strictly(
|
||||
config_layer: &TomlValue,
|
||||
base_dir: &Path,
|
||||
source_label: &str,
|
||||
) -> io::Result<()> {
|
||||
let _guard = AbsolutePathBufGuard::new(base_dir);
|
||||
if let Some(ignored_path) = ignored_toml_value_field::<ConfigToml>(cli_overrides_layer.clone())
|
||||
{
|
||||
if let Some(ignored_path) = ignored_toml_value_field::<ConfigToml>(config_layer.clone()) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("unknown configuration field `{ignored_path}` in -c/--config override"),
|
||||
format!("unknown configuration field `{ignored_path}` in {source_label}"),
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(ignored_path) = unknown_feature_toml_value_field(cli_overrides_layer) {
|
||||
if let Some(ignored_path) = unknown_feature_toml_value_field(config_layer) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("unknown configuration field `{ignored_path}` in -c/--config override"),
|
||||
format!("unknown configuration field `{ignored_path}` in {source_label}"),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::ConfigLayerStackOrdering;
|
||||
use async_trait::async_trait;
|
||||
use codex_file_system::CopyOptions;
|
||||
use codex_file_system::CreateDirectoryOptions;
|
||||
@@ -42,10 +43,18 @@ impl ExecutorFileSystem for TestFileSystem {
|
||||
|
||||
async fn get_metadata(
|
||||
&self,
|
||||
_path: &AbsolutePathBuf,
|
||||
path: &AbsolutePathBuf,
|
||||
_sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<FileMetadata> {
|
||||
unimplemented!("test filesystem only supports reads")
|
||||
let metadata = tokio::fs::metadata(path.as_path()).await?;
|
||||
let symlink_metadata = tokio::fs::symlink_metadata(path.as_path()).await?;
|
||||
Ok(FileMetadata {
|
||||
is_directory: metadata.is_dir(),
|
||||
is_file: metadata.is_file(),
|
||||
is_symlink: symlink_metadata.file_type().is_symlink(),
|
||||
created_at_ms: 0,
|
||||
modified_at_ms: 0,
|
||||
})
|
||||
}
|
||||
|
||||
async fn read_directory(
|
||||
@@ -170,3 +179,51 @@ model = "gpt-dev"
|
||||
.await
|
||||
.expect("profile-v2 should allow unrelated legacy profiles in base user config");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn app_server_host_project_root_markers_apply_before_project_layer_discovery() {
|
||||
let tmp = tempdir().expect("tempdir");
|
||||
let project_root = tmp.path().join("repo");
|
||||
let cwd = project_root.join("nested");
|
||||
std::fs::create_dir_all(project_root.join(".codex")).expect("create project config dir");
|
||||
std::fs::create_dir_all(&cwd).expect("create cwd");
|
||||
std::fs::write(project_root.join("WORKSPACE"), "").expect("write project root marker");
|
||||
std::fs::write(
|
||||
project_root.join(".codex").join(CONFIG_TOML_FILE),
|
||||
"model = \"gpt-project\"\n",
|
||||
)
|
||||
.expect("write project config");
|
||||
|
||||
let stack = load_config_layers_state(
|
||||
&TestFileSystem,
|
||||
tmp.path(),
|
||||
Some(AbsolutePathBuf::try_from(cwd).expect("absolute cwd")),
|
||||
&[],
|
||||
ConfigLoadOptions {
|
||||
loader_overrides: LoaderOverrides::without_managed_config_for_tests(),
|
||||
strict_config: false,
|
||||
app_server_host_config: Some(
|
||||
toml::from_str(r#"project_root_markers = ["WORKSPACE"]"#)
|
||||
.expect("host config toml"),
|
||||
),
|
||||
},
|
||||
CloudRequirementsLoader::default(),
|
||||
&crate::NoopThreadConfigLoader,
|
||||
)
|
||||
.await
|
||||
.expect("host project markers should load");
|
||||
|
||||
assert!(
|
||||
stack
|
||||
.get_layers(
|
||||
ConfigLayerStackOrdering::LowestPrecedenceFirst,
|
||||
/*include_disabled*/ true,
|
||||
)
|
||||
.iter()
|
||||
.any(
|
||||
|layer| matches!(&layer.name, ConfigLayerSource::Project { .. })
|
||||
&& layer.config.get("model").and_then(TomlValue::as_str) == Some("gpt-project")
|
||||
),
|
||||
"host project root markers should expose the ancestor project config layer"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use toml::Value as TomlValue;
|
||||
pub struct ConfigLoadOptions {
|
||||
pub loader_overrides: LoaderOverrides,
|
||||
pub strict_config: bool,
|
||||
pub app_server_host_config: Option<TomlValue>,
|
||||
}
|
||||
|
||||
impl From<LoaderOverrides> for ConfigLoadOptions {
|
||||
@@ -28,6 +29,7 @@ impl From<LoaderOverrides> for ConfigLoadOptions {
|
||||
Self {
|
||||
loader_overrides,
|
||||
strict_config: false,
|
||||
app_server_host_config: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,6 +184,7 @@ impl ConfigLayerEntry {
|
||||
ConfigLayerSource::Mdm { .. } => None,
|
||||
ConfigLayerSource::System { file } => file.parent(),
|
||||
ConfigLayerSource::User { file, .. } => file.parent(),
|
||||
ConfigLayerSource::AppServerHost => None,
|
||||
ConfigLayerSource::Project { dot_codex_folder } => Some(dot_codex_folder.clone()),
|
||||
ConfigLayerSource::SessionFlags => None,
|
||||
ConfigLayerSource::LegacyManagedConfigTomlFromFile { .. } => None,
|
||||
|
||||
@@ -35,7 +35,9 @@ pub fn skill_config_rules_from_stack(config_layer_stack: &ConfigLayerStack) -> S
|
||||
) {
|
||||
if !matches!(
|
||||
layer.name,
|
||||
ConfigLayerSource::User { .. } | ConfigLayerSource::SessionFlags
|
||||
ConfigLayerSource::User { .. }
|
||||
| ConfigLayerSource::AppServerHost
|
||||
| ConfigLayerSource::SessionFlags
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -330,6 +330,7 @@ fn skill_roots_from_layer_stack_inner(
|
||||
});
|
||||
}
|
||||
ConfigLayerSource::Mdm { .. }
|
||||
| ConfigLayerSource::AppServerHost
|
||||
| ConfigLayerSource::SessionFlags
|
||||
| ConfigLayerSource::LegacyManagedConfigTomlFromFile { .. }
|
||||
| ConfigLayerSource::LegacyManagedConfigTomlFromMdm => {}
|
||||
|
||||
@@ -1066,6 +1066,7 @@ pub struct ConfigBuilder {
|
||||
harness_overrides: Option<ConfigOverrides>,
|
||||
loader_overrides: Option<LoaderOverrides>,
|
||||
strict_config: bool,
|
||||
app_server_host_config: Option<TomlValue>,
|
||||
cloud_requirements: CloudRequirementsLoader,
|
||||
thread_config_loader: Option<Arc<dyn ThreadConfigLoader>>,
|
||||
fallback_cwd: Option<PathBuf>,
|
||||
@@ -1097,6 +1098,11 @@ impl ConfigBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn app_server_host_config(mut self, app_server_host_config: Option<TomlValue>) -> Self {
|
||||
self.app_server_host_config = app_server_host_config;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn cloud_requirements(mut self, cloud_requirements: CloudRequirementsLoader) -> Self {
|
||||
self.cloud_requirements = cloud_requirements;
|
||||
self
|
||||
@@ -1127,6 +1133,7 @@ impl ConfigBuilder {
|
||||
harness_overrides,
|
||||
loader_overrides,
|
||||
strict_config,
|
||||
app_server_host_config,
|
||||
cloud_requirements,
|
||||
thread_config_loader,
|
||||
fallback_cwd,
|
||||
@@ -1152,6 +1159,7 @@ impl ConfigBuilder {
|
||||
ConfigLoadOptions {
|
||||
loader_overrides,
|
||||
strict_config,
|
||||
app_server_host_config,
|
||||
},
|
||||
cloud_requirements,
|
||||
thread_config_loader
|
||||
|
||||
@@ -268,6 +268,7 @@ fn is_user_controlled_layer(layer: &ConfigLayerSource) -> bool {
|
||||
matches!(
|
||||
layer,
|
||||
ConfigLayerSource::User { .. }
|
||||
| ConfigLayerSource::AppServerHost
|
||||
| ConfigLayerSource::Project { .. }
|
||||
| ConfigLayerSource::SessionFlags
|
||||
)
|
||||
|
||||
@@ -337,6 +337,7 @@ pub async fn run_main(cli: Cli, arg0_paths: Arg0DispatchPaths) -> anyhow::Result
|
||||
ConfigLoadOptions {
|
||||
loader_overrides: loader_overrides.clone(),
|
||||
strict_config,
|
||||
app_server_host_config: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -9,10 +9,9 @@ use codex_config::TomlValue;
|
||||
/// Build effective hook state from config layers that are allowed to override
|
||||
/// user preferences.
|
||||
///
|
||||
/// This intentionally reads only user and session flag layers, including
|
||||
/// disabled layers, to match the skills config behavior. Project, managed, and
|
||||
/// plugin layers can discover hooks, but they do not get to write user hook
|
||||
/// state.
|
||||
/// This intentionally reads only user-controlled layers, including disabled
|
||||
/// layers, to match the skills config behavior. Project, managed, and plugin
|
||||
/// layers can discover hooks, but they do not get to write user hook state.
|
||||
pub fn hook_states_from_stack(
|
||||
config_layer_stack: Option<&ConfigLayerStack>,
|
||||
) -> HashMap<String, HookStateToml> {
|
||||
@@ -27,7 +26,9 @@ pub fn hook_states_from_stack(
|
||||
) {
|
||||
if !matches!(
|
||||
layer.name,
|
||||
ConfigLayerSource::User { .. } | ConfigLayerSource::SessionFlags
|
||||
ConfigLayerSource::User { .. }
|
||||
| ConfigLayerSource::AppServerHost
|
||||
| ConfigLayerSource::SessionFlags
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -364,6 +364,7 @@ fn config_toml_source_path(layer: &ConfigLayerEntry) -> AbsolutePathBuf {
|
||||
ConfigLayerSource::LegacyManagedConfigTomlFromMdm => {
|
||||
synthetic_layer_path("<legacy-managed-config.toml-mdm>/managed_config.toml")
|
||||
}
|
||||
ConfigLayerSource::AppServerHost => synthetic_layer_path("<app-server-host>/config.toml"),
|
||||
ConfigLayerSource::SessionFlags => synthetic_layer_path("<session-flags>/config.toml"),
|
||||
}
|
||||
}
|
||||
@@ -584,6 +585,7 @@ fn hook_metadata_for_config_layer_source(source: &ConfigLayerSource) -> (HookSou
|
||||
match source {
|
||||
ConfigLayerSource::System { .. } => (HookSource::System, true),
|
||||
ConfigLayerSource::User { .. } => (HookSource::User, false),
|
||||
ConfigLayerSource::AppServerHost => (HookSource::User, false),
|
||||
ConfigLayerSource::Project { .. } => (HookSource::Project, false),
|
||||
ConfigLayerSource::Mdm { .. } => (HookSource::Mdm, true),
|
||||
ConfigLayerSource::SessionFlags => (HookSource::SessionFlags, false),
|
||||
|
||||
@@ -255,7 +255,9 @@ fn render_debug_config_lines(stack: &ConfigLayerStack) -> Vec<Line<'static>> {
|
||||
|
||||
fn render_non_file_layer_details(layer: &ConfigLayerEntry) -> Vec<Line<'static>> {
|
||||
match &layer.name {
|
||||
ConfigLayerSource::SessionFlags => render_session_flag_details(&layer.config),
|
||||
ConfigLayerSource::AppServerHost | ConfigLayerSource::SessionFlags => {
|
||||
render_session_flag_details(&layer.config)
|
||||
}
|
||||
ConfigLayerSource::Mdm { .. } | ConfigLayerSource::LegacyManagedConfigTomlFromMdm => {
|
||||
render_mdm_layer_details(layer)
|
||||
}
|
||||
@@ -388,6 +390,7 @@ fn format_config_layer_source(source: &ConfigLayerSource) -> String {
|
||||
ConfigLayerSource::User { file, .. } => {
|
||||
format!("user ({})", file.as_path().display())
|
||||
}
|
||||
ConfigLayerSource::AppServerHost => "app-server-host".to_string(),
|
||||
ConfigLayerSource::Project { dot_codex_folder } => {
|
||||
format!(
|
||||
"project ({}/config.toml)",
|
||||
|
||||
@@ -958,6 +958,7 @@ pub async fn run_main(
|
||||
codex_config::ConfigLoadOptions {
|
||||
loader_overrides: loader_overrides.clone(),
|
||||
strict_config,
|
||||
app_server_host_config: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user