@sesamespace/hivemind 0.8.6 → 0.8.8

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.
@@ -97,6 +97,7 @@ var LLMClient = class {
97
97
  temperature;
98
98
  apiKey;
99
99
  provider;
100
+ isOAuth;
100
101
  constructor(config) {
101
102
  this.baseUrl = config.base_url;
102
103
  this.model = config.model;
@@ -104,10 +105,12 @@ var LLMClient = class {
104
105
  this.temperature = config.temperature;
105
106
  this.apiKey = config.api_key ?? "";
106
107
  this.provider = config.provider ?? "openai";
108
+ this.isOAuth = false;
107
109
  if (this.provider === "anthropic" && !this.apiKey) {
108
110
  const token = getClaudeCodeOAuthToken();
109
111
  if (token) {
110
112
  this.apiKey = token;
113
+ this.isOAuth = true;
111
114
  if (!this.baseUrl || this.baseUrl.includes("openrouter")) {
112
115
  this.baseUrl = "https://api.anthropic.com";
113
116
  }
@@ -116,7 +119,12 @@ var LLMClient = class {
116
119
  console.warn("[llm] Auth: No API key found for Anthropic provider");
117
120
  }
118
121
  } else if (this.provider === "anthropic") {
119
- console.log("[llm] Auth: Anthropic API key (from config/env)");
122
+ if (this.apiKey.startsWith("sk-ant-oat")) {
123
+ this.isOAuth = true;
124
+ console.log("[llm] Auth: Claude Max OAuth (from config)");
125
+ } else {
126
+ console.log("[llm] Auth: Anthropic API key (from config/env)");
127
+ }
120
128
  }
121
129
  }
122
130
  /**
@@ -210,13 +218,19 @@ var LLMClient = class {
210
218
  console.log(`[llm] Retry ${attempt}/${MAX_RETRIES} after ${delayMs}ms...`);
211
219
  await new Promise((r) => setTimeout(r, delayMs));
212
220
  }
221
+ const headers = {
222
+ "Content-Type": "application/json",
223
+ "anthropic-version": "2023-06-01"
224
+ };
225
+ if (this.isOAuth) {
226
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
227
+ headers["anthropic-beta"] = "oauth-2025-04-20";
228
+ } else {
229
+ headers["x-api-key"] = this.apiKey;
230
+ }
213
231
  const resp = await fetch(`${this.baseUrl}/v1/messages`, {
214
232
  method: "POST",
215
- headers: {
216
- "Content-Type": "application/json",
217
- "x-api-key": this.apiKey,
218
- "anthropic-version": "2023-06-01"
219
- },
233
+ headers,
220
234
  body: JSON.stringify(body)
221
235
  });
222
236
  if (!resp.ok) {
@@ -7384,4 +7398,4 @@ smol-toml/dist/index.js:
7384
7398
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7385
7399
  *)
7386
7400
  */
7387
- //# sourceMappingURL=chunk-S4QRR3ZJ.js.map
7401
+ //# sourceMappingURL=chunk-2LGU4ZLA.js.map