Repository navigation
Add native Grok Vault resume support #4398
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5708d67
Add native Grok Vault resume support
austinywang 4ab85ff
Tighten Grok Vault session resolution
austinywang 7c252d2
Harden Grok resume option parsing
austinywang a21a21c
Deduplicate shell wrapper installer
austinywang bbd65fd
Parse registered Grok transcripts by layout
austinywang 9507565
Quote built-in Grok Vault resume commands
austinywang d7f0bb5
Carry Grok home through registered Vault resumes
austinywang fa66e00
Broaden Grok transcript role detection
austinywang d71c1e8
Merge remote-tracking branch 'origin/main' into issue-4394-grok-vault…
austinywang be8c37c
Honor shell Grok homes in Vault
austinywang 9f66dff
Deduplicate Grok Vault sessions
austinywang 3a0bc4f
Allow Grok hook setup to create config dir
austinywang 8437347
Fix Grok Vault titles and icon
austinywang f95b25b
Honor custom Grok hook state directory
austinywang 12ae177
Fix Grok agent-scoped Vault filtering
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "Grok.svg", | ||
| "idiom" : "universal" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| }, | ||
| "properties" : { | ||
| "preserves-vector-representation" : true | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| #!/usr/bin/env bash | ||
| # cmux grok wrapper - installs cmux hooks and captures launch metadata. | ||
|
|
||
| find_real_grok() { | ||
| local self_dir | ||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| local names=(grok grok-macos-aarch64 grok-macos-aarch) | ||
| local IFS=: | ||
| for d in $PATH; do | ||
| [[ "$d" == "$self_dir" ]] && continue | ||
| local name candidate | ||
| for name in "${names[@]}"; do | ||
| candidate="$d/$name" | ||
| [[ -x "$candidate" ]] || continue | ||
| if [[ "$candidate" -ef "$0" ]]; then | ||
| continue | ||
| fi | ||
| printf '%s' "$candidate" | ||
| return 0 | ||
| done | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| resolve_cmux_bin() { | ||
| local bundled_cli self_dir | ||
| bundled_cli="${CMUX_BUNDLED_CLI_PATH:-}" | ||
| if [[ -n "$bundled_cli" && -x "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| bundled_cli="$self_dir/cmux" | ||
| if [[ -x "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| bundled_cli="$(command -v cmux || true)" | ||
| if [[ -n "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| return 1 | ||
| } | ||
|
|
||
| cmux_socket_available() { | ||
| local socket="${CMUX_SOCKET_PATH:-}" | ||
| [[ -n "$socket" && -S "$socket" ]] || return 1 | ||
|
|
||
| local cmux_bin | ||
| cmux_bin="$(resolve_cmux_bin)" || return 1 | ||
| CMUXTERM_CLI_RESPONSE_TIMEOUT_SEC=0.75 \ | ||
| "$cmux_bin" --socket "$socket" ping >/dev/null 2>&1 | ||
| } | ||
|
|
||
| encode_launch_argv() { | ||
| { | ||
| printf '%s\0' "$REAL_GROK" | ||
| if (( $# > 0 )); then | ||
| printf '%s\0' "$@" | ||
| fi | ||
| } | base64 | tr -d '\n' | ||
| } | ||
|
|
||
| grok_option_consumes_value() { | ||
| case "$1" in | ||
| --cwd|--model|-m|--permission-mode|--prompt-file|--prompt-json|\ | ||
| --sandbox|--settings|--config|--profile|--resume|-r) | ||
| return 0 | ||
| ;; | ||
| esac | ||
| return 1 | ||
| } | ||
|
|
||
| grok_passthrough_option_flag() { | ||
| case "$1" in | ||
| --help|-h|--version|-v|--single|--single=*|-p|--prompt-file|\ | ||
| --prompt-file=*|--prompt-json|--prompt-json=*|--output-format|\ | ||
| --output-format=*|--best-of-n|--best-of-n=*) | ||
| return 0 | ||
| ;; | ||
| esac | ||
| return 1 | ||
| } | ||
|
|
||
| grok_builtin_command_name() { | ||
| case "$1" in | ||
| auth|completion|completions|config|help|login|logout|models|sessions|\ | ||
| setup|update|upgrade|version) | ||
| return 0 | ||
| ;; | ||
| esac | ||
| return 1 | ||
| } | ||
|
|
||
| grok_command_like_invocation() { | ||
| local candidate="$1" | ||
| [[ -n "$candidate" ]] || return 1 | ||
| case "$candidate" in | ||
| *[![:alnum:]_-]*) | ||
| return 1 | ||
| ;; | ||
| esac | ||
| grok_builtin_command_name "$candidate" | ||
| } | ||
|
|
||
| should_install_grok_hooks() { | ||
| (( $# == 0 )) && return 0 | ||
|
|
||
| local arg | ||
| local skip_next=false | ||
| for arg in "$@"; do | ||
| if [[ "$skip_next" == true ]]; then | ||
| skip_next=false | ||
| continue | ||
| fi | ||
| case "$arg" in | ||
| --) | ||
| return 0 | ||
| ;; | ||
| --resume=*|-r=*) | ||
| return 0 | ||
| ;; | ||
| -*) | ||
| if grok_passthrough_option_flag "$arg"; then | ||
| return 1 | ||
| fi | ||
| if [[ "$arg" != *=* ]] && grok_option_consumes_value "$arg"; then | ||
| skip_next=true | ||
| fi | ||
| continue | ||
| ;; | ||
| *) | ||
| if grok_command_like_invocation "$arg"; then | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| REAL_GROK="$(find_real_grok)" || { echo "Error: grok not found in PATH" >&2; exit 127; } | ||
|
|
||
| IN_CMUX=0 | ||
| if [[ -n "${CMUX_SURFACE_ID:-}" ]]; then | ||
|
lawrencecchen marked this conversation as resolved.
|
||
| IN_CMUX=1 | ||
| fi | ||
|
|
||
| if [[ "$IN_CMUX" == "1" && "${CMUX_GROK_HOOKS_DISABLED:-}" != "1" ]] \ | ||
| && cmux_socket_available \ | ||
| && should_install_grok_hooks "$@"; then | ||
| CMUX_BIN="$(resolve_cmux_bin || true)" | ||
| if [[ -n "$CMUX_BIN" ]]; then | ||
| CMUXTERM_CLI_RESPONSE_TIMEOUT_SEC=2 \ | ||
| "$CMUX_BIN" --socket "$CMUX_SOCKET_PATH" hooks grok install --yes >/dev/null 2>&1 || true | ||
| fi | ||
| export CMUX_AGENT_LAUNCH_KIND="grok" | ||
| export CMUX_AGENT_LAUNCH_EXECUTABLE="$REAL_GROK" | ||
| export CMUX_AGENT_LAUNCH_ARGV_B64="$(encode_launch_argv "$@")" | ||
| export CMUX_AGENT_LAUNCH_CWD="$PWD" | ||
| fi | ||
|
|
||
| exec "$REAL_GROK" "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.