codemie-sdk 0.1.427 → 0.1.429

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.d.cts CHANGED
@@ -37,6 +37,7 @@ interface AuthConfig {
37
37
  token?: string | null;
38
38
  verifySSL?: boolean;
39
39
  cookies?: Record<string, string>;
40
+ tokenGetter?: (() => Promise<string>) | null;
40
41
  }
41
42
 
42
43
  interface ResponseMetadata {
@@ -573,13 +574,13 @@ interface AssistantUpdateResponse {
573
574
  }
574
575
 
575
576
  declare const AssistantListParamsSchema: z.ZodReadonly<z.ZodObject<{
576
- minimal_response: z.ZodPrefault<z.ZodBoolean>;
577
- scope: z.ZodPrefault<z.ZodEnum<{
577
+ minimal_response: z.ZodDefault<z.ZodBoolean>;
578
+ scope: z.ZodDefault<z.ZodEnum<{
578
579
  marketplace: "marketplace";
579
580
  visible_to_user: "visible_to_user";
580
581
  }>>;
581
- page: z.ZodPrefault<z.ZodNumber>;
582
- per_page: z.ZodPrefault<z.ZodNumber>;
582
+ page: z.ZodDefault<z.ZodNumber>;
583
+ per_page: z.ZodDefault<z.ZodNumber>;
583
584
  filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
584
585
  }, z.core.$strip>>;
585
586
  type AssistantListParams = Partial<z.infer<typeof AssistantListParamsSchema>>;
@@ -637,13 +638,13 @@ declare const AssistantCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
637
638
  mcp_connect_auth_token: z.ZodOptional<z.ZodAny>;
638
639
  }, z.core.$strip>>;
639
640
  assistant_ids: z.ZodArray<z.ZodString>;
640
- prompt_variables: z.ZodPrefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
641
+ prompt_variables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
641
642
  key: z.ZodString;
642
643
  description: z.ZodOptional<z.ZodString>;
643
644
  default_value: z.ZodString;
644
645
  }, z.core.$strip>>>>;
645
646
  categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
646
- skip_integration_validation: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
647
+ skip_integration_validation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
647
648
  }, z.core.$strip>>;
648
649
  type AssistantCreateParams = z.input<typeof AssistantCreateParamsSchema>;
649
650
  declare const AssistantUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
@@ -700,13 +701,13 @@ declare const AssistantUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
700
701
  mcp_connect_auth_token: z.ZodOptional<z.ZodAny>;
701
702
  }, z.core.$strip>>;
702
703
  assistant_ids: z.ZodArray<z.ZodString>;
703
- prompt_variables: z.ZodPrefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
704
+ prompt_variables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
704
705
  key: z.ZodString;
705
706
  description: z.ZodOptional<z.ZodString>;
706
707
  default_value: z.ZodString;
707
708
  }, z.core.$strip>>>>;
708
709
  categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
709
- skip_integration_validation: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
710
+ skip_integration_validation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
710
711
  }, z.core.$strip>>;
711
712
  type AssistantUpdateParams = z.input<typeof AssistantUpdateParamsSchema>;
712
713
  declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
@@ -951,9 +952,9 @@ interface ConversationCreateRequest {
951
952
  declare const ConversationCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
952
953
  initial_assistant_id: z.ZodOptional<z.ZodString>;
953
954
  folder: z.ZodOptional<z.ZodString>;
954
- mcp_server_single_usage: z.ZodOptional<z.ZodPrefault<z.ZodBoolean>>;
955
+ mcp_server_single_usage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
955
956
  }, z.core.$strip>>;
956
- type ConversationCreateParams = z.infer<typeof ConversationCreateParamsSchema>;
957
+ type ConversationCreateParams = z.input<typeof ConversationCreateParamsSchema>;
957
958
 
958
959
  declare class ConversationService {
959
960
  private api;
@@ -1639,18 +1640,18 @@ declare class FileService {
1639
1640
  }
1640
1641
 
1641
1642
  declare const IntegrationListParamsSchema: z.ZodReadonly<z.ZodObject<{
1642
- setting_type: z.ZodPrefault<z.ZodEnum<{
1643
+ setting_type: z.ZodDefault<z.ZodEnum<{
1643
1644
  user: "user";
1644
1645
  project: "project";
1645
1646
  }>>;
1646
- page: z.ZodPrefault<z.ZodNumber>;
1647
- per_page: z.ZodPrefault<z.ZodNumber>;
1647
+ page: z.ZodDefault<z.ZodNumber>;
1648
+ per_page: z.ZodDefault<z.ZodNumber>;
1648
1649
  filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1649
1650
  }, z.core.$strip>>;
1650
1651
  type IntegrationListParams = Partial<z.infer<typeof IntegrationListParamsSchema>>;
1651
1652
  declare const IntegrationGetParamsSchema: z.ZodReadonly<z.ZodObject<{
1652
1653
  integration_id: z.ZodString;
1653
- setting_type: z.ZodPrefault<z.ZodEnum<{
1654
+ setting_type: z.ZodDefault<z.ZodEnum<{
1654
1655
  user: "user";
1655
1656
  project: "project";
1656
1657
  }>>;
@@ -1658,7 +1659,7 @@ declare const IntegrationGetParamsSchema: z.ZodReadonly<z.ZodObject<{
1658
1659
  type IntegrationGetParams = z.infer<typeof IntegrationGetParamsSchema>;
1659
1660
  declare const IntegrationGetByAliasParamsSchema: z.ZodReadonly<z.ZodObject<{
1660
1661
  alias: z.ZodString;
1661
- setting_type: z.ZodPrefault<z.ZodEnum<{
1662
+ setting_type: z.ZodDefault<z.ZodEnum<{
1662
1663
  user: "user";
1663
1664
  project: "project";
1664
1665
  }>>;
@@ -1675,14 +1676,14 @@ declare const IntegrationCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
1675
1676
  value: z.ZodUnknown;
1676
1677
  }, z.core.$strip>>;
1677
1678
  project_name: z.ZodString;
1678
- setting_type: z.ZodPrefault<z.ZodEnum<{
1679
+ setting_type: z.ZodDefault<z.ZodEnum<{
1679
1680
  user: "user";
1680
1681
  project: "project";
1681
1682
  }>>;
1682
1683
  alias: z.ZodOptional<z.ZodString>;
1683
- default: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1684
+ default: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1684
1685
  project: z.ZodOptional<z.ZodString>;
1685
- enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1686
+ enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1686
1687
  external_id: z.ZodOptional<z.ZodString>;
1687
1688
  }, z.core.$strip>>;
1688
1689
  type IntegrationCreateParams = Omit<z.infer<typeof IntegrationCreateParamsSchema>, "default" | "enabled"> & {
@@ -1698,14 +1699,14 @@ declare const IntegrationUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
1698
1699
  value: z.ZodUnknown;
1699
1700
  }, z.core.$strip>>;
1700
1701
  project_name: z.ZodString;
1701
- setting_type: z.ZodPrefault<z.ZodEnum<{
1702
+ setting_type: z.ZodDefault<z.ZodEnum<{
1702
1703
  user: "user";
1703
1704
  project: "project";
1704
1705
  }>>;
1705
1706
  alias: z.ZodOptional<z.ZodString>;
1706
- default: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1707
+ default: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1707
1708
  project: z.ZodOptional<z.ZodString>;
1708
- enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1709
+ enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1709
1710
  external_id: z.ZodOptional<z.ZodString>;
1710
1711
  }, z.core.$strip>>;
1711
1712
  type IntegrationUpdateParams = Omit<z.infer<typeof IntegrationUpdateParamsSchema>, "default" | "enabled"> & {
@@ -2351,8 +2352,8 @@ interface WorkflowExecutionStateOutput {
2351
2352
  * Workflow list parameters schema
2352
2353
  */
2353
2354
  declare const WorkflowListParamsSchema: z.ZodReadonly<z.ZodObject<{
2354
- page: z.ZodPrefault<z.ZodNumber>;
2355
- per_page: z.ZodPrefault<z.ZodNumber>;
2355
+ page: z.ZodDefault<z.ZodNumber>;
2356
+ per_page: z.ZodDefault<z.ZodNumber>;
2356
2357
  projects: z.ZodOptional<z.ZodArray<z.ZodString>>;
2357
2358
  search: z.ZodOptional<z.ZodString>;
2358
2359
  }, z.core.$strip>>;
@@ -2393,8 +2394,8 @@ type WorkflowUpdateParams = z.infer<typeof WorkflowUpdateParamsSchema>;
2393
2394
  * Workflow execution list parameters schema
2394
2395
  */
2395
2396
  declare const WorkflowExecutionListParamsSchema: z.ZodReadonly<z.ZodObject<{
2396
- page: z.ZodPrefault<z.ZodNumber>;
2397
- per_page: z.ZodPrefault<z.ZodNumber>;
2397
+ page: z.ZodDefault<z.ZodNumber>;
2398
+ per_page: z.ZodDefault<z.ZodNumber>;
2398
2399
  }, z.core.$strip>>;
2399
2400
  type WorkflowExecutionListParams = Partial<z.infer<typeof WorkflowExecutionListParamsSchema>>;
2400
2401
  /**
@@ -2412,8 +2413,8 @@ type WorkflowExecutionCreateParams = z.infer<typeof WorkflowExecutionCreateParam
2412
2413
  * Workflow execution state list parameters schema
2413
2414
  */
2414
2415
  declare const WorkflowExecutionStateListParamsSchema: z.ZodReadonly<z.ZodObject<{
2415
- page: z.ZodPrefault<z.ZodNumber>;
2416
- per_page: z.ZodPrefault<z.ZodNumber>;
2416
+ page: z.ZodDefault<z.ZodNumber>;
2417
+ per_page: z.ZodDefault<z.ZodNumber>;
2417
2418
  }, z.core.$strip>>;
2418
2419
  type WorkflowExecutionStateListParams = Partial<z.infer<typeof WorkflowExecutionStateListParamsSchema>>;
2419
2420
 
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ interface AuthConfig {
37
37
  token?: string | null;
38
38
  verifySSL?: boolean;
39
39
  cookies?: Record<string, string>;
40
+ tokenGetter?: (() => Promise<string>) | null;
40
41
  }
41
42
 
42
43
  interface ResponseMetadata {
@@ -573,13 +574,13 @@ interface AssistantUpdateResponse {
573
574
  }
574
575
 
575
576
  declare const AssistantListParamsSchema: z.ZodReadonly<z.ZodObject<{
576
- minimal_response: z.ZodPrefault<z.ZodBoolean>;
577
- scope: z.ZodPrefault<z.ZodEnum<{
577
+ minimal_response: z.ZodDefault<z.ZodBoolean>;
578
+ scope: z.ZodDefault<z.ZodEnum<{
578
579
  marketplace: "marketplace";
579
580
  visible_to_user: "visible_to_user";
580
581
  }>>;
581
- page: z.ZodPrefault<z.ZodNumber>;
582
- per_page: z.ZodPrefault<z.ZodNumber>;
582
+ page: z.ZodDefault<z.ZodNumber>;
583
+ per_page: z.ZodDefault<z.ZodNumber>;
583
584
  filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
584
585
  }, z.core.$strip>>;
585
586
  type AssistantListParams = Partial<z.infer<typeof AssistantListParamsSchema>>;
@@ -637,13 +638,13 @@ declare const AssistantCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
637
638
  mcp_connect_auth_token: z.ZodOptional<z.ZodAny>;
638
639
  }, z.core.$strip>>;
639
640
  assistant_ids: z.ZodArray<z.ZodString>;
640
- prompt_variables: z.ZodPrefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
641
+ prompt_variables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
641
642
  key: z.ZodString;
642
643
  description: z.ZodOptional<z.ZodString>;
643
644
  default_value: z.ZodString;
644
645
  }, z.core.$strip>>>>;
645
646
  categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
646
- skip_integration_validation: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
647
+ skip_integration_validation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
647
648
  }, z.core.$strip>>;
648
649
  type AssistantCreateParams = z.input<typeof AssistantCreateParamsSchema>;
649
650
  declare const AssistantUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
@@ -700,13 +701,13 @@ declare const AssistantUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
700
701
  mcp_connect_auth_token: z.ZodOptional<z.ZodAny>;
701
702
  }, z.core.$strip>>;
702
703
  assistant_ids: z.ZodArray<z.ZodString>;
703
- prompt_variables: z.ZodPrefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
704
+ prompt_variables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
704
705
  key: z.ZodString;
705
706
  description: z.ZodOptional<z.ZodString>;
706
707
  default_value: z.ZodString;
707
708
  }, z.core.$strip>>>>;
708
709
  categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
709
- skip_integration_validation: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
710
+ skip_integration_validation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
710
711
  }, z.core.$strip>>;
711
712
  type AssistantUpdateParams = z.input<typeof AssistantUpdateParamsSchema>;
712
713
  declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
@@ -951,9 +952,9 @@ interface ConversationCreateRequest {
951
952
  declare const ConversationCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
952
953
  initial_assistant_id: z.ZodOptional<z.ZodString>;
953
954
  folder: z.ZodOptional<z.ZodString>;
954
- mcp_server_single_usage: z.ZodOptional<z.ZodPrefault<z.ZodBoolean>>;
955
+ mcp_server_single_usage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
955
956
  }, z.core.$strip>>;
956
- type ConversationCreateParams = z.infer<typeof ConversationCreateParamsSchema>;
957
+ type ConversationCreateParams = z.input<typeof ConversationCreateParamsSchema>;
957
958
 
958
959
  declare class ConversationService {
959
960
  private api;
@@ -1639,18 +1640,18 @@ declare class FileService {
1639
1640
  }
1640
1641
 
1641
1642
  declare const IntegrationListParamsSchema: z.ZodReadonly<z.ZodObject<{
1642
- setting_type: z.ZodPrefault<z.ZodEnum<{
1643
+ setting_type: z.ZodDefault<z.ZodEnum<{
1643
1644
  user: "user";
1644
1645
  project: "project";
1645
1646
  }>>;
1646
- page: z.ZodPrefault<z.ZodNumber>;
1647
- per_page: z.ZodPrefault<z.ZodNumber>;
1647
+ page: z.ZodDefault<z.ZodNumber>;
1648
+ per_page: z.ZodDefault<z.ZodNumber>;
1648
1649
  filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1649
1650
  }, z.core.$strip>>;
1650
1651
  type IntegrationListParams = Partial<z.infer<typeof IntegrationListParamsSchema>>;
1651
1652
  declare const IntegrationGetParamsSchema: z.ZodReadonly<z.ZodObject<{
1652
1653
  integration_id: z.ZodString;
1653
- setting_type: z.ZodPrefault<z.ZodEnum<{
1654
+ setting_type: z.ZodDefault<z.ZodEnum<{
1654
1655
  user: "user";
1655
1656
  project: "project";
1656
1657
  }>>;
@@ -1658,7 +1659,7 @@ declare const IntegrationGetParamsSchema: z.ZodReadonly<z.ZodObject<{
1658
1659
  type IntegrationGetParams = z.infer<typeof IntegrationGetParamsSchema>;
1659
1660
  declare const IntegrationGetByAliasParamsSchema: z.ZodReadonly<z.ZodObject<{
1660
1661
  alias: z.ZodString;
1661
- setting_type: z.ZodPrefault<z.ZodEnum<{
1662
+ setting_type: z.ZodDefault<z.ZodEnum<{
1662
1663
  user: "user";
1663
1664
  project: "project";
1664
1665
  }>>;
@@ -1675,14 +1676,14 @@ declare const IntegrationCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
1675
1676
  value: z.ZodUnknown;
1676
1677
  }, z.core.$strip>>;
1677
1678
  project_name: z.ZodString;
1678
- setting_type: z.ZodPrefault<z.ZodEnum<{
1679
+ setting_type: z.ZodDefault<z.ZodEnum<{
1679
1680
  user: "user";
1680
1681
  project: "project";
1681
1682
  }>>;
1682
1683
  alias: z.ZodOptional<z.ZodString>;
1683
- default: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1684
+ default: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1684
1685
  project: z.ZodOptional<z.ZodString>;
1685
- enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1686
+ enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1686
1687
  external_id: z.ZodOptional<z.ZodString>;
1687
1688
  }, z.core.$strip>>;
1688
1689
  type IntegrationCreateParams = Omit<z.infer<typeof IntegrationCreateParamsSchema>, "default" | "enabled"> & {
@@ -1698,14 +1699,14 @@ declare const IntegrationUpdateParamsSchema: z.ZodReadonly<z.ZodObject<{
1698
1699
  value: z.ZodUnknown;
1699
1700
  }, z.core.$strip>>;
1700
1701
  project_name: z.ZodString;
1701
- setting_type: z.ZodPrefault<z.ZodEnum<{
1702
+ setting_type: z.ZodDefault<z.ZodEnum<{
1702
1703
  user: "user";
1703
1704
  project: "project";
1704
1705
  }>>;
1705
1706
  alias: z.ZodOptional<z.ZodString>;
1706
- default: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1707
+ default: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1707
1708
  project: z.ZodOptional<z.ZodString>;
1708
- enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
1709
+ enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1709
1710
  external_id: z.ZodOptional<z.ZodString>;
1710
1711
  }, z.core.$strip>>;
1711
1712
  type IntegrationUpdateParams = Omit<z.infer<typeof IntegrationUpdateParamsSchema>, "default" | "enabled"> & {
@@ -2351,8 +2352,8 @@ interface WorkflowExecutionStateOutput {
2351
2352
  * Workflow list parameters schema
2352
2353
  */
2353
2354
  declare const WorkflowListParamsSchema: z.ZodReadonly<z.ZodObject<{
2354
- page: z.ZodPrefault<z.ZodNumber>;
2355
- per_page: z.ZodPrefault<z.ZodNumber>;
2355
+ page: z.ZodDefault<z.ZodNumber>;
2356
+ per_page: z.ZodDefault<z.ZodNumber>;
2356
2357
  projects: z.ZodOptional<z.ZodArray<z.ZodString>>;
2357
2358
  search: z.ZodOptional<z.ZodString>;
2358
2359
  }, z.core.$strip>>;
@@ -2393,8 +2394,8 @@ type WorkflowUpdateParams = z.infer<typeof WorkflowUpdateParamsSchema>;
2393
2394
  * Workflow execution list parameters schema
2394
2395
  */
2395
2396
  declare const WorkflowExecutionListParamsSchema: z.ZodReadonly<z.ZodObject<{
2396
- page: z.ZodPrefault<z.ZodNumber>;
2397
- per_page: z.ZodPrefault<z.ZodNumber>;
2397
+ page: z.ZodDefault<z.ZodNumber>;
2398
+ per_page: z.ZodDefault<z.ZodNumber>;
2398
2399
  }, z.core.$strip>>;
2399
2400
  type WorkflowExecutionListParams = Partial<z.infer<typeof WorkflowExecutionListParamsSchema>>;
2400
2401
  /**
@@ -2412,8 +2413,8 @@ type WorkflowExecutionCreateParams = z.infer<typeof WorkflowExecutionCreateParam
2412
2413
  * Workflow execution state list parameters schema
2413
2414
  */
2414
2415
  declare const WorkflowExecutionStateListParamsSchema: z.ZodReadonly<z.ZodObject<{
2415
- page: z.ZodPrefault<z.ZodNumber>;
2416
- per_page: z.ZodPrefault<z.ZodNumber>;
2416
+ page: z.ZodDefault<z.ZodNumber>;
2417
+ per_page: z.ZodDefault<z.ZodNumber>;
2417
2418
  }, z.core.$strip>>;
2418
2419
  type WorkflowExecutionStateListParams = Partial<z.infer<typeof WorkflowExecutionStateListParamsSchema>>;
2419
2420
 
package/dist/index.js CHANGED
@@ -2,8 +2,10 @@
2
2
  import { Agent } from "https";
3
3
  import axios from "axios";
4
4
  var DEFAULT_CLIENT_ID = "codemie-sdk";
5
- var KeycloakCredentials = class {
5
+ var _KeycloakCredentials = class _KeycloakCredentials {
6
6
  constructor(config) {
7
+ this.cachedToken = null;
8
+ this.tokenExpiresAt = 0;
7
9
  this.validateConfigCredentials(config);
8
10
  this.config = config;
9
11
  this.httpAgent = new Agent({
@@ -11,11 +13,17 @@ var KeycloakCredentials = class {
11
13
  });
12
14
  }
13
15
  async getToken() {
16
+ const now = Date.now();
17
+ if (this.cachedToken && now < this.tokenExpiresAt) {
18
+ return this.cachedToken;
19
+ }
14
20
  const { serverUrl, realmName } = this.config;
15
21
  const url = `${serverUrl}/realms/${realmName}/protocol/openid-connect/token`;
16
22
  let payload;
17
23
  if (this.config.externalToken && this.config.externalIdp) {
18
- payload = this.createTokenExchangePayload();
24
+ const raw = this.config.externalToken;
25
+ const subjectToken = typeof raw === "function" ? await raw() : raw;
26
+ payload = this.createTokenExchangePayload(subjectToken);
19
27
  } else if (this.config.username && this.config.password) {
20
28
  payload = this.createResourceOwnerCredentialsPayload();
21
29
  } else {
@@ -25,15 +33,23 @@ var KeycloakCredentials = class {
25
33
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
26
34
  httpsAgent: this.httpAgent
27
35
  });
28
- return data.access_token;
36
+ this.cachedToken = data.access_token;
37
+ const expiresIn = data.expires_in ?? 300;
38
+ this.tokenExpiresAt = now + expiresIn * 1e3 - _KeycloakCredentials.TOKEN_EXPIRY_BUFFER_MS;
39
+ return this.cachedToken;
40
+ }
41
+ clearCache() {
42
+ this.cachedToken = null;
43
+ this.tokenExpiresAt = 0;
29
44
  }
30
- createTokenExchangePayload() {
31
- const { clientId, clientSecret, externalToken, externalIdp } = this.config;
45
+ createTokenExchangePayload(subjectToken) {
46
+ const { clientId, clientSecret, externalIdp } = this.config;
32
47
  return {
33
48
  grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
34
49
  client_id: clientId || DEFAULT_CLIENT_ID,
35
50
  client_secret: clientSecret,
36
- subject_token: externalToken,
51
+ subject_token: subjectToken,
52
+ subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
37
53
  subject_issuer: externalIdp,
38
54
  requested_token_type: "urn:ietf:params:oauth:token-type:access_token"
39
55
  };
@@ -71,6 +87,8 @@ var KeycloakCredentials = class {
71
87
  }
72
88
  }
73
89
  };
90
+ _KeycloakCredentials.TOKEN_EXPIRY_BUFFER_MS = 3e4;
91
+ var KeycloakCredentials = _KeycloakCredentials;
74
92
 
75
93
  // src/schemas/analytics.ts
76
94
  import { z } from "zod";
@@ -129,7 +147,7 @@ function formatCookies(cookies) {
129
147
  }
130
148
  var ApiRequestHandler = class {
131
149
  constructor(config) {
132
- const { apiDomain, token, verifySSL = true, cookies = {} } = config;
150
+ const { apiDomain, token, verifySSL = true, cookies = {}, tokenGetter } = config;
133
151
  const headers = {
134
152
  "Content-Type": "application/json"
135
153
  };
@@ -151,6 +169,13 @@ var ApiRequestHandler = class {
151
169
  (response) => response,
152
170
  (error) => this.processFailedResponse(error)
153
171
  );
172
+ if (tokenGetter) {
173
+ this.client.interceptors.request.use(async (requestConfig) => {
174
+ const freshToken = await tokenGetter();
175
+ requestConfig.headers.Authorization = `Bearer ${freshToken}`;
176
+ return requestConfig;
177
+ });
178
+ }
154
179
  }
155
180
  async request(method, path, config = {}) {
156
181
  const response = await this.client.request({
@@ -334,10 +359,10 @@ import { z as z3 } from "zod";
334
359
  // src/schemas/assistant.ts
335
360
  import { z as z2 } from "zod";
336
361
  var AssistantListParamsSchema = z2.object({
337
- minimal_response: z2.boolean().prefault(true),
338
- scope: z2.enum(["visible_to_user", "marketplace"]).prefault("visible_to_user"),
339
- page: z2.number().prefault(0),
340
- per_page: z2.number().prefault(12),
362
+ minimal_response: z2.boolean().default(true),
363
+ scope: z2.enum(["visible_to_user", "marketplace"]).default("visible_to_user"),
364
+ page: z2.number().default(0),
365
+ per_page: z2.number().default(12),
341
366
  filters: z2.record(z2.string(), z2.unknown()).optional()
342
367
  }).readonly();
343
368
  var PromptVariableSchema = z2.object({
@@ -403,9 +428,7 @@ var AssistantCreateParamsSchema = z2.object({
403
428
  const hasCommand = !!config.command;
404
429
  return hasUrl !== hasCommand;
405
430
  },
406
- {
407
- error: "Either 'url' or 'command' must be provided in config, but not both"
408
- }
431
+ "Either 'url' or 'command' must be provided in config, but not both"
409
432
  ),
410
433
  mcp_connect_url: z2.string().optional(),
411
434
  tools_tokens_size_limit: z2.number().optional(),
@@ -416,9 +439,9 @@ var AssistantCreateParamsSchema = z2.object({
416
439
  })
417
440
  ),
418
441
  assistant_ids: z2.array(z2.string()),
419
- prompt_variables: z2.array(PromptVariableSchema).optional().prefault([]),
442
+ prompt_variables: z2.array(PromptVariableSchema).optional().default([]),
420
443
  categories: z2.array(z2.string()).max(3).optional(),
421
- skip_integration_validation: z2.boolean().optional().prefault(false)
444
+ skip_integration_validation: z2.boolean().optional().default(false)
422
445
  }).readonly();
423
446
  var AssistantUpdateParamsSchema = AssistantCreateParamsSchema;
424
447
  var AssistantChatParamsSchema = z2.object({
@@ -468,7 +491,7 @@ var AssistantService = class {
468
491
  "/v1/assistants",
469
492
  {
470
493
  ...params,
471
- ...params.filters && { filters: JSON.stringify(params.filters) }
494
+ ...params.filters ? { filters: JSON.stringify(params.filters) } : {}
472
495
  }
473
496
  );
474
497
  return response.data;
@@ -482,7 +505,7 @@ var AssistantService = class {
482
505
  "/v1/assistants",
483
506
  {
484
507
  ...params,
485
- ...params.filters && { filters: JSON.stringify(params.filters) }
508
+ ...params.filters ? { filters: JSON.stringify(params.filters) } : {}
486
509
  }
487
510
  );
488
511
  return response;
@@ -676,7 +699,7 @@ import { z as z4 } from "zod";
676
699
  var ConversationCreateParamsSchema = z4.object({
677
700
  initial_assistant_id: z4.string().optional(),
678
701
  folder: z4.string().optional(),
679
- mcp_server_single_usage: z4.boolean().prefault(false).optional()
702
+ mcp_server_single_usage: z4.boolean().optional().default(false)
680
703
  }).readonly();
681
704
 
682
705
  // src/services/conversation.ts
@@ -1232,18 +1255,18 @@ var IntegrationType = {
1232
1255
  // src/schemas/integration.ts
1233
1256
  import { z as z5 } from "zod";
1234
1257
  var IntegrationListParamsSchema = z5.object({
1235
- setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).prefault(IntegrationType.USER),
1236
- page: z5.number().prefault(0),
1237
- per_page: z5.number().prefault(10),
1258
+ setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER),
1259
+ page: z5.number().default(0),
1260
+ per_page: z5.number().default(10),
1238
1261
  filters: z5.record(z5.string(), z5.unknown()).optional()
1239
1262
  }).readonly();
1240
1263
  var IntegrationGetParamsSchema = z5.object({
1241
1264
  integration_id: z5.string(),
1242
- setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).prefault(IntegrationType.USER)
1265
+ setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER)
1243
1266
  }).readonly();
1244
1267
  var IntegrationGetByAliasParamsSchema = z5.object({
1245
1268
  alias: z5.string(),
1246
- setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).prefault(IntegrationType.USER)
1269
+ setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER)
1247
1270
  }).readonly();
1248
1271
  var CredentialValueSchema = z5.object({
1249
1272
  key: z5.string(),
@@ -1253,11 +1276,11 @@ var IntegrationCreateParamsSchema = z5.object({
1253
1276
  credential_type: z5.enum(Object.values(CredentialTypes)),
1254
1277
  credential_values: z5.array(CredentialValueSchema),
1255
1278
  project_name: z5.string(),
1256
- setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).prefault(IntegrationType.USER),
1279
+ setting_type: z5.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER),
1257
1280
  alias: z5.string().optional(),
1258
- default: z5.boolean().optional().prefault(false),
1281
+ default: z5.boolean().optional().default(false),
1259
1282
  project: z5.string().optional(),
1260
- enabled: z5.boolean().optional().prefault(true),
1283
+ enabled: z5.boolean().optional().default(true),
1261
1284
  external_id: z5.string().optional()
1262
1285
  }).readonly();
1263
1286
  var IntegrationUpdateParamsSchema = IntegrationCreateParamsSchema;
@@ -1282,7 +1305,7 @@ var IntegrationService = class {
1282
1305
  const queryParams = {
1283
1306
  page: params.page,
1284
1307
  per_page: params.per_page,
1285
- ...params.filters && { filters: JSON.stringify(params.filters) }
1308
+ ...params.filters ? { filters: JSON.stringify(params.filters) } : {}
1286
1309
  };
1287
1310
  const response = await this.api.get(
1288
1311
  this.getBasePath(settingType),
@@ -1727,8 +1750,8 @@ var ExecutionStatus = {
1727
1750
 
1728
1751
  // src/schemas/workflow.ts
1729
1752
  var WorkflowListParamsSchema = z7.object({
1730
- page: z7.number().prefault(0),
1731
- per_page: z7.number().prefault(10),
1753
+ page: z7.number().default(0),
1754
+ per_page: z7.number().default(10),
1732
1755
  projects: z7.array(z7.string()).optional(),
1733
1756
  search: z7.string().optional()
1734
1757
  }).readonly();
@@ -1751,8 +1774,8 @@ var WorkflowUpdateParamsSchema = z7.object({
1751
1774
  icon_url: z7.string().optional()
1752
1775
  }).readonly();
1753
1776
  var WorkflowExecutionListParamsSchema = z7.object({
1754
- page: z7.number().prefault(0),
1755
- per_page: z7.number().prefault(10)
1777
+ page: z7.number().default(0),
1778
+ per_page: z7.number().default(10)
1756
1779
  }).readonly();
1757
1780
  var WorkflowExecutionCreateParamsSchema = z7.object({
1758
1781
  user_input: z7.union([
@@ -1768,8 +1791,8 @@ var WorkflowExecutionCreateParamsSchema = z7.object({
1768
1791
  tags: z7.array(z7.string()).optional()
1769
1792
  }).readonly();
1770
1793
  var WorkflowExecutionStateListParamsSchema = z7.object({
1771
- page: z7.number().prefault(0),
1772
- per_page: z7.number().prefault(10)
1794
+ page: z7.number().default(0),
1795
+ per_page: z7.number().default(10)
1773
1796
  }).readonly();
1774
1797
 
1775
1798
  // src/services/workflow_execution_state.ts
@@ -2004,7 +2027,9 @@ var CodeMieClient = class {
2004
2027
  apiDomain: this.apiDomain,
2005
2028
  token: this.token,
2006
2029
  verifySSL: this.verifySSL,
2007
- cookies: this.cookies
2030
+ cookies: this.cookies,
2031
+ // biome-ignore lint/style/noNonNullAssertion: auth is non-null here, guarded by ternary
2032
+ tokenGetter: this.auth ? () => this.auth.getToken() : null
2008
2033
  };
2009
2034
  this._analytics = new AnalyticsService(authConfig);
2010
2035
  this._assistants = new AssistantService(authConfig);
@@ -2134,6 +2159,7 @@ var CodeMieClient = class {
2134
2159
  if (!this.auth) {
2135
2160
  throw new Error("Authentication not configured");
2136
2161
  }
2162
+ this.auth.clearCache();
2137
2163
  this.token = await this.auth.getToken();
2138
2164
  await this.refreshServices();
2139
2165
  return this.token;
@@ -2152,7 +2178,9 @@ var CodeMieClient = class {
2152
2178
  apiDomain: this.apiDomain,
2153
2179
  token: this.token,
2154
2180
  verifySSL: this.verifySSL,
2155
- cookies: this.cookies
2181
+ cookies: this.cookies,
2182
+ // biome-ignore lint/style/noNonNullAssertion: auth is non-null here, guarded by ternary
2183
+ tokenGetter: this.auth ? () => this.auth.getToken() : null
2156
2184
  };
2157
2185
  this._analytics = new AnalyticsService(authConfig);
2158
2186
  this._assistants = new AssistantService(authConfig);