-
Notifications
You must be signed in to change notification settings - Fork 0
Codex/shared python sdk runtime #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -884,13 +884,32 @@ fn host_process_exec( | |||||||||||||
| ) -> Result<(), Error> { | ||||||||||||||
| let ctx = user_data.get().map_err(|e| Error::msg(format!("{e}")))?; | ||||||||||||||
| let ctx = ctx.lock().map_err(|e| Error::msg(format!("{e}")))?; | ||||||||||||||
| require_declared_capability(&ctx, "process:exec")?; | ||||||||||||||
| if let Err(err) = require_declared_capability(&ctx, "process:exec") { | ||||||||||||||
|
||||||||||||||
| if let Err(err) = require_declared_capability(&ctx, "process:exec") { | |
| if let Err(err) = require_capability(&ctx, "process:exec") { |
Copilot
AI
Apr 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spawn error string includes resolved_program and resolved_cwd (often absolute paths under the user’s home directory). If this message is surfaced in plugin UIs/logs, it can leak local filesystem paths. Consider redacting/sanitizing these values or limiting detail.
| "stderr": format!( | |
| "Process spawn failed: program='{}' cwd='{}' ({e})", | |
| resolved_program.display(), | |
| resolved_cwd.display() | |
| ), | |
| "stderr": format!("Process spawn failed ({e})"), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [package] | ||
| name = "peekoo-python-sdk" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
| license = "MIT" | ||
|
|
||
| [lib] | ||
| path = "src/lib.rs" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REQ_FILE="${1:-}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OUT_FILE="${2:-}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$REQ_FILE" || -z "$OUT_FILE" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "usage: $0 <requirements.txt> <output.tar.gz>" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ ! -f "$REQ_FILE" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "requirements file not found: $REQ_FILE" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| platform="$(uname -s | tr '[:upper:]' '[:lower:]')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| arch="$(uname -m)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "$platform:$arch" in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| darwin:arm64) target_triple="aarch64-apple-darwin" ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| darwin:x86_64) target_triple="x86_64-apple-darwin" ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| linux:x86_64) target_triple="x86_64-unknown-linux-gnu" ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| linux:aarch64) target_triple="aarch64-unknown-linux-gnu" ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "unsupported platform: $platform/$arch" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| release_tag="${PEEKOO_PYTHON_STANDALONE_TAG:-20250317}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archive_url="${PEEKOO_PYTHON_STANDALONE_URL:-https://github.com/indygreg/python-build-standalone/releases/download/${release_tag}/cpython-3.12.9+${release_tag}-${target_triple}-install_only.tar.gz}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workdir="$(mktemp -d)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap 'rm -rf "$workdir"' EXIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archive_path="$workdir/python-runtime.tar.gz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -fL "$archive_url" -o "$archive_path" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+37
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archive_url="${PEEKOO_PYTHON_STANDALONE_URL:-https://github.com/indygreg/python-build-standalone/releases/download/${release_tag}/cpython-3.12.9+${release_tag}-${target_triple}-install_only.tar.gz}" | |
| workdir="$(mktemp -d)" | |
| trap 'rm -rf "$workdir"' EXIT | |
| archive_path="$workdir/python-runtime.tar.gz" | |
| curl -fL "$archive_url" -o "$archive_path" | |
| archive_url="${PEEKOO_PYTHON_STANDALONE_URL:-https://github.com/indygreg/python-build-standalone/releases/download/${release_tag}/cpython-3.12.9+${release_tag}-${target_triple}-install_only.tar.gz}" | |
| archive_sha256="${PEEKOO_PYTHON_STANDALONE_SHA256:-}" | |
| if [[ -z "$archive_sha256" ]]; then | |
| echo "missing required SHA256 for runtime archive: set PEEKOO_PYTHON_STANDALONE_SHA256" >&2 | |
| exit 1 | |
| fi | |
| workdir="$(mktemp -d)" | |
| trap 'rm -rf "$workdir"' EXIT | |
| archive_path="$workdir/python-runtime.tar.gz" | |
| curl -fL "$archive_url" -o "$archive_path" | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| actual_sha256="$(sha256sum "$archive_path" | awk '{print $1}')" | |
| elif command -v shasum >/dev/null 2>&1; then | |
| actual_sha256="$(shasum -a 256 "$archive_path" | awk '{print $1}')" | |
| else | |
| echo "no SHA-256 tool available; install sha256sum or shasum" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$actual_sha256" != "$archive_sha256" ]]; then | |
| echo "downloaded runtime archive SHA256 mismatch" >&2 | |
| echo "expected: $archive_sha256" >&2 | |
| echo "actual: $actual_sha256" >&2 | |
| exit 1 | |
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| PACKAGE_FILE="${1:-}" | ||
| TARGET_DIR="${2:-$HOME/.peekoo/python-sdk}" | ||
|
|
||
| if [[ -z "$PACKAGE_FILE" ]]; then | ||
| echo "usage: $0 <runtime-package.tar.gz> [target-dir]" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "$PACKAGE_FILE" ]]; then | ||
| echo "package file not found: $PACKAGE_FILE" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p "$TARGET_DIR" | ||
| rm -rf "$TARGET_DIR/python" | ||
| tar -xzf "$PACKAGE_FILE" -C "$TARGET_DIR" | ||
|
|
||
| echo "Python runtime installed to: $TARGET_DIR/python" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| pub const SHARED_PYTHON_SDK_ROOT: &str = "~/.peekoo/python-sdk"; | ||
|
|
||
| pub fn shared_python_candidates() -> Vec<String> { | ||
| vec![ | ||
| format!("{SHARED_PYTHON_SDK_ROOT}/python/bin/python3"), | ||
| format!("{SHARED_PYTHON_SDK_ROOT}/python/bin/python"), | ||
| format!("{SHARED_PYTHON_SDK_ROOT}/python/python.exe"), | ||
| format!("{SHARED_PYTHON_SDK_ROOT}/python/bin/python.exe"), | ||
| ] | ||
| } | ||
|
|
||
| pub fn plugin_local_python_candidates() -> Vec<String> { | ||
| vec![ | ||
| "runtime/python/bin/python3".to_string(), | ||
| "runtime/python/bin/python".to_string(), | ||
| "runtime/python/python.exe".to_string(), | ||
| "runtime/python/bin/python.exe".to_string(), | ||
| ] | ||
| } | ||
|
|
||
| pub fn system_python_candidates() -> Vec<String> { | ||
| vec![ | ||
| "python3".to_string(), | ||
| "python".to_string(), | ||
| "py".to_string(), | ||
| ] | ||
| } | ||
|
|
||
| pub fn all_python_candidates() -> Vec<String> { | ||
| let mut out = Vec::new(); | ||
| out.extend(shared_python_candidates()); | ||
| out.extend(plugin_local_python_candidates()); | ||
| out.extend(system_python_candidates()); | ||
| out | ||
| } | ||
|
|
||
| pub fn is_spawn_error_message(message: &str) -> bool { | ||
| message.contains("Process spawn failed") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These PostHog permission constants appear unrelated to the shared Python SDK runtime changes described in the PR. If this schema update is accidental or unrelated, consider reverting or splitting it into a separate PR to keep scope focused.