teapot-coding-agent 0.37.23 → 0.37.24

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.
@@ -900,9 +900,22 @@ export function buildApp(master) {
900
900
  });
901
901
  // ---- config (view/edit from the web UI) ----
902
902
  app.get("/api/config", (c) => {
903
+ /**
904
+ * Mask EVERY credential, including each entry of the `apiKeys` pool.
905
+ *
906
+ * Only `apiKey` was masked, so a provider holding three keys answered with one masked key and
907
+ * no `apiKeys` at all — the settings dialog could not show the pool it was editing, and saving
908
+ * that view wrote the single key back. The rotation the operator configured existed nowhere
909
+ * they could see.
910
+ */
911
+ const maskKey = (k) => (k ? "•••" + String(k).slice(-4) : undefined);
903
912
  const mask = (p) => Object.fromEntries(Object.entries(p ?? {}).map(([k, v]) => [
904
913
  k,
905
- { ...v, apiKey: v.apiKey ? "•••" + String(v.apiKey).slice(-4) : undefined },
914
+ {
915
+ ...v,
916
+ apiKey: maskKey(v.apiKey),
917
+ ...(Array.isArray(v.apiKeys) ? { apiKeys: v.apiKeys.map(maskKey) } : {}),
918
+ },
906
919
  ]));
907
920
  return c.json({
908
921
  configPath: master.configPath,
@@ -959,11 +972,37 @@ export function buildApp(master) {
959
972
  // keep masked keys intact: "•••1234" means "unchanged"
960
973
  const prev = master.config.providers ?? {};
961
974
  const providers = {};
975
+ /**
976
+ * Persist the WHOLE `apiKeys` pool, which is what the settings dialog edits.
977
+ *
978
+ * This built only `apiKey`, so every key after the first was discarded on save: the operator
979
+ * could add three and the config kept one. `apiKey` is still written as `apiKeys[0]` because
980
+ * other readers expect the legacy field (see `migrateProviderKeys`).
981
+ *
982
+ * A key arrives masked as "•••1234" when untouched, meaning "the stored value" — resolved
983
+ * POSITIONALLY against the previous list, so editing key 2 does not overwrite key 1.
984
+ */
962
985
  for (const [name, p] of Object.entries(patch.providers ?? {})) {
963
- const masked = !p.apiKey || p.apiKey.startsWith("•••");
986
+ const stored = prev[name]?.apiKeys ?? (prev[name]?.apiKey ? [prev[name].apiKey] : []);
987
+ const resolve = (k, i) => {
988
+ if (!k || k.startsWith("•••"))
989
+ return stored[i];
990
+ return k;
991
+ };
992
+ const incoming = Array.isArray(p.apiKeys) && p.apiKeys.length ? p.apiKeys : undefined;
993
+ const keys = incoming
994
+ ? incoming.map((k, i) => resolve(k, i)).filter((k) => !!k)
995
+ : [];
996
+ // a provider with NO pool keeps the legacy single-key path, including "unchanged"
997
+ const single = !incoming
998
+ ? !p.apiKey || p.apiKey.startsWith("•••")
999
+ ? stored[0]
1000
+ : p.apiKey
1001
+ : keys[0];
964
1002
  providers[name] = {
965
1003
  baseUrl: p.baseUrl ?? "",
966
- apiKey: masked ? prev[name]?.apiKey : p.apiKey,
1004
+ ...(single ? { apiKey: single } : {}),
1005
+ ...(keys.length ? { apiKeys: keys } : {}),
967
1006
  ...(p.model ? { model: p.model } : {}),
968
1007
  };
969
1008
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.23",
3
+ "version": "0.37.24",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",