agim-cli 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.0.6] - 2026-05-12
8
+
9
+ ### Fixed — Agent toggles in the web settings page actually do something
10
+
11
+ The agent toggle in `/settings` only flipped the `.active` CSS class — it
12
+ never updated `config.agents`, so toggling an agent on or off had zero
13
+ effect on the saved config. The "Save Agents" button next to it had no
14
+ click handler at all. The "Default Agent" `<select>` likewise ignored
15
+ user changes.
16
+
17
+ All three are now wired up the same way the messenger card already works:
18
+
19
+ - Clicking an agent toggle flips it in `config.agents` (in-memory) and
20
+ re-renders so the Default Agent dropdown reflects the new eligible set.
21
+ - Toggling off the current default auto-promotes the next still-enabled
22
+ agent (or clears if nothing left). Toggling on an agent when no default
23
+ is set makes it the default.
24
+ - The Default Agent dropdown now only lists agents that are BOTH enabled
25
+ AND installed — so the saved default isn't a missing binary or a
26
+ disabled adapter that would break routing the first time someone sends
27
+ a message.
28
+ - Changing the dropdown updates `config.defaultAgent` immediately; the
29
+ Save Agents button PUTs everything to `/api/config`.
30
+
7
31
  ## [1.0.5] - 2026-05-12
8
32
 
9
33
  ### Added — full messenger configuration + service control in the web settings page
@@ -741,16 +741,24 @@
741
741
  `;
742
742
  }).join('');
743
743
 
744
+ // Default-agent picker only lists agents that are BOTH enabled and
745
+ // installed — defaulting to a missing binary or a disabled adapter
746
+ // both break routing the first time someone sends a message.
747
+ const eligibleDefaults = agents.filter(a => enabledAgents.includes(a) && agentStatus[a]);
748
+
744
749
  return `
745
750
  <div class="card">
746
751
  <h2>${t('agents')} <span class="badge">${agents.length}</span></h2>
747
752
  ${rows}
748
753
  <hr class="divider">
749
754
  <label>${t('defaultAgent')}</label>
750
- <select id="defaultAgent">
751
- ${agents.filter(a => agentStatus[a]).map(a =>
752
- `<option value="${esc(a)}" ${a === defaultAgent ? 'selected' : ''}>${esc(a)}</option>`
753
- ).join('')}
755
+ <select id="defaultAgent" ${eligibleDefaults.length === 0 ? 'disabled' : ''}>
756
+ ${eligibleDefaults.length === 0
757
+ ? `<option value="">— ${esc(t('agents'))} —</option>`
758
+ : eligibleDefaults.map(a =>
759
+ `<option value="${esc(a)}" ${a === defaultAgent ? 'selected' : ''}>${esc(a)}</option>`
760
+ ).join('')
761
+ }
754
762
  </select>
755
763
  <div class="actions">
756
764
  <button type="button" class="btn btn-primary" id="saveAgents">${t('saveAgents')}</button>
@@ -1211,9 +1219,40 @@
1211
1219
  document.getElementById('svc-stop')?.addEventListener('click', () => svcAction('stop'));
1212
1220
  document.getElementById('svc-start')?.addEventListener('click', () => svcAction('start'));
1213
1221
 
1214
- // Agent toggles
1222
+ // Agent toggles — flip config.agents in memory + auto-manage
1223
+ // defaultAgent (promote / demote as needed), then re-render so the
1224
+ // default-agent dropdown reflects the new eligible set.
1215
1225
  document.querySelectorAll('[data-toggle-agent]').forEach(el => {
1216
- el.addEventListener('click', () => el.classList.toggle('active'));
1226
+ el.addEventListener('click', () => {
1227
+ const id = el.getAttribute('data-toggle-agent');
1228
+ const set = new Set(config.agents || []);
1229
+ if (set.has(id)) {
1230
+ set.delete(id);
1231
+ // If we just removed the default, promote the next still-enabled
1232
+ // agent (or clear). saveConfig() will sync to disk on Save.
1233
+ if (config.defaultAgent === id) {
1234
+ config.defaultAgent = Array.from(set)[0] || '';
1235
+ }
1236
+ } else {
1237
+ set.add(id);
1238
+ // First enabled agent inherits default when nothing was set.
1239
+ if (!config.defaultAgent) config.defaultAgent = id;
1240
+ }
1241
+ config.agents = Array.from(set);
1242
+ render();
1243
+ });
1244
+ });
1245
+
1246
+ // Default-agent dropdown — keep in-memory config in sync so the
1247
+ // Save button persists what the user just picked.
1248
+ document.getElementById('defaultAgent')?.addEventListener('change', (e) => {
1249
+ config.defaultAgent = e.target.value;
1250
+ });
1251
+
1252
+ // Save Agents button — pushes the in-memory agents[] + defaultAgent
1253
+ // to /api/config PUT. Mirrors the saveMessengers pattern.
1254
+ document.getElementById('saveAgents')?.addEventListener('click', async () => {
1255
+ await saveConfig();
1217
1256
  });
1218
1257
 
1219
1258
  // Messenger toggles — flip in-memory config.messengers, then re-render.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agim-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Agim (阿吉姆) — universal messenger-to-agent bridge. Connect WeChat / Feishu / DingTalk / Telegram / Discord to Claude Code / Codex / Copilot / OpenCode, or any custom agent via ACP. Installs the `agim` command.",
5
5
  "type": "module",
6
6
  "bin": {