mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
Boot-time installs were swallowed and the boot cleared gitSetup, so a restart whose install failed again dropped the desktop strip while git still lacked identities. Every boot install now goes through settleMemberGit: failure marks the VM and the row, a later success (or a boot with nobody to install) clears them. The git shim refuses on a failed mark even with nothing pending. Restart is the retry (it re-runs the install before it answers).
54 lines
2.9 KiB
Bash
Executable File
54 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# git for agents in Orca Cloud workspaces (first on orcad's PATH). Commands that author or publish
|
|
# work run as the teammate whose message started this agent's turn (orca-git-as: orcad attests the
|
|
# sender's paired device; root-only member identities). Everything else is plain git, untouched.
|
|
real=/usr/bin/git
|
|
sub=''
|
|
skip=0
|
|
for arg in "$@"; do
|
|
if [ "$skip" = 1 ]; then skip=0; continue; fi
|
|
case "$arg" in
|
|
-C | -c | --git-dir | --work-tree | --namespace | --exec-path | --config-env) skip=1 ;;
|
|
-*) ;;
|
|
*) sub="$arg"; break ;;
|
|
esac
|
|
done
|
|
# CREATE-GIT-ASYNC: a new workspace answers before teammates' GitHub identities are installed. Until
|
|
# they are (orca-sandbox-members writes git-setup.ready), commits and pushes wait up to 15 s rather
|
|
# than go out under the workspace identity; a failed or stalled setup stops them with what to do.
|
|
# Read-only git and fetches never wait (they use the workspace's own credentials, set before ready).
|
|
hold_for_member_setup() {
|
|
local state="${HOME:-/nonexistent}/.orca-sandbox" ticks=0 since
|
|
# A failed install on any boot (create or a later restart) refuses even with nothing pending.
|
|
[ -f "$state/git-setup.pending" ] || [ -f "$state/git-setup.failed" ] || return 0
|
|
since="$(cat "$state/git-setup.pending" 2>/dev/null || echo 0)"
|
|
case "$since" in '' | *[!0-9]*) since=0 ;; esac
|
|
while [ -f "$state/git-setup.pending" ] && [ ! -f "$state/git-setup.ready" ] && [ ! -f "$state/git-setup.failed" ]; do
|
|
# 15 s per command; a mark older than 2 min is a setup that died, not one still running.
|
|
if [ "$ticks" -ge "${ORCA_GIT_SETUP_WAIT_TICKS:-150}" ] || [ $(($(date +%s) - since)) -gt 120 ]; then
|
|
break
|
|
fi
|
|
sleep 0.1
|
|
ticks=$((ticks + 1))
|
|
done
|
|
if [ -f "$state/git-setup.ready" ] || { [ ! -f "$state/git-setup.pending" ] && [ ! -f "$state/git-setup.failed" ]; }; then
|
|
return 0
|
|
fi
|
|
if [ -f "$state/git-setup.failed" ]; then
|
|
printf '%s\n' "orca: Orca couldn't set up your GitHub identity in this sandbox, so it stopped \`git $sub\` rather than use the wrong identity. Restart this workspace (right-click it in the sidebar > Restart), then try again." >&2
|
|
else
|
|
printf '%s\n' "orca: Orca is still setting up your GitHub identity in this sandbox, so it stopped \`git $sub\` rather than use the wrong identity. Try again in a few seconds. If this keeps happening, restart this workspace (right-click it in the sidebar > Restart)." >&2
|
|
fi
|
|
exit 1
|
|
}
|
|
case "$sub" in
|
|
commit | push | merge | rebase | cherry-pick | revert | am | pull | tag)
|
|
hold_for_member_setup
|
|
# Outside an agent turn (no attested sender) orca-git-as falls back to the workspace identity.
|
|
if [ -n "${ORCA_TERMINAL_HANDLE:-}${ORCA_AGENT_SESSION_ID:-}" ] && [ -x /opt/orca/bin/orca-git-as ]; then
|
|
PATH="/usr/bin:/bin:$PATH" exec /opt/orca/bin/orca-git-as "$@" 2> >(grep -v '^orca-git-as: no teammate identity' >&2)
|
|
fi
|
|
;;
|
|
esac
|
|
exec "$real" "$@"
|