hammer-ai 0.2.8 → 0.2.9

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/dist/index.js CHANGED
@@ -168,19 +168,6 @@ var LLMResponseSchema = z.object({
168
168
  }).strict();
169
169
 
170
170
  // src/llm-client.ts
171
- function shouldOmitTemperature(config) {
172
- return config.model === "kimi-k2.5";
173
- }
174
- function buildChatPayload(config, basePayload) {
175
- const payload = { ...basePayload };
176
- if (shouldOmitTemperature(config)) {
177
- delete payload.temperature;
178
- }
179
- if (config.enableThinking !== void 0) {
180
- payload.enable_thinking = config.enableThinking;
181
- }
182
- return payload;
183
- }
184
171
  var LLMClient = class {
185
172
  config;
186
173
  constructor(config) {
@@ -213,7 +200,7 @@ var LLMClient = class {
213
200
  presencePenalty = 0,
214
201
  signal
215
202
  } = options;
216
- const payload = buildChatPayload(this.config, {
203
+ const payload = {
217
204
  model: this.config.model,
218
205
  messages,
219
206
  temperature,
@@ -221,7 +208,13 @@ var LLMClient = class {
221
208
  frequency_penalty: frequencyPenalty,
222
209
  presence_penalty: presencePenalty,
223
210
  stream
224
- });
211
+ };
212
+ if (this.config.model === "kimi-k2.5") {
213
+ delete payload.temperature;
214
+ }
215
+ if (this.config.enableThinking !== void 0) {
216
+ payload.enable_thinking = this.config.enableThinking;
217
+ }
225
218
  const headers = {
226
219
  "Content-Type": "application/json",
227
220
  Authorization: `Bearer ${this.config.apiKey}`,
@@ -239,7 +232,7 @@ var LLMClient = class {
239
232
  }
240
233
  if (attempt > 1) {
241
234
  log(`Retry attempt ${attempt}/${maxRetries}\u2026`, "warn");
242
- await sleep(1e3 * attempt);
235
+ await new Promise((r) => setTimeout(r, 1e3 * attempt));
243
236
  }
244
237
  const controller = new AbortController();
245
238
  const abortFetch = () => {
@@ -257,7 +250,7 @@ var LLMClient = class {
257
250
  if (!response.ok) {
258
251
  const errorText = await response.text();
259
252
  const err = new ApiError(response.status, errorText);
260
- if (isRetryableStatus(response.status) && attempt < maxRetries) {
253
+ if ((response.status === 429 || response.status === 500 || response.status === 502 || response.status === 503 || response.status === 408) && attempt < maxRetries) {
261
254
  log(`Transient HTTP ${response.status}. Retrying\u2026`, "warn");
262
255
  lastError = err;
263
256
  continue;
@@ -455,9 +448,6 @@ var LLMClient = class {
455
448
  });
456
449
  try {
457
450
  await streamPromise;
458
- } catch (err) {
459
- if (err.message?.includes("getFirstChunkTimeout()")) throw err;
460
- throw err;
461
451
  } finally {
462
452
  cleanup();
463
453
  signal?.removeEventListener("abort", abortStream);
@@ -483,9 +473,6 @@ var ApiError = class extends Error {
483
473
  }
484
474
  status;
485
475
  };
486
- function isRetryableStatus(status) {
487
- return status === 429 || status === 500 || status === 502 || status === 503 || status === 408;
488
- }
489
476
  function isNetworkError(err) {
490
477
  const code = err.code ?? err.cause?.code ?? "";
491
478
  return code === "ENOTFOUND" || code === "ETIMEDOUT" || code === "ECONNREFUSED" || code === "UND_ERR_CONNECT_TIMEOUT" || typeof err.message === "string" && err.message.includes("fetch failed");
@@ -506,9 +493,6 @@ function createAbortError(reason) {
506
493
  error.name = "AbortError";
507
494
  return error;
508
495
  }
509
- function sleep(ms) {
510
- return new Promise((r) => setTimeout(r, ms));
511
- }
512
496
  var AGENT_MACHINE_STATES = [
513
497
  "idle",
514
498
  "prompting",