Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(config): add the zhipu_api_key file-plane slot folded into ZHIPUAI_API_KEY (#5338)

time-attack41a36104e740
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index f561558199..84b55a07ba 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -36,7 +36,7 @@ src/core/embedding-migration.ts 1586 ratchet new row: crossed 1500 in v0.46.25.0
src/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refresh
src/commands/hook.ts 1904 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail read; +1 #5371: the stop-hook dirty probe ignores physical-root ownership metadata (root-metadata.ts, engine-free)
src/core/chunkers/code.ts 1588 ratchet new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (decorated-python defs #3821, version-gate + timeout chunker fixes); grown wave-g (#4511): named defs never folded into merged chunks; grown #4669: skip WASM parse for languages without TOP_LEVEL_TYPES; +6 N13-1: CodeChunkMetadata.definesFunction field + merge-guard stamp (predicate lives in def-types.ts)
-src/core/config.ts 1877 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured); +3 retrieval feedback: the feedback keys in KNOWN_CONFIG_KEYS; 2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x engine graduation composition: both deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x foundations-2 composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); P3 x P1 (v0.60.57.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; P3 x P7 (v0.60.60.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); P3 x aow-followup composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); +2 entity mention index: mentions.auto_link, mentions.entity_types, mentions.ignore key rows (resolver in core/mentions/policy.ts); cat40 entity wave merge with v0.60.61.0 (1853 measured); P3 x cat40-entity-wave composition: deltas re-summed at the merge; +6 fix wave lane B3: chat_fallback_on_refusal (GBrainConfig slot, GBRAIN_CHAT_FALLBACK_ON_REFUSAL env fold, known key); +2 W-B4: shared_skills.inventory.* known keys (logic in shared-skills/inventory-limits.ts); +2 fix wave 9 lane B #4921: ai.chat.per_turn_timeout_ms known key; +1 wave 9 lane W #5363: cycle.consolidate.cluster_threshold key row; +1 #5984 lanes: sync.lanes key registration; +2 P8: dream.quote_verify and think.quote_verify known keys; +2 P8: GBrainConfig.mcp.advertised_surface interface slot (resolver in mcp/surface.ts); +2 fix wave 10 lane L1 #4907: cycle.synthesize_concepts.budget_usd registered (validation in cycle/phase-config-values.ts); +2 #5958: dream.propose_takes.call_timeout_ms registered; +1 #5024: search.statement_timeout_ms registered in KNOWN_CONFIG_KEYS
+src/core/config.ts 1881 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured); +3 retrieval feedback: the feedback keys in KNOWN_CONFIG_KEYS; 2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x engine graduation composition: both deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x foundations-2 composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); P3 x P1 (v0.60.57.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; P3 x P7 (v0.60.60.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); P3 x aow-followup composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); +2 entity mention index: mentions.auto_link, mentions.entity_types, mentions.ignore key rows (resolver in core/mentions/policy.ts); cat40 entity wave merge with v0.60.61.0 (1853 measured); P3 x cat40-entity-wave composition: deltas re-summed at the merge; +6 fix wave lane B3: chat_fallback_on_refusal (GBrainConfig slot, GBRAIN_CHAT_FALLBACK_ON_REFUSAL env fold, known key); +2 W-B4: shared_skills.inventory.* known keys (logic in shared-skills/inventory-limits.ts); +2 fix wave 9 lane B #4921: ai.chat.per_turn_timeout_ms known key; +1 wave 9 lane W #5363: cycle.consolidate.cluster_threshold key row; +1 #5984 lanes: sync.lanes key registration; +2 P8: dream.quote_verify and think.quote_verify known keys; +2 P8: GBrainConfig.mcp.advertised_surface interface slot (resolver in mcp/surface.ts); +2 fix wave 10 lane L1 #4907: cycle.synthesize_concepts.budget_usd registered (validation in cycle/phase-config-values.ts); +2 #5958: dream.propose_takes.call_timeout_ms registered; +1 #5024: search.statement_timeout_ms registered in KNOWN_CONFIG_KEYS; +4 #5338: zhipu_api_key file-plane slot (GBrainConfig field + KNOWN_CONFIG_KEYS row)
src/core/bootstrap/harness.ts 2711 ratchet +29 live-PGLite-serve lane: LIVE_SERVE refusal ahead of source resolution + unpinned --token hooks (CI e2e fix); +46 wave review: resolveHookSource dep (serve-parity resolver + federated grant), --source shape validation, loud SOURCE_UNRESOLVED instead of a silent 'default'; +10: #4574 parseCodexBlockBearer http_headers shape + legacy bearer_token fallback; +4 at megawave/wave-k merge; +codex hooks lane: step-7 codex hooks.json + config.toml trust pair, removeHarness arm; +234 ambient-writeback WP3: kind:'instructions' targets (plan/apply/converge-off/remove/status probes, OV-A4 override pre-check) — splice/render mechanics live in instructions-block.ts; +59 adversarial fix wave: registrar-mode block suppression, converge-failure receipt tracking, MCP-confirmed guard before block install; +26 round-3 fixes: codex-lane MCP-confirmed guard + smoke-rollback block strip; master: | merged v0.48.1.0 true-up; +41 #4897 resolveImplicitSource dep + defaultResolveImplicitSource: hooks/token/receipt bind to the serve's implicit default source when --source is omitted; +23 #4586 statusHarness live claude-code mcp verdict (URL mismatch or same-scope non-HTTP registration reads failed, receipt untouched); shared-skills integration on company-ingestion base; +18 #5671: logAmbientPostureNotes helper (registrar note moved out of applyHarness + pre-consent warning when an explicit private facts default meets the HTTP harness; text shared with doctor in facts/writeback-config.ts); +24 #5893: rotation grant carry wiring and its rotationCarry/withheldOperationsNote helpers (carry rules live in token-mint.ts carryLegacyGrant); +6 #5878: --refresh-skills flag and status epoch line (refresh logic lives in harness-skills.ts); +7 #4618 seat: HarnessFlags.seat field, --seat/--no-seat parse via hooks.ts parseSeatFlags, GBRAIN_SEAT in the hook env
src/core/oauth-provider.ts 1236 ratchet new row: crossed the 1500 unlisted cap absorbing #3819 (DCR 400 invalid_client_metadata + scope filtering + custom-scheme redirect_uris + pseudo-scheme guard); merged v0.49: transactional grant enforcement shared with hosted grant policies; +1 #5222 resourceUrl option
src/core/ops/pages.ts 671 ratchet crossed the unlisted 1500 cap in the fix wave: pack-vocabulary enforcement on capture (#4721) + get_page alias follow (#4275) landed together; next growth should peel a pages-ops submodule; +3: alias hop reads the canonical in the owning source (ship-review); +5: explicit source_id liveness check in get_page/list_pages (#4620); +3: #4857 total-order slug sort + list_pages source_id parse; +5: #4620 explicit removed-source id fails loudly; master integration: +4: authenticated delegated private-write boundary and auto-link suppression; #5105: canonical page mutations peeled into persistence modules; +2 v0.50.5.0 purge parameter and shared preflight call; preparation composes through the persistence modules; +7: source-qualified deep-research fetch authorization and ambiguity refusal (codec lives in deep-research-id.ts); +1 #5567: remote get_page keeps materialized markers; +1 #5622: trusted local capture file parameter; +5 #5709: get_page include_timeline_entries (rows via get_timeline's read policy); +8 GBRA-36 security wave: required outputRedaction policy on each pages op; +1 #5154: list_pages passes listColumnsOnly; +17 #5641: list_pages exposes the updated_after_slug keyset cursor and updated_at_iso; +8 agent operator wave A2: every op declares mutating + idempotent (tags only); +7 F3b (#5954): list_pages pagination meta + listing_truncated notice for MCP callers (logic in ops/list-pages-pagination.ts); +4 #5988: get_page file_held (one indexed hold lookup; logic in persistence/held-reads.ts); +6 #6103: list_pages maps an unreadable updated_after (SQLSTATE 22007/22008) to invalid_params; wave 10 collector: #6103 (+6) and #4807 (+2) compose
diff --git a/src/commands/config.ts b/src/commands/config.ts
index 362145ca8b..ca5e49113e 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -265,6 +265,7 @@ export const FILE_PLANE_API_KEYS: readonly string[] = [
'deepseek_api_key',
'litellm_api_key',
'together_api_key',
+ 'zhipu_api_key',
'google_api_key',
'azure_openai_api_key', // #4031: mergedProviderEnv reads the file plane only
];
diff --git a/src/core/ai/provider-env.ts b/src/core/ai/provider-env.ts
index 7e4f2bdff1..8352d6d7de 100644
--- a/src/core/ai/provider-env.ts
+++ b/src/core/ai/provider-env.ts
@@ -47,6 +47,9 @@ export const CONFIG_API_KEY_ENV = [
// way voyage's #2662 did).
['litellm_api_key', 'LITELLM_API_KEY'],
['together_api_key', 'TOGETHER_API_KEY'],
+ // The zhipu recipe (embeddings + GLM chat) requires ZHIPUAI_API_KEY; launchd
+ // workers and MCP stdio servers that do not export it read the file plane.
+ ['zhipu_api_key', 'ZHIPUAI_API_KEY'],
['google_api_key', 'GOOGLE_GENERATIVE_AI_API_KEY'],
// #4031: the Azure key was the only member of the group below left unfolded,
// so a config.json-only setup failed every embed from keyless shells
diff --git a/src/core/config-db-merge.ts b/src/core/config-db-merge.ts
index cdc6334155..5318baf7b5 100644
--- a/src/core/config-db-merge.ts
+++ b/src/core/config-db-merge.ts
@@ -42,6 +42,7 @@ export const DB_MERGED_PROVIDER_KEY_FIELDS = [
'deepseek_api_key',
'litellm_api_key',
'together_api_key',
+ 'zhipu_api_key',
'google_api_key',
'azure_openai_api_key',
] as const;
diff --git a/src/core/config.ts b/src/core/config.ts
index 8f1aaf125c..7066cf302a 100644
--- a/src/core/config.ts
+++ b/src/core/config.ts
@@ -111,6 +111,9 @@ export interface GBrainConfig {
* (and same DB-plane caveat) as voyage_api_key above.
*/
together_api_key?: string;
+ /** Zhipu AI API key: file-plane slot folded into ZHIPUAI_API_KEY (the zhipu recipe's
+ * embeddings and GLM chat). Same fold and DB-plane caveat as voyage_api_key. */
+ zhipu_api_key?: string;
/**
* Google Gemini API key (#3500). File-plane slot folded into the gateway
* env as GOOGLE_GENERATIVE_AI_API_KEY (the name the google recipe reads).
@@ -1225,6 +1228,7 @@ export const KNOWN_CONFIG_KEYS: readonly string[] = [
'deepseek_api_key',
'litellm_api_key',
'together_api_key',
+ 'zhipu_api_key',
'google_api_key',
'azure_openai_api_key',
'azure_openai_endpoint',
diff --git a/src/core/readiness.ts b/src/core/readiness.ts
index e621bc5b51..efa57ef6ce 100644
--- a/src/core/readiness.ts
+++ b/src/core/readiness.ts
@@ -35,7 +35,7 @@ import { isEngineDegraded } from './degraded-marker.ts';
import { heldLockFor, peekLock, type LockPeekResult } from './pglite-lock.ts';
import { listRecipes, RECIPES } from './ai/recipes/index.ts';
import type { Recipe } from './ai/types.ts';
-import { mergedProviderEnv } from './ai/provider-env.ts';
+import { CONFIG_API_KEY_ENV, mergedProviderEnv } from './ai/provider-env.ts';
import { resolveSchemaEmbeddingDim } from './embedding-dim-check.ts';
import { DEFAULT_EMBEDDING_DIMENSIONS, NEW_INSTALL_DEFAULT_EMBEDDING_MODEL } from './ai/defaults.ts';
import { getCliOptions, parseGlobalFlags } from './cli-options.ts';
@@ -155,15 +155,13 @@ function providerLabel(recipe: Recipe): string {
return recipe.name ?? recipe.id;
}
-/** Provider keys `gbrain config set` stores on the file plane (src/commands/config.ts FILE_PLANE_API_KEYS). */
-const FILE_PLANE_KEY_ENVS: ReadonlySet<string> = new Set([
- 'OPENAI_API_KEY', 'ANTHROPIC_API_KEY', 'OPENROUTER_API_KEY', 'VOYAGE_API_KEY', 'DASHSCOPE_API_KEY',
- 'DEEPSEEK_API_KEY', 'LITELLM_API_KEY', 'TOGETHER_API_KEY', 'GOOGLE_API_KEY', 'AZURE_OPENAI_API_KEY',
-]);
+/** Env name -> the file-plane key `gbrain config set` stores it under (zhipu_api_key fills ZHIPUAI_API_KEY). */
+const FILE_PLANE_KEY_FOR_ENV: ReadonlyMap<string, string> = new Map(CONFIG_API_KEY_ENV.map(([key, env]) => [env, key]));
function keyHow(name: string): string {
- return FILE_PLANE_KEY_ENVS.has(name)
- ? `store it with \`gbrain config set ${name.toLowerCase()} <key>\` (every gbrain process reads it), or export ${name} in the environment of every gbrain process`
+ const configKey = FILE_PLANE_KEY_FOR_ENV.get(name);
+ return configKey
+ ? `store it with \`gbrain config set ${configKey} <key>\` (every gbrain process reads it), or export ${name} in the environment of every gbrain process`
: `export ${name}=<key> in the environment of every gbrain process, including the one your agent harness starts`;
}
diff --git a/test/config-file-plane-keys.test.ts b/test/config-file-plane-keys.test.ts
index 3b8a6886fd..66ba64f6fb 100644
--- a/test/config-file-plane-keys.test.ts
+++ b/test/config-file-plane-keys.test.ts
@@ -28,12 +28,16 @@ const noEngine = null as unknown as BrainEngine;
async function captureLog(fn: () => Promise<void>): Promise<string> {
const orig = console.log;
+ const origExit = process.exit;
let out = '';
console.log = (...a: unknown[]) => { out += a.map(String).join(' ') + '\n'; };
+ // A refused write fails the calling test instead of ending the runner.
+ (process as { exit: unknown }).exit = ((code?: number) => { throw new Error(`process.exit(${code}) during a write expected to succeed`); }) as unknown as typeof process.exit;
try {
await fn();
} finally {
console.log = orig;
+ process.exit = origExit;
}
return out;
}
@@ -202,6 +206,7 @@ const GATEWAY_MAPPED_KEYS = [
'voyage_api_key',
'dashscope_api_key',
'deepseek_api_key',
+ 'zhipu_api_key',
'google_api_key',
] as const;
@@ -233,6 +238,21 @@ describe('config set — vendor API keys are FILE-plane canonical', () => {
}
});
+ test('zhipu_api_key: set lands in config.json, never the DB plane, and set + show print it redacted', async () => {
+ const parent = mkdtempSync(join(tmpdir(), 'gb-cfg-apikey-zhipu-'));
+ await withEnv({ GBRAIN_HOME: parent, DATABASE_URL: undefined }, async () => {
+ // The null engine proves the write never reaches the DB plane.
+ const setOut = await captureLog(() => runConfig(noEngine, ['set', 'zhipu_api_key', 'zp-TEST-VALUE-123']));
+ expect(setOut).toContain('file plane');
+ expect(setOut).not.toContain('zp-TEST-VALUE-123');
+ const cfgPath = join(parent, '.gbrain', 'config.json');
+ expect((JSON.parse(readFileSync(cfgPath, 'utf8')) as Record<string, unknown>).zhipu_api_key).toBe('zp-TEST-VALUE-123');
+ const showOut = await captureLog(() => runConfig({} as unknown as BrainEngine, ['show']));
+ expect(showOut).toContain('zhipu_api_key: ***');
+ expect(showOut).not.toContain('zp-TEST-VALUE-123');
+ });
+ });
+
test('unset removes the key from the file plane, so set/unset round-trip on one plane', async () => {
const parent = mkdtempSync(join(tmpdir(), 'gb-cfg-apikey-unset-'));
await withEnv({ GBRAIN_HOME: parent }, async () => {
diff --git a/test/provider-env.test.ts b/test/provider-env.test.ts
index f52ddf3e7d..7e26b9359c 100644
--- a/test/provider-env.test.ts
+++ b/test/provider-env.test.ts
@@ -19,6 +19,7 @@ describe('mergedProviderEnv', () => {
openai_api_key: 'sk-o', anthropic_api_key: 'sk-a', voyage_api_key: 'pa-v',
openrouter_api_key: 'or', dashscope_api_key: 'ds',
deepseek_api_key: 'sk-deepseek',
+ zhipu_api_key: 'zp-secret',
google_api_key: 'gg',
azure_openai_api_key: 'az-secret',
azure_openai_endpoint: 'https://x.openai.azure.com',
@@ -31,6 +32,9 @@ describe('mergedProviderEnv', () => {
expect(env.OPENROUTER_API_KEY).toBe('or');
expect(env.DASHSCOPE_API_KEY).toBe('ds');
expect(env.DEEPSEEK_API_KEY).toBe('sk-deepseek');
+ // The zhipu recipe requires ZHIPUAI_API_KEY; the file-plane slot lets
+ // launchers that do not export it authenticate GLM calls.
+ expect(env.ZHIPUAI_API_KEY).toBe('zp-secret');
expect(env.GOOGLE_GENERATIVE_AI_API_KEY).toBe('gg');
// #4031: the key was the only member of the Azure group left unfolded —
// config.json looked complete while every keyless-shell embed failed auth.
diff --git a/test/readiness.test.ts b/test/readiness.test.ts
index 1367929d9d..530c553cf0 100644
--- a/test/readiness.test.ts
+++ b/test/readiness.test.ts
@@ -162,6 +162,22 @@ describe('embeddingEnablement', () => {
expect(a.argv?.[4]).toBe('openai:text-embedding-3-small');
expect(a.inputs?.map(i => i.name)).toEqual(['OPENAI_API_KEY']);
});
+
+ test('the key hint names the config key `gbrain config set` accepts, not the lowercased env name', async () => {
+ const how = async (embedding_model: string, embedding_dimensions: number) =>
+ (await run(pglite({ embedding_disabled: true, embedding_model, embedding_dimensions }), {})).inputs?.[0]?.how ?? '';
+ // ZHIPUAI_API_KEY is stored as zhipu_api_key; `config set zhipuai_api_key` is rejected as unknown.
+ const zhipu = await how('zhipu:embedding-3', 1024);
+ expect(zhipu).toContain('`gbrain config set zhipu_api_key <key>`');
+ expect(zhipu).not.toContain('zhipuai_api_key');
+ // The google recipe reads GOOGLE_GENERATIVE_AI_API_KEY, stored as google_api_key.
+ const google = await how('google:gemini-embedding-001', 768);
+ expect(google).toContain('`gbrain config set google_api_key <key>`');
+ // A recipe key with no file-plane slot keeps the export-only hint.
+ const mistral = await how('mistral:mistral-embed', 1024);
+ expect(mistral).not.toContain('config set');
+ expect(mistral).toContain('export MISTRAL_API_KEY=<key>');
+ });
});
describe('harness_wiring by state', () => {