feat: enhance entrypoint script and config handling

- Added symlink creation for bsky CLI in entrypoint.sh
- Improved config update handling by copying security credentials before validation
This commit is contained in:
Kristjan Kruus 2026-03-23 13:47:51 +02:00
parent 9d085e6d5d
commit 03bcec74bc
3 changed files with 28 additions and 8 deletions

View file

@ -12,6 +12,14 @@ if [ ! -d "${HOME}/.picoclaw/workspace" ] && [ ! -f "${HOME}/.picoclaw/config.js
exit 0 exit 0
fi fi
# Ensure bsky CLI is on PATH (symlink from skill scripts)
BSKY_SCRIPT="${HOME}/.picoclaw/workspace/skills/bluesky/scripts/bsky.py"
if [ -f "$BSKY_SCRIPT" ] && [ ! -e /usr/local/bin/bsky ]; then
chmod +x "$BSKY_SCRIPT"
ln -sf "$BSKY_SCRIPT" /usr/local/bin/bsky
echo "bsky CLI symlinked to PATH"
fi
# Start virtual framebuffer for headed chromium (agent-browser) # Start virtual framebuffer for headed chromium (agent-browser)
if [ -n "$DISPLAY" ] && command -v Xvfb >/dev/null 2>&1; then if [ -n "$DISPLAY" ] && command -v Xvfb >/dev/null 2>&1; then
Xvfb "$DISPLAY" -screen 0 1280x1024x24 -ac & Xvfb "$DISPLAY" -screen 0 1280x1024x24 -ac &
@ -35,6 +43,12 @@ fi
# Start launcher (web UI) if available, otherwise fall back to gateway only. # Start launcher (web UI) if available, otherwise fall back to gateway only.
# The launcher auto-starts its own gateway subprocess. # The launcher auto-starts its own gateway subprocess.
# Tail log files to stdout so they appear in `docker logs`.
LOG_DIR="${HOME}/.picoclaw/logs"
mkdir -p "$LOG_DIR"
touch "$LOG_DIR/launcher.log" "$LOG_DIR/gateway.log"
tail -F "$LOG_DIR/launcher.log" "$LOG_DIR/gateway.log" &
if command -v picoclaw-launcher >/dev/null 2>&1; then if command -v picoclaw-launcher >/dev/null 2>&1; then
exec picoclaw-launcher -public -no-browser "$@" exec picoclaw-launcher -public -no-browser "$@"
else else

View file

@ -43,6 +43,7 @@ func NewGitHubCopilotProvider(uri string, connectMode string, model string) (*Gi
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{ session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: model, Model: model,
Hooks: &copilot.SessionHooks{}, Hooks: &copilot.SessionHooks{},
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
}) })
if err != nil { if err != nil {
client.Stop() client.Stop()

View file

@ -54,6 +54,15 @@ func (h *Handler) handleUpdateConfig(w http.ResponseWriter, r *http.Request) {
cfg.Tools.Exec.AllowRemote = config.DefaultConfig().Tools.Exec.AllowRemote cfg.Tools.Exec.AllowRemote = config.DefaultConfig().Tools.Exec.AllowRemote
} }
// Load existing config and copy security credentials before validation,
// so that security-managed fields (e.g. pico token) are available.
oldCfg, err := config.LoadConfig(h.configPath)
if err != nil {
http.Error(w, fmt.Sprintf("Failed to load config: %v", err), http.StatusInternalServerError)
return
}
cfg.SecurityCopyFrom(oldCfg)
if errs := validateConfig(&cfg); len(errs) > 0 { if errs := validateConfig(&cfg); len(errs) > 0 {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -65,12 +74,6 @@ func (h *Handler) handleUpdateConfig(w http.ResponseWriter, r *http.Request) {
} }
logger.Infof("new config: %+v", cfg) logger.Infof("new config: %+v", cfg)
oldCfg, err := config.LoadConfig(h.configPath)
if err != nil {
http.Error(w, fmt.Sprintf("Failed to load config: %v", err), http.StatusInternalServerError)
return
}
cfg.SecurityCopyFrom(oldCfg)
if err := config.SaveConfig(h.configPath, &cfg); err != nil { if err := config.SaveConfig(h.configPath, &cfg); err != nil {
http.Error(w, fmt.Sprintf("Failed to save config: %v", err), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("Failed to save config: %v", err), http.StatusInternalServerError)
@ -149,6 +152,10 @@ func (h *Handler) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
return return
} }
// Copy security credentials before validation so security-managed
// fields (e.g. pico token) are available for validation checks.
newCfg.SecurityCopyFrom(cfg)
if errs := validateConfig(&newCfg); len(errs) > 0 { if errs := validateConfig(&newCfg); len(errs) > 0 {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -159,8 +166,6 @@ func (h *Handler) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
return return
} }
newCfg.SecurityCopyFrom(cfg)
if err := config.SaveConfig(h.configPath, &newCfg); err != nil { if err := config.SaveConfig(h.configPath, &newCfg); err != nil {
http.Error(w, fmt.Sprintf("Failed to save config: %v", err), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("Failed to save config: %v", err), http.StatusInternalServerError)
return return