Skip to content

Commit 3d5a584

Browse files
committed
refactor: remove redundant Market.Enabled toggle
Market tools are always available (just HTTP calls, no cost). Only the Autonomous toggle matters — it controls LLM token consumption. - config: remove Enabled field from MarketConfig - cooldown/main: gate on Market.Autonomous only - server: remove /config/market endpoints and handlers - web: remove Market ON/OFF button from header and all JS/i18n references
1 parent 0c5c0b3 commit 3d5a584

File tree

6 files changed

+7
-100
lines changed

6 files changed

+7
-100
lines changed

cmd/clawwork/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func runInsc(cmd *cobra.Command, _ []string) error {
646646
// Thinking mode is always disabled here: market activity requires clean JSON output,
647647
// and extended-thinking tokens consume the budget leaving too little for actual content.
648648
var marketLLM llm.Provider
649-
if cfg.Market.Enabled {
649+
if cfg.Market.Autonomous {
650650
marketLLM, err = llm.NewProvider(&cfg.LLM, kn.MarketSystemPrompt(), 8192)
651651
if err != nil {
652652
fmt.Printf(tr("Warning: market LLM failed: %s (cooldown activity disabled)\n",

internal/config/config.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ type Config struct {
2020
UI UIConfig `toml:"ui"`
2121
}
2222

23-
// MarketConfig controls market access and autonomous cooldown activity.
23+
// MarketConfig controls autonomous cooldown market activity.
2424
type MarketConfig struct {
25-
// Enabled turns on market access (default: true).
26-
// When disabled, market tools are hidden from chat and CLI commands.
27-
Enabled bool `toml:"enabled"`
28-
2925
// Autonomous controls whether the agent runs self-directed market tasks
30-
// during the 30-minute mining cooldown (default: true).
26+
// during the 30-minute mining cooldown (default: false).
3127
// Each cooldown session calls the LLM once to browse gigs, deliver work,
3228
// and post moments — this consumes LLM API tokens from your account.
33-
// Disable if you prefer the agent to mine only, without autonomous activity.
29+
// Market tools in chat and CLI commands are always available regardless of this setting.
3430
Autonomous bool `toml:"autonomous"`
3531
}
3632

@@ -71,7 +67,7 @@ func DefaultConfig() *Config {
7167
return &Config{
7268
Agent: AgentConfig{TokenID: 42},
7369
LLM: LLMConfig{Provider: "openai", BaseURL: "https://api.moonshot.cn/v1", Model: "kimi-k2.5"},
74-
Market: MarketConfig{Enabled: false, Autonomous: false},
70+
Market: MarketConfig{Autonomous: false},
7571
Logging: LoggingConfig{Level: "info"},
7672
UI: UIConfig{Language: "auto"},
7773
}

internal/miner/cooldown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// runCooldown blocks for duration d while concurrently running market activity.
1919
// Returns false if ctx is cancelled before the timer fires.
2020
func (m *Miner) runCooldown(ctx context.Context, d time.Duration) bool {
21-
if m.Market.Enabled && m.Market.Autonomous && m.MarketLLM != nil {
21+
if m.Market.Autonomous && m.MarketLLM != nil {
2222
go func() {
2323
actCtx, cancel := context.WithTimeout(ctx, d-10*time.Second)
2424
defer cancel()

internal/web/server.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ func New(chatProvider llm.Provider, state *miner.State, tokenID int, agent Agent
107107
mux.HandleFunc("POST /update", s.handleUpdate)
108108
mux.HandleFunc("GET /config/lang", s.handleGetLanguage)
109109
mux.HandleFunc("POST /config/lang", s.handleSetLanguage)
110-
mux.HandleFunc("GET /config/market", s.handleGetMarket)
111-
mux.HandleFunc("POST /config/market", s.handleSetMarket)
112110
mux.HandleFunc("GET /config/autonomous", s.handleGetAutonomous)
113111
mux.HandleFunc("POST /config/autonomous", s.handleSetAutonomous)
114112
mux.HandleFunc("GET /sessions", s.handleListSessions)
@@ -468,46 +466,6 @@ func (s *Server) handleSetLanguage(w http.ResponseWriter, r *http.Request) {
468466
})
469467
}
470468

471-
// ── Market config endpoints ──
472-
473-
func (s *Server) handleGetMarket(w http.ResponseWriter, _ *http.Request) {
474-
enabled := true // default on
475-
if cfg, err := config.Load(); err == nil {
476-
enabled = cfg.Market.Enabled
477-
}
478-
w.Header().Set("Content-Type", "application/json")
479-
_ = json.NewEncoder(w).Encode(map[string]any{"enabled": enabled})
480-
}
481-
482-
func (s *Server) handleSetMarket(w http.ResponseWriter, r *http.Request) {
483-
var req struct {
484-
Enabled bool `json:"enabled"`
485-
}
486-
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
487-
http.Error(w, `{"error":"invalid JSON"}`, http.StatusBadRequest)
488-
return
489-
}
490-
491-
cfg, err := config.Load()
492-
if err != nil {
493-
w.Header().Set("Content-Type", "application/json")
494-
w.WriteHeader(http.StatusInternalServerError)
495-
_ = json.NewEncoder(w).Encode(map[string]string{"error": "failed to load config: " + err.Error()})
496-
return
497-
}
498-
499-
cfg.Market.Enabled = req.Enabled
500-
if err := cfg.Save(); err != nil {
501-
w.Header().Set("Content-Type", "application/json")
502-
w.WriteHeader(http.StatusInternalServerError)
503-
_ = json.NewEncoder(w).Encode(map[string]string{"error": "failed to save config: " + err.Error()})
504-
return
505-
}
506-
507-
w.Header().Set("Content-Type", "application/json")
508-
_ = json.NewEncoder(w).Encode(map[string]any{"enabled": req.Enabled})
509-
}
510-
511469
func (s *Server) handleGetAutonomous(w http.ResponseWriter, _ *http.Request) {
512470
enabled := true // default on
513471
if cfg, err := config.Load(); err == nil {

internal/web/static/app.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
cmd_gig_my: 'my gigs',
5050
cmd_gig_deliver: 'deliver',
5151
cmd_gig_approve: 'approve',
52-
market_toggle_label: 'Market',
52+
5353
auto_toggle_label: 'Auto',
5454
inbox_title: 'Agent inbox',
5555
market_browse_prompt: 'Browse available gigs on the market and tell me which ones look good.',
@@ -620,8 +620,6 @@
620620
if (el) el.textContent = t('cmd_gig_deliver');
621621
el = document.getElementById('cmd-gig-approve');
622622
if (el) el.textContent = t('cmd_gig_approve');
623-
el = document.getElementById('market-toggle-label');
624-
if (el) el.textContent = t('market_toggle_label');
625623
el = document.getElementById('auto-toggle-label');
626624
if (el) el.textContent = t('auto_toggle_label');
627625
el = document.getElementById('inbox-btn');
@@ -917,46 +915,6 @@
917915
}
918916
}
919917

920-
// ── Market toggle ──
921-
const marketBtn = document.getElementById('market-toggle-btn');
922-
923-
async function initMarketToggle() {
924-
if (!marketBtn) return;
925-
marketBtn.addEventListener('click', handleMarketToggle);
926-
try {
927-
var resp = await fetch('/config/market');
928-
var data = await resp.json();
929-
setMarketBtnState(data.enabled !== false);
930-
} catch (err) {
931-
console.error('initMarketToggle error:', err);
932-
}
933-
}
934-
935-
function setMarketBtnState(enabled) {
936-
marketBtn.dataset.enabled = enabled ? 'true' : 'false';
937-
marketBtn.textContent = enabled ? 'ON' : 'OFF';
938-
}
939-
940-
async function handleMarketToggle() {
941-
if (!marketBtn) return;
942-
var next = marketBtn.dataset.enabled !== 'true';
943-
marketBtn.disabled = true;
944-
try {
945-
var resp = await fetch('/config/market', {
946-
method: 'POST',
947-
headers: { 'Content-Type': 'application/json' },
948-
body: JSON.stringify({ enabled: next }),
949-
});
950-
var data = await resp.json().catch(function() { return {}; });
951-
if (!resp.ok || data.error) throw new Error(data.error || ('HTTP ' + resp.status));
952-
setMarketBtnState(data.enabled !== false);
953-
} catch (err) {
954-
console.error('market toggle failed:', err);
955-
} finally {
956-
marketBtn.disabled = false;
957-
}
958-
}
959-
960918
// ── Autonomous toggle ──
961919
const autoBtn = document.getElementById('auto-toggle-btn');
962920

@@ -2174,7 +2132,6 @@
21742132
// Init.
21752133
applyStaticTranslations();
21762134
initLanguageSwitcher();
2177-
initMarketToggle();
21782135
initAutoToggle();
21792136
fetchVersionStatus();
21802137
connectSSE();

internal/web/static/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ <h1 id="title-main">ClawWork Console</h1>
2828
<option value="ru">Russian</option>
2929
</select>
3030
</div>
31-
<div class="market-toggle" title="Enable market tools in chat and CLI">
32-
<label id="market-toggle-label">Market</label>
33-
<button id="market-toggle-btn" class="toggle-btn" data-enabled="true">ON</button>
34-
</div>
3531
<div class="market-toggle" title="Autonomous activity during cooldown (uses LLM tokens)">
3632
<label id="auto-toggle-label">Auto</label>
3733
<button id="auto-toggle-btn" class="toggle-btn" data-enabled="true">ON</button>

0 commit comments

Comments
 (0)