leaf-coding-agent 1.0.4 → 1.0.5

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.
@@ -1955,13 +1955,23 @@ export class AgentSession {
1955
1955
  if (this._extensionRunnerRef) {
1956
1956
  this._extensionRunnerRef.current = this._extensionRunner;
1957
1957
  }
1958
- // 初始化 Worker 集成
1958
+ // 初始化 Worker 集成(API Key 将在首次使用时获取)
1959
1959
  this.workerIntegration = createWorkerIntegration({
1960
1960
  cwd: this._cwd,
1961
1961
  agentSession: this,
1962
1962
  extensionRunner: this._extensionRunner,
1963
1963
  });
1964
1964
  this.workerIntegration.initialize();
1965
+ // 异步获取 API Key
1966
+ if (this.model) {
1967
+ this._modelRegistry.getApiKeyAndHeaders(this.model).then(authResult => {
1968
+ if (authResult.ok && authResult.apiKey && this.workerIntegration) {
1969
+ this.workerIntegration.updateApiKey(authResult.apiKey);
1970
+ }
1971
+ }).catch(error => {
1972
+ console.warn("[WorkerIntegration] 获取 API Key 失败:", error);
1973
+ });
1974
+ }
1965
1975
  this._bindExtensionCore(this._extensionRunner);
1966
1976
  this._applyExtensionBindings(this._extensionRunner);
1967
1977
  const defaultActiveToolNames = this._baseToolsOverride