@axiom-lattice/client-sdk 4.6.0 → 4.7.0

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.mjs CHANGED
@@ -1856,6 +1856,7 @@ var ScheduledTaskStatus = /* @__PURE__ */ ((ScheduledTaskStatus2) => {
1856
1856
  })(ScheduledTaskStatus || {});
1857
1857
 
1858
1858
  // src/abstract-client.ts
1859
+ import { threadAffinityHeaders } from "@axiom-lattice/protocols";
1859
1860
  var AbstractClient = class {
1860
1861
  /**
1861
1862
  * Creates a new AbstractClient instance
@@ -1986,7 +1987,8 @@ var AbstractClient = class {
1986
1987
  return await this.makeRequest(
1987
1988
  `/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`,
1988
1989
  {
1989
- method: "POST"
1990
+ method: "POST",
1991
+ headers: threadAffinityHeaders(params.threadId)
1990
1992
  }
1991
1993
  );
1992
1994
  }
@@ -3366,6 +3368,9 @@ var AbstractClient = class {
3366
3368
  }
3367
3369
  };
3368
3370
 
3371
+ // src/client.ts
3372
+ import { threadAffinityHeaders as threadAffinityHeaders2 } from "@axiom-lattice/protocols";
3373
+
3369
3374
  // src/resources-client.ts
3370
3375
  var ResourcesClient = class {
3371
3376
  constructor(baseURL, getHeaders) {
@@ -4288,6 +4293,7 @@ var _Client = class extends AbstractClient {
4288
4293
  const requestHeaders = {
4289
4294
  ...this.headers,
4290
4295
  ...workspaceHeaders,
4296
+ ...this.bodyAffinityHeaders(options?.body),
4291
4297
  ...options?.headers || {}
4292
4298
  };
4293
4299
  if (method === "DELETE" && !options?.body) {
@@ -4325,7 +4331,8 @@ var _Client = class extends AbstractClient {
4325
4331
  const headers = {
4326
4332
  "Content-Type": "application/json",
4327
4333
  Accept: "text/event-stream",
4328
- ...this.getAllHeaders()
4334
+ ...this.getAllHeaders(),
4335
+ ...threadAffinityHeaders2(options.threadId)
4329
4336
  };
4330
4337
  const controller = new AbortController();
4331
4338
  const { signal } = controller;
@@ -4423,11 +4430,18 @@ var _Client = class extends AbstractClient {
4423
4430
  ...workspaceHeaders
4424
4431
  };
4425
4432
  }
4433
+ bodyAffinityHeaders(body) {
4434
+ if (!body || typeof body !== "object" || body instanceof FormData)
4435
+ return {};
4436
+ const threadId = body.thread_id;
4437
+ return typeof threadId === "string" ? threadAffinityHeaders2(threadId) : {};
4438
+ }
4426
4439
  streamRun(options, onEvent, onComplete, onError) {
4427
4440
  const headers = {
4428
4441
  "Content-Type": "application/json",
4429
4442
  Accept: "text/event-stream",
4430
- ...this.getAllHeaders()
4443
+ ...this.getAllHeaders(),
4444
+ ...threadAffinityHeaders2(options.threadId)
4431
4445
  };
4432
4446
  const controller = new AbortController();
4433
4447
  const { signal } = controller;
@@ -4537,9 +4551,11 @@ var RuntimeAxiomClient = class extends Client {
4537
4551
  async makeRequest(url, options) {
4538
4552
  await this.primeToken();
4539
4553
  const method = options?.method ?? "GET";
4554
+ const affinity = this.bodyAffinityHeaders(options?.body);
4540
4555
  const headers = {
4541
4556
  "Content-Type": "application/json",
4542
4557
  ...this.identityHeaders(),
4558
+ ...affinity,
4543
4559
  ...options?.headers ?? {}
4544
4560
  };
4545
4561
  const requestOptions = { method, headers };
@@ -4593,6 +4609,7 @@ var RuntimeAxiomClient = class extends Client {
4593
4609
  };
4594
4610
 
4595
4611
  // src/wechat-client.ts
4612
+ import { threadAffinityHeaders as threadAffinityHeaders3 } from "@axiom-lattice/protocols";
4596
4613
  var import_encoding = __toESM(require_encoding());
4597
4614
  var WeChatClient = class extends AbstractClient {
4598
4615
  /**
@@ -4690,7 +4707,8 @@ var WeChatClient = class extends AbstractClient {
4690
4707
  const headers = {
4691
4708
  "Content-Type": "application/json",
4692
4709
  Authorization: `Bearer ${this.config.apiKey}`,
4693
- ...this.config.headers
4710
+ ...this.config.headers,
4711
+ ...threadAffinityHeaders3(options.threadId)
4694
4712
  };
4695
4713
  if (this.tenantId) {
4696
4714
  headers["x-tenant-id"] = this.tenantId;
@@ -4804,7 +4822,8 @@ var WeChatClient = class extends AbstractClient {
4804
4822
  const headers = {
4805
4823
  "Content-Type": "application/json",
4806
4824
  Authorization: `Bearer ${this.config.apiKey}`,
4807
- ...this.config.headers
4825
+ ...this.config.headers,
4826
+ ...threadAffinityHeaders3(options.threadId)
4808
4827
  };
4809
4828
  if (this.tenantId) {
4810
4829
  headers["x-tenant-id"] = this.tenantId;