diff --git a/.gitignore b/.gitignore
index 979cea4..adc0435 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,4 +66,6 @@ dist
toolchain/chidori-old/package_python/chidori/_chidori.abi3.so
-.pre-commit-config.yaml
\ No newline at end of file
+.pre-commit-config.yaml
+
+.env
\ No newline at end of file
diff --git a/deployment/README.md b/deployment/README.md
new file mode 100644
index 0000000..e5e8d63
--- /dev/null
+++ b/deployment/README.md
@@ -0,0 +1 @@
+# Deployment Examples
\ No newline at end of file
diff --git a/deployment/docker-single-container/Dockerfile b/deployment/docker-single-container/Dockerfile
new file mode 100644
index 0000000..4bac963
--- /dev/null
+++ b/deployment/docker-single-container/Dockerfile
@@ -0,0 +1,35 @@
+# Initalling chidori
+FROM ghcr.io/rust-lang/rust:nightly-bookworm
+
+RUN apt update
+RUN apt install -y cmake curl
+RUN apt install -y python3-dev
+
+RUN curl -LsSf https://astral.sh/uv/install.sh | sh
+RUN cargo +nightly install chidori-core --locked
+RUN uv venv
+RUN uv pip install "litellm[proxy]"
+
+WORKDIR /usr/src
+RUN mkdir logs
+COPY example_agent ./example_agent
+COPY init.sh ./init.sh
+COPY litellm_config.yaml litellm_config.yaml
+RUN chmod +x ./init.sh
+
+ENV OPENAI_API_KEY=OPENAI_API_KEY
+ENV ANTHROPIC_API_KEY=ANTHROPIC_API_KEY
+EXPOSE 8000
+
+CMD ["./init.sh"]
+
+
+
+# Bundle Stage
+#FROM scratch
+#COPY --from=builder /usr/local/cargo/bin/chidori-core .
+#COPY agent ./example_agent
+#COPY init.sh ./init.sh
+#RUN ["./init.sh"]
+#USER 1000
+#CMD ["./deciduously-com", "-a", "0.0.0.0", "-p", "8080"]
\ No newline at end of file
diff --git a/deployment/docker-single-container/example_agent/example.md b/deployment/docker-single-container/example_agent/example.md
new file mode 100644
index 0000000..6312130
--- /dev/null
+++ b/deployment/docker-single-container/example_agent/example.md
@@ -0,0 +1,48 @@
+# Demonstrating running a hono web service to produce a user facing interface
+
+
+```python
+def testingFunC(x):
+ return x + "Hello"
+```
+
+```javascript
+import { Hono } from 'https://deno.land/x/hono/mod.ts';
+import { serve } from 'https://deno.land/std@0.145.0/http/server.ts';
+
+const app = new Hono();
+
+app.get('/', (c) => {
+ const form = `
+
Welcome to Trip Planner Crew
+
+ `;
+ return c.html(form);
+});
+
+app.post('/submit', async (c) => {
+ const body = await c.req.parseBody();
+ const { origin, cities, date_range, interests } = body;
+ const xx = await testingFunC(origin);
+ const response = `
+ Trip Details
+ Origin: ${xx}
+ Cities: ${cities}
+ Date Range: ${date_range}
+ Interests: ${interests}
+ `;
+ return c.html(response);
+});
+
+serve(app.fetch);
+```
\ No newline at end of file
diff --git a/deployment/docker-single-container/init.sh b/deployment/docker-single-container/init.sh
new file mode 100644
index 0000000..71a72d8
--- /dev/null
+++ b/deployment/docker-single-container/init.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Create log files for LiteLLM
+mkdir -p logs
+
+# Start LiteLLM and redirect both stdout and stderr to log files
+uv run litellm --config ./litellm_config.yaml 2>&1 &
+LITELLM_PID=$!
+
+# Start Chidori and stream its output to console while still maintaining the background process
+chidori-core run --load ./example_agent 2>&1 &
+CHIDORI_PID=$!
+
+# Optional: Print PIDs for debugging
+echo "LiteLLM PID: $LITELLM_PID"
+echo "Chidori PID: $CHIDORI_PID"
+
+# Wait for any process to exit
+wait -n
+
+# Capture the exit status
+EXIT_STATUS=$?
+
+# Optional: Print which process exited
+if ! kill -0 $LITELLM_PID 2>/dev/null; then
+ echo "LiteLLM process exited first with status $EXIT_STATUS"
+elif ! kill -0 $CHIDORI_PID 2>/dev/null; then
+ echo "Chidori process exited first with status $EXIT_STATUS"
+fi
+
+# Clean up any remaining processes
+kill $LITELLM_PID $CHIDORI_PID 2>/dev/null
+
+# Exit with status of process that exited first
+exit $EXIT_STATUS
\ No newline at end of file
diff --git a/deployment/docker-single-container/litellm_config.yaml b/deployment/docker-single-container/litellm_config.yaml
new file mode 100644
index 0000000..f07e37d
--- /dev/null
+++ b/deployment/docker-single-container/litellm_config.yaml
@@ -0,0 +1,38 @@
+model_list:
+ - model_name: o1-preview
+ litellm_params:
+ model: openai/o1-preview
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: o1-mini
+ litellm_params:
+ model: openai/o1-mini
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: gpt-4o
+ litellm_params:
+ model: openai/gpt-4o
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: gpt-4o-mini
+ litellm_params:
+ model: openai/gpt-4o-mini
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: gpt-4-turbo
+ litellm_params:
+ model: openai/gpt-4-turbo
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: gpt-3.5-turbo
+ litellm_params:
+ model: openai/gpt-3.5-turbo
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: gpt-3.5-turbo-instruct
+ litellm_params:
+ model: text-completion-openai/gpt-3.5-turbo-instruct
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: text-embedding-3-small
+ litellm_params:
+ model: openai/text-embedding-3-small
+ api_key: os.environ/OPENAI_API_KEY
+ - model_name: claude-3.5
+ litellm_params:
+ model: anthropic/claude-3-5-sonnet-20240620
+ api_key: os.environ/ANTHROPIC_API_KEY
+
diff --git a/toolchain/Cargo.lock b/toolchain/Cargo.lock
index e722864..04f7639 100644
--- a/toolchain/Cargo.lock
+++ b/toolchain/Cargo.lock
@@ -2648,7 +2648,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "chidori-core"
-version = "0.2.7"
+version = "0.2.8"
dependencies = [
"anyhow",
"ariadne",
@@ -2726,7 +2726,7 @@ dependencies = [
[[package]]
name = "chidori-debugger"
-version = "0.2.7"
+version = "0.2.8"
dependencies = [
"anyhow",
"arboard",
diff --git a/toolchain/Cargo.toml b/toolchain/Cargo.toml
index 59cdc01..6ba3e0a 100644
--- a/toolchain/Cargo.toml
+++ b/toolchain/Cargo.toml
@@ -8,7 +8,7 @@ members = [
resolver = "2"
[workspace.package]
-version = "0.2.8"
+version = "0.2.9"
authors = ["Colton Pierson "]
edition = "2021"
license = "MIT"
diff --git a/toolchain/chidori-core/src/main.rs b/toolchain/chidori-core/src/main.rs
index 36156ee..fc0996c 100644
--- a/toolchain/chidori-core/src/main.rs
+++ b/toolchain/chidori-core/src/main.rs
@@ -16,6 +16,7 @@ mod utils;
pub use tokio;
pub use uuid;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
pub use chidori_static_analysis;
pub use chidori_prompt_format;
@@ -71,7 +72,7 @@ async fn run_command(run_directory: &PathBuf) -> anyhow::Result<()> {
let mut instance = chidori.get_instance().unwrap();
let _await_ready = instance.wait_until_ready().await;
chidori.load_md_directory(&run_directory_clone).unwrap();
- let result = instance.run().await;
+ let result = instance.run(PlaybackState::Running).await;
match result {
Ok(_) => {
println!("Instance completed execution and closed successfully.");
diff --git a/toolchain/chidori-core/src/sdk/chidori.rs b/toolchain/chidori-core/src/sdk/chidori.rs
index 8d244e2..28d496b 100644
--- a/toolchain/chidori-core/src/sdk/chidori.rs
+++ b/toolchain/chidori-core/src/sdk/chidori.rs
@@ -88,7 +88,7 @@ impl Chidori {
}
#[tracing::instrument]
- pub fn handle_user_action(&self, action: UserInteractionMessage) -> anyhow::Result<()> {
+ pub fn dispatch_user_interaction_to_instance(&self, action: UserInteractionMessage) -> anyhow::Result<()> {
if let Some(tx) = &self.instanced_env_tx {
tx.send(action)?;
}
@@ -135,7 +135,7 @@ impl Chidori {
}
self.shared_state.lock().unwrap().editor_cells = new_cells_state;
println!("Cells commit to shared state");
- self.handle_user_action(UserInteractionMessage::ReloadCells)?;
+ self.dispatch_user_interaction_to_instance(UserInteractionMessage::ReloadCells)?;
Ok(())
}
@@ -162,6 +162,7 @@ impl Chidori {
}
self.loaded_path = Some(path.to_str().unwrap().to_string());
cells.sort();
+ println!("Loading {} cells from {:?}", cells.len(), path);
self.load_cells(cells)
}
diff --git a/toolchain/chidori-core/src/sdk/instanced_environment.rs b/toolchain/chidori-core/src/sdk/instanced_environment.rs
index 7c1d33e..f593032 100644
--- a/toolchain/chidori-core/src/sdk/instanced_environment.rs
+++ b/toolchain/chidori-core/src/sdk/instanced_environment.rs
@@ -57,7 +57,7 @@ impl InstancedEnvironment {
// TODO: reload_cells needs to diff the mutations that live on the current branch, with the state
// that we see in the shared state when this event is fired.
- pub(crate) fn reload_cells(&mut self) -> anyhow::Result<()> {
+ pub fn reload_cells(&mut self) -> anyhow::Result<()> {
println!("Reloading cells");
let cells_to_upsert: Vec<_> = {
let shared_state = self.shared_state.lock().unwrap();
@@ -108,9 +108,9 @@ impl InstancedEnvironment {
/// Entrypoint for execution of an instanced environment, handles messages from the host
// #[tracing::instrument]
- pub async fn run(&mut self) -> anyhow::Result<()> {
+ pub async fn run(&mut self, initial_playback_state: PlaybackState) -> anyhow::Result<()> {
println!("Starting instanced environment");
- self.set_playback_state(PlaybackState::Paused);
+ self.set_playback_state(initial_playback_state);
// Reload cells to make sure we're up-to-date
self.reload_cells()?;
diff --git a/toolchain/chidori-debugger/examples/core10_concurrency/main.rs b/toolchain/chidori-debugger/examples/core10_concurrency/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core10_concurrency/main.rs
+++ b/toolchain/chidori-debugger/examples/core10_concurrency/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core11_hono/main.rs b/toolchain/chidori-debugger/examples/core11_hono/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core11_hono/main.rs
+++ b/toolchain/chidori-debugger/examples/core11_hono/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core12_dependency_management/main.rs b/toolchain/chidori-debugger/examples/core12_dependency_management/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core12_dependency_management/main.rs
+++ b/toolchain/chidori-debugger/examples/core12_dependency_management/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core13_state_machine/main.rs b/toolchain/chidori-debugger/examples/core13_state_machine/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core13_state_machine/main.rs
+++ b/toolchain/chidori-debugger/examples/core13_state_machine/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core1_simple_math/main.rs b/toolchain/chidori-debugger/examples/core1_simple_math/main.rs
index 64a272a..863ba4d 100644
--- a/toolchain/chidori-debugger/examples/core1_simple_math/main.rs
+++ b/toolchain/chidori-debugger/examples/core1_simple_math/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -7,5 +9,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core2_marshalling/main.rs b/toolchain/chidori-debugger/examples/core2_marshalling/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core2_marshalling/main.rs
+++ b/toolchain/chidori-debugger/examples/core2_marshalling/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core3_function_invocations/main.rs b/toolchain/chidori-debugger/examples/core3_function_invocations/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core3_function_invocations/main.rs
+++ b/toolchain/chidori-debugger/examples/core3_function_invocations/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core4_async_function_invocations/main.rs b/toolchain/chidori-debugger/examples/core4_async_function_invocations/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core4_async_function_invocations/main.rs
+++ b/toolchain/chidori-debugger/examples/core4_async_function_invocations/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core5_prompts_invoked_as_functions/main.rs b/toolchain/chidori-debugger/examples/core5_prompts_invoked_as_functions/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core5_prompts_invoked_as_functions/main.rs
+++ b/toolchain/chidori-debugger/examples/core5_prompts_invoked_as_functions/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core6_prompts_leveraging_function_calling/main.rs b/toolchain/chidori-debugger/examples/core6_prompts_leveraging_function_calling/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core6_prompts_leveraging_function_calling/main.rs
+++ b/toolchain/chidori-debugger/examples/core6_prompts_leveraging_function_calling/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core7_rag_stateful_memory_cells/main.rs b/toolchain/chidori-debugger/examples/core7_rag_stateful_memory_cells/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core7_rag_stateful_memory_cells/main.rs
+++ b/toolchain/chidori-debugger/examples/core7_rag_stateful_memory_cells/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core8_prompt_code_generation_and_execution/main.rs b/toolchain/chidori-debugger/examples/core8_prompt_code_generation_and_execution/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core8_prompt_code_generation_and_execution/main.rs
+++ b/toolchain/chidori-debugger/examples/core8_prompt_code_generation_and_execution/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/core9_multi_agent_simulation/main.rs b/toolchain/chidori-debugger/examples/core9_multi_agent_simulation/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/core9_multi_agent_simulation/main.rs
+++ b/toolchain/chidori-debugger/examples/core9_multi_agent_simulation/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo10_cpt_codes/main.rs b/toolchain/chidori-debugger/examples/demo10_cpt_codes/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo10_cpt_codes/main.rs
+++ b/toolchain/chidori-debugger/examples/demo10_cpt_codes/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo1_business_analyst/main.rs b/toolchain/chidori-debugger/examples/demo1_business_analyst/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo1_business_analyst/main.rs
+++ b/toolchain/chidori-debugger/examples/demo1_business_analyst/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo2_gpt_migrate/main.rs b/toolchain/chidori-debugger/examples/demo2_gpt_migrate/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo2_gpt_migrate/main.rs
+++ b/toolchain/chidori-debugger/examples/demo2_gpt_migrate/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo3_self_healing_scaper/main.rs b/toolchain/chidori-debugger/examples/demo3_self_healing_scaper/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo3_self_healing_scaper/main.rs
+++ b/toolchain/chidori-debugger/examples/demo3_self_healing_scaper/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo4_story_generator/main.rs b/toolchain/chidori-debugger/examples/demo4_story_generator/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo4_story_generator/main.rs
+++ b/toolchain/chidori-debugger/examples/demo4_story_generator/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo5_todomvc/main.rs b/toolchain/chidori-debugger/examples/demo5_todomvc/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo5_todomvc/main.rs
+++ b/toolchain/chidori-debugger/examples/demo5_todomvc/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo6_code_docs_updater/main.rs b/toolchain/chidori-debugger/examples/demo6_code_docs_updater/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo6_code_docs_updater/main.rs
+++ b/toolchain/chidori-debugger/examples/demo6_code_docs_updater/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo6_open_devin/main.rs b/toolchain/chidori-debugger/examples/demo6_open_devin/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo6_open_devin/main.rs
+++ b/toolchain/chidori-debugger/examples/demo6_open_devin/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo7_comfyui/main.rs b/toolchain/chidori-debugger/examples/demo7_comfyui/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo7_comfyui/main.rs
+++ b/toolchain/chidori-debugger/examples/demo7_comfyui/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo8_hacker_news_scraper/main.rs b/toolchain/chidori-debugger/examples/demo8_hacker_news_scraper/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo8_hacker_news_scraper/main.rs
+++ b/toolchain/chidori-debugger/examples/demo8_hacker_news_scraper/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/demo9_arc_agi/main.rs b/toolchain/chidori-debugger/examples/demo9_arc_agi/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/demo9_arc_agi/main.rs
+++ b/toolchain/chidori-debugger/examples/demo9_arc_agi/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/examples/experiment1_explicit_imports/main.rs b/toolchain/chidori-debugger/examples/experiment1_explicit_imports/main.rs
index b173807..d257775 100644
--- a/toolchain/chidori-debugger/examples/experiment1_explicit_imports/main.rs
+++ b/toolchain/chidori-debugger/examples/experiment1_explicit_imports/main.rs
@@ -1,5 +1,7 @@
use std::path::Path;
use chidori_core::sdk::chidori::Chidori;
+use chidori_core::sdk::entry::PlaybackState;
+
fn main() {
let current_file = env!("CARGO_MANIFEST_DIR");
let current_file_path = Path::new(current_file);
@@ -8,5 +10,5 @@ fn main() {
let mut env = Chidori::new();
env.load_md_directory(&relative_path);
let mut s = env.get_instance().unwrap();
- s.run();
+ s.run(PlaybackState::Paused);
}
\ No newline at end of file
diff --git a/toolchain/chidori-debugger/src/chidori.rs b/toolchain/chidori-debugger/src/chidori.rs
index 0d3c317..a19cad9 100644
--- a/toolchain/chidori-debugger/src/chidori.rs
+++ b/toolchain/chidori-debugger/src/chidori.rs
@@ -338,21 +338,21 @@ impl ChidoriState {
pub fn step(&self) -> anyhow::Result<(), String> {
let env = self.chidori.lock().unwrap();
- env.handle_user_action(UserInteractionMessage::Step)
+ env.dispatch_user_interaction_to_instance(UserInteractionMessage::Step)
.map_err(|e| e.to_string())?;
Ok(())
}
pub fn play(&self) -> anyhow::Result<(), String> {
let env = self.chidori.lock().unwrap();
- env.handle_user_action(UserInteractionMessage::Play)
+ env.dispatch_user_interaction_to_instance(UserInteractionMessage::Play)
.map_err(|e| e.to_string())?;
Ok(())
}
pub fn pause(&self) -> anyhow::Result<(), String> {
let env = self.chidori.lock().unwrap();
- env.handle_user_action(UserInteractionMessage::Pause)
+ env.dispatch_user_interaction_to_instance(UserInteractionMessage::Pause)
.map_err(|e| e.to_string())?;
Ok(())
}
@@ -364,7 +364,7 @@ impl ChidoriState {
{
let chidori_guard = chidori.lock().expect("Failed to lock chidori");
println!("=== handle user action Revert");
- chidori_guard.handle_user_action(UserInteractionMessage::RevertToState(Some(id)))
+ chidori_guard.dispatch_user_interaction_to_instance(UserInteractionMessage::RevertToState(Some(id)))
.map_err(|e| e.to_string())?;
}
@@ -376,7 +376,7 @@ impl ChidoriState {
let chidori = self.chidori.clone();
{
let chidori_guard = chidori.lock().expect("Failed to lock chidori");
- chidori_guard.handle_user_action(UserInteractionMessage::MutateCell(cell_holder))
+ chidori_guard.dispatch_user_interaction_to_instance(UserInteractionMessage::MutateCell(cell_holder))
.map_err(|e| e.to_string())?;
}
Ok(())
@@ -482,7 +482,7 @@ fn setup(mut commands: Commands, runtime: ResMut
};
let _ = instance.wait_until_ready().await;
- let result = instance.run().await;
+ let result = instance.run(PlaybackState::Paused).await;
match result {
Ok(_) => {
panic!("Instance completed execution and closed successfully.");
diff --git a/toolchain/chidori-debugger/src/graph.rs b/toolchain/chidori-debugger/src/graph.rs
index 4bd8417..df495c0 100644
--- a/toolchain/chidori-debugger/src/graph.rs
+++ b/toolchain/chidori-debugger/src/graph.rs
@@ -16,7 +16,7 @@ use bevy::render::view::{NoFrustumCulling, RenderLayers};
use bevy::tasks::futures_lite::StreamExt;
use bevy::utils::petgraph::stable_graph::GraphIndex;
use bevy::window::{PrimaryWindow, WindowResized};
-use egui::{Color32, Order, Pos2, Rgba, RichText, Stroke, TextureHandle, Ui};
+use egui::{Color32, Frame, Margin, Order, Pos2, Rgba, RichText, Stroke, TextureHandle, Ui};
use crate::bevy_egui::{EguiContext, EguiContexts, EguiManagedTextures, EguiRenderOutput, EguiRenderTarget};
use egui;
use bevy_rapier2d::geometry::Collider;
@@ -42,7 +42,7 @@ use dashmap::DashMap;
use egui_extras::syntax_highlighting::CodeTheme;
use egui_json_tree::JsonTree;
use egui_tiles::Tile;
-use image::{ImageBuffer, RgbaImage};
+use image::{DynamicImage, ImageBuffer, RgbImage, RgbaImage};
use chidori_core::execution::execution::execution_state::{ExecutionStateErrors, ExecutionStateEvaluation};
use uuid::Uuid;
use chidori_core::execution::primitives::serialized_value::RkyvSerializedValue;
@@ -1384,12 +1384,18 @@ fn graph_setup(
alpha_mode: AlphaMode::Blend,
});
+ // Main camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(0.0, 0.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
camera: Camera {
order: 1,
clear_color: ClearColorConfig::Custom(Color::rgba(0.035, 0.035, 0.043, 1.0)),
+ // viewport: Some(Viewport {
+ // physical_position: UVec2::new((300.0 * scale_factor) as u32, 0),
+ // physical_size: UVec2::new(window.physical_width() - 300 * (scale_factor as u32), window.physical_height()),
+ // ..default()
+ // }),
..default()
},
projection: OrthographicProjection {
@@ -1500,6 +1506,73 @@ fn graph_setup(
});
}
+fn ui_window(
+ mut contexts: EguiContexts,
+ tree_identities: Res,
+ q_window: Query<&Window, With>,
+ mut chidori_state: ResMut,
+ current_theme: Res,
+ mut tree: ResMut,
+) {
+ let window = q_window.single();
+ let mut hide_all = false;
+
+ let mut container_frame = Frame::default()
+ .fill(current_theme.theme.accent)
+ .outer_margin(Margin {
+ left: 0.0,
+ right: 0.0,
+ top: 0.0,
+ bottom: 0.0,
+ })
+ .inner_margin(16.0);
+ if let Some(graph_title) = tree_identities.graph_tile {
+ if let Some(tile) = tree.tree.tiles.get(graph_title) {
+ match tile {
+ Tile::Pane(p) => {
+ if !tree.tree.active_tiles().contains(&graph_title) {
+ hide_all = true;
+ } else {
+ if let Some(r) = p.rect {
+ container_frame = container_frame.outer_margin(Margin {
+ left: r.min.x,
+ right: (window.width() - 300.0),
+ top: r.min.y,
+ bottom: window.height() - r.max.y,
+ });
+ }
+ }
+ }
+ Tile::Container(_) => {}
+ }
+ }
+ }
+
+ if hide_all || chidori_state.display_example_modal {
+ return;
+ }
+
+ egui::CentralPanel::default().frame(container_frame).show(contexts.ctx_mut(), |ui| {
+ ui.add_space(22.0);
+ ui.horizontal(|ui| {
+ ui.add_space(22.0);
+ ui.vertical(|ui| {
+ ui.label("Sidebar");
+ ui.button("Collapse Alternate Branches");
+ });
+ });
+
+ });
+ // egui::SidePanel::left("Explorer")
+ // .frame(container_frame)
+ // .min_width(300.0)
+ // .max_width(300.0)
+ // .resizable(false)
+ // .show_separator_line(false)
+ // .show(contexts.ctx_mut(), |ui| {
+ // });
+}
+
#[derive(Component)]
struct OnGraphScreen;
@@ -1534,7 +1607,8 @@ pub fn graph_plugin(app: &mut App) {
mouse_over_system,
enforce_tiled_viewports,
update_cursor_materials,
- update_node_materials
+ update_node_materials,
+ ui_window
)
.run_if(in_state(GameState::Graph)),
);