mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
fix(code-mode): wire store/load config through core
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
use serde::Serialize;
|
||||
|
||||
/// Configuration for one durable code-mode session.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
|
||||
pub struct CodeModeSessionConfig {
|
||||
/// Controls whether cells can persist JSON values for later cells.
|
||||
pub store_load: StoreLoadMode,
|
||||
}
|
||||
|
||||
/// Controls whether the `store` and `load` globals are available in a session.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
|
||||
pub enum StoreLoadMode {
|
||||
/// Expose `store` and `load` and retain their JSON values between cells.
|
||||
#[default]
|
||||
|
||||
@@ -285,12 +285,16 @@ fn run_runtime(
|
||||
v8::scope!(let scope, isolate);
|
||||
let context = v8::Context::new(scope, Default::default());
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
let stored_value_writes = match &config.stored_values {
|
||||
StoredValues::Enabled(_) => StoredValues::Enabled(HashMap::new()),
|
||||
StoredValues::Disabled => StoredValues::Disabled,
|
||||
};
|
||||
|
||||
scope.set_slot(RuntimeState {
|
||||
event_tx: event_tx.clone(),
|
||||
pending_tool_calls: HashMap::new(),
|
||||
pending_timeouts: HashMap::new(),
|
||||
stored_value_writes: config.stored_values.empty_like(),
|
||||
stored_value_writes,
|
||||
stored_values: config.stored_values,
|
||||
enabled_tools: config.enabled_tools,
|
||||
next_tool_call_id: 1,
|
||||
|
||||
@@ -19,13 +19,6 @@ impl StoredValues {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn empty_like(&self) -> Self {
|
||||
match self {
|
||||
Self::Enabled(_) => Self::Enabled(HashMap::new()),
|
||||
Self::Disabled => Self::Disabled,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_enabled(&self) -> bool {
|
||||
matches!(self, Self::Enabled(_))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user