feat(config): add timezone setting to agents.defaults
Add a timezone field to AgentDefaults that overrides the process-wide default timezone via time.Local at startup. This ensures all time.Now() calls across cron, heartbeat, and agent context use the configured timezone instead of relying on the server system timezone. Also supports override via PICOCLAW_AGENTS_DEFAULTS_TIMEZONE env var.
This commit is contained in:
parent
803679d914
commit
29b6e486ff
2 changed files with 13 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
"agents": {
|
||||
"defaults": {
|
||||
"workspace": "~/.picoclaw/workspace",
|
||||
"timezone": "Asia/Makassar",
|
||||
"restrict_to_workspace": true,
|
||||
"model": "gpt4",
|
||||
"max_tokens": 8192,
|
||||
|
|
@ -246,4 +247,4 @@
|
|||
"host": "0.0.0.0",
|
||||
"port": 18790
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
|
@ -167,6 +168,7 @@ type SessionConfig struct {
|
|||
}
|
||||
|
||||
type AgentDefaults struct {
|
||||
Timezone string `json:"timezone,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_TIMEZONE"`
|
||||
Workspace string `json:"workspace" env:"PICOCLAW_AGENTS_DEFAULTS_WORKSPACE"`
|
||||
RestrictToWorkspace bool `json:"restrict_to_workspace" env:"PICOCLAW_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE"`
|
||||
Provider string `json:"provider" env:"PICOCLAW_AGENTS_DEFAULTS_PROVIDER"`
|
||||
|
|
@ -515,6 +517,15 @@ func LoadConfig(path string) (*Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Apply timezone from config — overrides process-wide default
|
||||
if tz := cfg.Agents.Defaults.Timezone; tz != "" {
|
||||
loc, err := time.LoadLocation(tz)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid timezone %q: %w", tz, err)
|
||||
}
|
||||
time.Local = loc
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue