@discomedia/utils 1.0.71 → 1.0.74

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.
@@ -5,6 +5,7 @@ const OPENAI_MODELS = [
5
5
  'gpt-5',
6
6
  'gpt-5-mini',
7
7
  'gpt-5.4-mini',
8
+ 'gpt-5.4-nano',
8
9
  'gpt-5-nano',
9
10
  'gpt-5.1',
10
11
  'gpt-5.4',
@@ -47,6 +48,7 @@ const OPENROUTER_MODELS = [
47
48
  'openai/gpt-5',
48
49
  'openai/gpt-5-mini',
49
50
  'openai/gpt-5.4-mini',
51
+ 'openai/gpt-5.4-nano',
50
52
  'openai/gpt-5-nano',
51
53
  'openai/gpt-5.1',
52
54
  'openai/gpt-5.4',
@@ -344,7 +346,7 @@ const safeJSON = (text) => {
344
346
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
345
347
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
346
348
 
347
- const VERSION = '6.37.0'; // x-release-please-version
349
+ const VERSION = '6.39.0'; // x-release-please-version
348
350
 
349
351
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
350
352
  const isRunningInBrowser = () => {
@@ -1793,19 +1795,22 @@ class WorkloadIdentityAuth {
1793
1795
  }
1794
1796
  async refreshToken() {
1795
1797
  const subjectToken = await this.config.provider.getToken();
1798
+ const body = {
1799
+ grant_type: TOKEN_EXCHANGE_GRANT_TYPE,
1800
+ subject_token: subjectToken,
1801
+ subject_token_type: SUBJECT_TOKEN_TYPES[this.config.provider.tokenType],
1802
+ identity_provider_id: this.config.identityProviderId,
1803
+ service_account_id: this.config.serviceAccountId,
1804
+ };
1805
+ if (this.config.clientId) {
1806
+ body['client_id'] = this.config.clientId;
1807
+ }
1796
1808
  const response = await this.fetch(this.tokenExchangeUrl, {
1797
1809
  method: 'POST',
1798
1810
  headers: {
1799
1811
  'Content-Type': 'application/json',
1800
1812
  },
1801
- body: JSON.stringify({
1802
- grant_type: TOKEN_EXCHANGE_GRANT_TYPE,
1803
- client_id: this.config.clientId,
1804
- subject_token: subjectToken,
1805
- subject_token_type: SUBJECT_TOKEN_TYPES[this.config.provider.tokenType],
1806
- identity_provider_id: this.config.identityProviderId,
1807
- service_account_id: this.config.serviceAccountId,
1808
- }),
1813
+ body: JSON.stringify(body),
1809
1814
  });
1810
1815
  if (!response.ok) {
1811
1816
  const errorText = await response.text();
@@ -3877,6 +3882,43 @@ let Certificates$1 = class Certificates extends APIResource {
3877
3882
  }
3878
3883
  };
3879
3884
 
3885
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3886
+ let DataRetention$1 = class DataRetention extends APIResource {
3887
+ /**
3888
+ * Retrieves organization data retention controls.
3889
+ *
3890
+ * @example
3891
+ * ```ts
3892
+ * const organizationDataRetention =
3893
+ * await client.admin.organization.dataRetention.retrieve();
3894
+ * ```
3895
+ */
3896
+ retrieve(options) {
3897
+ return this._client.get('/organization/data_retention', {
3898
+ ...options,
3899
+ __security: { adminAPIKeyAuth: true },
3900
+ });
3901
+ }
3902
+ /**
3903
+ * Updates organization data retention controls.
3904
+ *
3905
+ * @example
3906
+ * ```ts
3907
+ * const organizationDataRetention =
3908
+ * await client.admin.organization.dataRetention.update({
3909
+ * retention_type: 'zero_data_retention',
3910
+ * });
3911
+ * ```
3912
+ */
3913
+ update(body, options) {
3914
+ return this._client.post('/organization/data_retention', {
3915
+ body,
3916
+ ...options,
3917
+ __security: { adminAPIKeyAuth: true },
3918
+ });
3919
+ }
3920
+ };
3921
+
3880
3922
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3881
3923
  class Invites extends APIResource {
3882
3924
  /**
@@ -3973,6 +4015,22 @@ let Roles$5 = class Roles extends APIResource {
3973
4015
  __security: { adminAPIKeyAuth: true },
3974
4016
  });
3975
4017
  }
4018
+ /**
4019
+ * Retrieves an organization role.
4020
+ *
4021
+ * @example
4022
+ * ```ts
4023
+ * const role = await client.admin.organization.roles.retrieve(
4024
+ * 'role_id',
4025
+ * );
4026
+ * ```
4027
+ */
4028
+ retrieve(roleID, options) {
4029
+ return this._client.get(path `/organization/roles/${roleID}`, {
4030
+ ...options,
4031
+ __security: { adminAPIKeyAuth: true },
4032
+ });
4033
+ }
3976
4034
  /**
3977
4035
  * Updates an existing organization role.
3978
4036
  *
@@ -4026,6 +4084,92 @@ let Roles$5 = class Roles extends APIResource {
4026
4084
  }
4027
4085
  };
4028
4086
 
4087
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4088
+ let SpendAlerts$1 = class SpendAlerts extends APIResource {
4089
+ /**
4090
+ * Creates an organization spend alert.
4091
+ *
4092
+ * @example
4093
+ * ```ts
4094
+ * const organizationSpendAlert =
4095
+ * await client.admin.organization.spendAlerts.create({
4096
+ * currency: 'USD',
4097
+ * interval: 'month',
4098
+ * notification_channel: {
4099
+ * recipients: ['string'],
4100
+ * type: 'email',
4101
+ * },
4102
+ * threshold_amount: 0,
4103
+ * });
4104
+ * ```
4105
+ */
4106
+ create(body, options) {
4107
+ return this._client.post('/organization/spend_alerts', {
4108
+ body,
4109
+ ...options,
4110
+ __security: { adminAPIKeyAuth: true },
4111
+ });
4112
+ }
4113
+ /**
4114
+ * Updates an organization spend alert.
4115
+ *
4116
+ * @example
4117
+ * ```ts
4118
+ * const organizationSpendAlert =
4119
+ * await client.admin.organization.spendAlerts.update(
4120
+ * 'alert_id',
4121
+ * {
4122
+ * currency: 'USD',
4123
+ * interval: 'month',
4124
+ * notification_channel: {
4125
+ * recipients: ['string'],
4126
+ * type: 'email',
4127
+ * },
4128
+ * threshold_amount: 0,
4129
+ * },
4130
+ * );
4131
+ * ```
4132
+ */
4133
+ update(alertID, body, options) {
4134
+ return this._client.post(path `/organization/spend_alerts/${alertID}`, {
4135
+ body,
4136
+ ...options,
4137
+ __security: { adminAPIKeyAuth: true },
4138
+ });
4139
+ }
4140
+ /**
4141
+ * Lists organization spend alerts.
4142
+ *
4143
+ * @example
4144
+ * ```ts
4145
+ * // Automatically fetches more pages as needed.
4146
+ * for await (const organizationSpendAlert of client.admin.organization.spendAlerts.list()) {
4147
+ * // ...
4148
+ * }
4149
+ * ```
4150
+ */
4151
+ list(query = {}, options) {
4152
+ return this._client.getAPIList('/organization/spend_alerts', (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
4153
+ }
4154
+ /**
4155
+ * Deletes an organization spend alert.
4156
+ *
4157
+ * @example
4158
+ * ```ts
4159
+ * const organizationSpendAlertDeleted =
4160
+ * await client.admin.organization.spendAlerts.delete(
4161
+ * 'alert_id',
4162
+ * );
4163
+ * ```
4164
+ */
4165
+ delete(alertID, options) {
4166
+ return this._client.delete(path `/organization/spend_alerts/${alertID}`, {
4167
+ ...options,
4168
+ __security: { adminAPIKeyAuth: true },
4169
+ });
4170
+ }
4171
+ };
4172
+
4029
4173
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4030
4174
  class Usage extends APIResource {
4031
4175
  /**
@@ -4136,6 +4280,24 @@ class Usage extends APIResource {
4136
4280
  __security: { adminAPIKeyAuth: true },
4137
4281
  });
4138
4282
  }
4283
+ /**
4284
+ * Get file search calls usage details for the organization.
4285
+ *
4286
+ * @example
4287
+ * ```ts
4288
+ * const response =
4289
+ * await client.admin.organization.usage.fileSearchCalls({
4290
+ * start_time: 0,
4291
+ * });
4292
+ * ```
4293
+ */
4294
+ fileSearchCalls(query, options) {
4295
+ return this._client.get('/organization/usage/file_search_calls', {
4296
+ query,
4297
+ ...options,
4298
+ __security: { adminAPIKeyAuth: true },
4299
+ });
4300
+ }
4139
4301
  /**
4140
4302
  * Get images usage details for the organization.
4141
4303
  *
@@ -4190,6 +4352,24 @@ class Usage extends APIResource {
4190
4352
  __security: { adminAPIKeyAuth: true },
4191
4353
  });
4192
4354
  }
4355
+ /**
4356
+ * Get web search calls usage details for the organization.
4357
+ *
4358
+ * @example
4359
+ * ```ts
4360
+ * const response =
4361
+ * await client.admin.organization.usage.webSearchCalls({
4362
+ * start_time: 0,
4363
+ * });
4364
+ * ```
4365
+ */
4366
+ webSearchCalls(query, options) {
4367
+ return this._client.get('/organization/usage/web_search_calls', {
4368
+ query,
4369
+ ...options,
4370
+ __security: { adminAPIKeyAuth: true },
4371
+ });
4372
+ }
4193
4373
  }
4194
4374
 
4195
4375
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
@@ -4213,6 +4393,25 @@ let Roles$4 = class Roles extends APIResource {
4213
4393
  __security: { adminAPIKeyAuth: true },
4214
4394
  });
4215
4395
  }
4396
+ /**
4397
+ * Retrieves an organization role assigned to a group.
4398
+ *
4399
+ * @example
4400
+ * ```ts
4401
+ * const role =
4402
+ * await client.admin.organization.groups.roles.retrieve(
4403
+ * 'role_id',
4404
+ * { group_id: 'group_id' },
4405
+ * );
4406
+ * ```
4407
+ */
4408
+ retrieve(roleID, params, options) {
4409
+ const { group_id } = params;
4410
+ return this._client.get(path `/organization/groups/${group_id}/roles/${roleID}`, {
4411
+ ...options,
4412
+ __security: { adminAPIKeyAuth: true },
4413
+ });
4414
+ }
4216
4415
  /**
4217
4416
  * Lists the organization roles assigned to a group within the organization.
4218
4417
  *
@@ -4271,6 +4470,25 @@ let Users$2 = class Users extends APIResource {
4271
4470
  __security: { adminAPIKeyAuth: true },
4272
4471
  });
4273
4472
  }
4473
+ /**
4474
+ * Retrieves a user in a group.
4475
+ *
4476
+ * @example
4477
+ * ```ts
4478
+ * const user =
4479
+ * await client.admin.organization.groups.users.retrieve(
4480
+ * 'user_id',
4481
+ * { group_id: 'group_id' },
4482
+ * );
4483
+ * ```
4484
+ */
4485
+ retrieve(userID, params, options) {
4486
+ const { group_id } = params;
4487
+ return this._client.get(path `/organization/groups/${group_id}/users/${userID}`, {
4488
+ ...options,
4489
+ __security: { adminAPIKeyAuth: true },
4490
+ });
4491
+ }
4274
4492
  /**
4275
4493
  * Lists the users assigned to a group.
4276
4494
  *
@@ -4332,6 +4550,23 @@ let Groups$1 = class Groups extends APIResource {
4332
4550
  __security: { adminAPIKeyAuth: true },
4333
4551
  });
4334
4552
  }
4553
+ /**
4554
+ * Retrieves a group.
4555
+ *
4556
+ * @example
4557
+ * ```ts
4558
+ * const group =
4559
+ * await client.admin.organization.groups.retrieve(
4560
+ * 'group_id',
4561
+ * );
4562
+ * ```
4563
+ */
4564
+ retrieve(groupID, options) {
4565
+ return this._client.get(path `/organization/groups/${groupID}`, {
4566
+ ...options,
4567
+ __security: { adminAPIKeyAuth: true },
4568
+ });
4569
+ }
4335
4570
  /**
4336
4571
  * Updates a group's information.
4337
4572
  *
@@ -4506,6 +4741,142 @@ class Certificates extends APIResource {
4506
4741
  }
4507
4742
  }
4508
4743
 
4744
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4745
+ class DataRetention extends APIResource {
4746
+ /**
4747
+ * Retrieves project data retention controls.
4748
+ *
4749
+ * @example
4750
+ * ```ts
4751
+ * const projectDataRetention =
4752
+ * await client.admin.organization.projects.dataRetention.retrieve(
4753
+ * 'project_id',
4754
+ * );
4755
+ * ```
4756
+ */
4757
+ retrieve(projectID, options) {
4758
+ return this._client.get(path `/organization/projects/${projectID}/data_retention`, {
4759
+ ...options,
4760
+ __security: { adminAPIKeyAuth: true },
4761
+ });
4762
+ }
4763
+ /**
4764
+ * Updates project data retention controls.
4765
+ *
4766
+ * @example
4767
+ * ```ts
4768
+ * const projectDataRetention =
4769
+ * await client.admin.organization.projects.dataRetention.update(
4770
+ * 'project_id',
4771
+ * { retention_type: 'organization_default' },
4772
+ * );
4773
+ * ```
4774
+ */
4775
+ update(projectID, body, options) {
4776
+ return this._client.post(path `/organization/projects/${projectID}/data_retention`, {
4777
+ body,
4778
+ ...options,
4779
+ __security: { adminAPIKeyAuth: true },
4780
+ });
4781
+ }
4782
+ }
4783
+
4784
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4785
+ class HostedToolPermissions extends APIResource {
4786
+ /**
4787
+ * Returns hosted tool permissions for a project.
4788
+ *
4789
+ * @example
4790
+ * ```ts
4791
+ * const projectHostedToolPermissions =
4792
+ * await client.admin.organization.projects.hostedToolPermissions.retrieve(
4793
+ * 'project_id',
4794
+ * );
4795
+ * ```
4796
+ */
4797
+ retrieve(projectID, options) {
4798
+ return this._client.get(path `/organization/projects/${projectID}/hosted_tool_permissions`, {
4799
+ ...options,
4800
+ __security: { adminAPIKeyAuth: true },
4801
+ });
4802
+ }
4803
+ /**
4804
+ * Updates hosted tool permissions for a project.
4805
+ *
4806
+ * @example
4807
+ * ```ts
4808
+ * const projectHostedToolPermissions =
4809
+ * await client.admin.organization.projects.hostedToolPermissions.update(
4810
+ * 'project_id',
4811
+ * );
4812
+ * ```
4813
+ */
4814
+ update(projectID, body, options) {
4815
+ return this._client.post(path `/organization/projects/${projectID}/hosted_tool_permissions`, {
4816
+ body,
4817
+ ...options,
4818
+ __security: { adminAPIKeyAuth: true },
4819
+ });
4820
+ }
4821
+ }
4822
+
4823
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4824
+ class ModelPermissions extends APIResource {
4825
+ /**
4826
+ * Returns model permissions for a project.
4827
+ *
4828
+ * @example
4829
+ * ```ts
4830
+ * const projectModelPermissions =
4831
+ * await client.admin.organization.projects.modelPermissions.retrieve(
4832
+ * 'project_id',
4833
+ * );
4834
+ * ```
4835
+ */
4836
+ retrieve(projectID, options) {
4837
+ return this._client.get(path `/organization/projects/${projectID}/model_permissions`, {
4838
+ ...options,
4839
+ __security: { adminAPIKeyAuth: true },
4840
+ });
4841
+ }
4842
+ /**
4843
+ * Updates model permissions for a project.
4844
+ *
4845
+ * @example
4846
+ * ```ts
4847
+ * const projectModelPermissions =
4848
+ * await client.admin.organization.projects.modelPermissions.update(
4849
+ * 'project_id',
4850
+ * { mode: 'allow_list', model_ids: ['string'] },
4851
+ * );
4852
+ * ```
4853
+ */
4854
+ update(projectID, body, options) {
4855
+ return this._client.post(path `/organization/projects/${projectID}/model_permissions`, {
4856
+ body,
4857
+ ...options,
4858
+ __security: { adminAPIKeyAuth: true },
4859
+ });
4860
+ }
4861
+ /**
4862
+ * Deletes model permissions for a project.
4863
+ *
4864
+ * @example
4865
+ * ```ts
4866
+ * const projectModelPermissionsDeleted =
4867
+ * await client.admin.organization.projects.modelPermissions.delete(
4868
+ * 'project_id',
4869
+ * );
4870
+ * ```
4871
+ */
4872
+ delete(projectID, options) {
4873
+ return this._client.delete(path `/organization/projects/${projectID}/model_permissions`, {
4874
+ ...options,
4875
+ __security: { adminAPIKeyAuth: true },
4876
+ });
4877
+ }
4878
+ }
4879
+
4509
4880
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4510
4881
  class RateLimits extends APIResource {
4511
4882
  /**
@@ -4567,6 +4938,25 @@ let Roles$3 = class Roles extends APIResource {
4567
4938
  __security: { adminAPIKeyAuth: true },
4568
4939
  });
4569
4940
  }
4941
+ /**
4942
+ * Retrieves a project role.
4943
+ *
4944
+ * @example
4945
+ * ```ts
4946
+ * const role =
4947
+ * await client.admin.organization.projects.roles.retrieve(
4948
+ * 'role_id',
4949
+ * { project_id: 'project_id' },
4950
+ * );
4951
+ * ```
4952
+ */
4953
+ retrieve(roleID, params, options) {
4954
+ const { project_id } = params;
4955
+ return this._client.get(path `/projects/${project_id}/roles/${roleID}`, {
4956
+ ...options,
4957
+ __security: { adminAPIKeyAuth: true },
4958
+ });
4959
+ }
4570
4960
  /**
4571
4961
  * Updates an existing project role.
4572
4962
  *
@@ -4669,6 +5059,22 @@ class ServiceAccounts extends APIResource {
4669
5059
  __security: { adminAPIKeyAuth: true },
4670
5060
  });
4671
5061
  }
5062
+ /**
5063
+ * Updates a service account in the project.
5064
+ *
5065
+ * @example
5066
+ * ```ts
5067
+ * const projectServiceAccount =
5068
+ * await client.admin.organization.projects.serviceAccounts.update(
5069
+ * 'service_account_id',
5070
+ * { project_id: 'project_id' },
5071
+ * );
5072
+ * ```
5073
+ */
5074
+ update(serviceAccountID, params, options) {
5075
+ const { project_id, ...body } = params;
5076
+ return this._client.post(path `/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { body, ...options, __security: { adminAPIKeyAuth: true } });
5077
+ }
4672
5078
  /**
4673
5079
  * Returns a list of service accounts in the project.
4674
5080
  *
@@ -4706,6 +5112,101 @@ class ServiceAccounts extends APIResource {
4706
5112
  }
4707
5113
  }
4708
5114
 
5115
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5116
+ class SpendAlerts extends APIResource {
5117
+ /**
5118
+ * Creates a project spend alert.
5119
+ *
5120
+ * @example
5121
+ * ```ts
5122
+ * const projectSpendAlert =
5123
+ * await client.admin.organization.projects.spendAlerts.create(
5124
+ * 'project_id',
5125
+ * {
5126
+ * currency: 'USD',
5127
+ * interval: 'month',
5128
+ * notification_channel: {
5129
+ * recipients: ['string'],
5130
+ * type: 'email',
5131
+ * },
5132
+ * threshold_amount: 0,
5133
+ * },
5134
+ * );
5135
+ * ```
5136
+ */
5137
+ create(projectID, body, options) {
5138
+ return this._client.post(path `/organization/projects/${projectID}/spend_alerts`, {
5139
+ body,
5140
+ ...options,
5141
+ __security: { adminAPIKeyAuth: true },
5142
+ });
5143
+ }
5144
+ /**
5145
+ * Updates a project spend alert.
5146
+ *
5147
+ * @example
5148
+ * ```ts
5149
+ * const projectSpendAlert =
5150
+ * await client.admin.organization.projects.spendAlerts.update(
5151
+ * 'alert_id',
5152
+ * {
5153
+ * project_id: 'project_id',
5154
+ * currency: 'USD',
5155
+ * interval: 'month',
5156
+ * notification_channel: {
5157
+ * recipients: ['string'],
5158
+ * type: 'email',
5159
+ * },
5160
+ * threshold_amount: 0,
5161
+ * },
5162
+ * );
5163
+ * ```
5164
+ */
5165
+ update(alertID, params, options) {
5166
+ const { project_id, ...body } = params;
5167
+ return this._client.post(path `/organization/projects/${project_id}/spend_alerts/${alertID}`, {
5168
+ body,
5169
+ ...options,
5170
+ __security: { adminAPIKeyAuth: true },
5171
+ });
5172
+ }
5173
+ /**
5174
+ * Lists project spend alerts.
5175
+ *
5176
+ * @example
5177
+ * ```ts
5178
+ * // Automatically fetches more pages as needed.
5179
+ * for await (const projectSpendAlert of client.admin.organization.projects.spendAlerts.list(
5180
+ * 'project_id',
5181
+ * )) {
5182
+ * // ...
5183
+ * }
5184
+ * ```
5185
+ */
5186
+ list(projectID, query = {}, options) {
5187
+ return this._client.getAPIList(path `/organization/projects/${projectID}/spend_alerts`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } });
5188
+ }
5189
+ /**
5190
+ * Deletes a project spend alert.
5191
+ *
5192
+ * @example
5193
+ * ```ts
5194
+ * const projectSpendAlertDeleted =
5195
+ * await client.admin.organization.projects.spendAlerts.delete(
5196
+ * 'alert_id',
5197
+ * { project_id: 'project_id' },
5198
+ * );
5199
+ * ```
5200
+ */
5201
+ delete(alertID, params, options) {
5202
+ const { project_id } = params;
5203
+ return this._client.delete(path `/organization/projects/${project_id}/spend_alerts/${alertID}`, {
5204
+ ...options,
5205
+ __security: { adminAPIKeyAuth: true },
5206
+ });
5207
+ }
5208
+ }
5209
+
4709
5210
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4710
5211
  let Roles$2 = class Roles extends APIResource {
4711
5212
  /**
@@ -4728,6 +5229,25 @@ let Roles$2 = class Roles extends APIResource {
4728
5229
  __security: { adminAPIKeyAuth: true },
4729
5230
  });
4730
5231
  }
5232
+ /**
5233
+ * Retrieves a project role assigned to a group.
5234
+ *
5235
+ * @example
5236
+ * ```ts
5237
+ * const role =
5238
+ * await client.admin.organization.projects.groups.roles.retrieve(
5239
+ * 'role_id',
5240
+ * { project_id: 'project_id', group_id: 'group_id' },
5241
+ * );
5242
+ * ```
5243
+ */
5244
+ retrieve(roleID, params, options) {
5245
+ const { project_id, group_id } = params;
5246
+ return this._client.get(path `/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
5247
+ ...options,
5248
+ __security: { adminAPIKeyAuth: true },
5249
+ });
5250
+ }
4731
5251
  /**
4732
5252
  * Lists the project roles assigned to a group within a project.
4733
5253
  *
@@ -4792,6 +5312,26 @@ class Groups extends APIResource {
4792
5312
  __security: { adminAPIKeyAuth: true },
4793
5313
  });
4794
5314
  }
5315
+ /**
5316
+ * Retrieves a project's group.
5317
+ *
5318
+ * @example
5319
+ * ```ts
5320
+ * const projectGroup =
5321
+ * await client.admin.organization.projects.groups.retrieve(
5322
+ * 'group_id',
5323
+ * { project_id: 'project_id' },
5324
+ * );
5325
+ * ```
5326
+ */
5327
+ retrieve(groupID, params, options) {
5328
+ const { project_id, ...query } = params;
5329
+ return this._client.get(path `/organization/projects/${project_id}/groups/${groupID}`, {
5330
+ query,
5331
+ ...options,
5332
+ __security: { adminAPIKeyAuth: true },
5333
+ });
5334
+ }
4795
5335
  /**
4796
5336
  * Lists the groups that have access to a project.
4797
5337
  *
@@ -4852,6 +5392,25 @@ let Roles$1 = class Roles extends APIResource {
4852
5392
  __security: { adminAPIKeyAuth: true },
4853
5393
  });
4854
5394
  }
5395
+ /**
5396
+ * Retrieves a project role assigned to a user.
5397
+ *
5398
+ * @example
5399
+ * ```ts
5400
+ * const role =
5401
+ * await client.admin.organization.projects.users.roles.retrieve(
5402
+ * 'role_id',
5403
+ * { project_id: 'project_id', user_id: 'user_id' },
5404
+ * );
5405
+ * ```
5406
+ */
5407
+ retrieve(roleID, params, options) {
5408
+ const { project_id, user_id } = params;
5409
+ return this._client.get(path `/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
5410
+ ...options,
5411
+ __security: { adminAPIKeyAuth: true },
5412
+ });
5413
+ }
4855
5414
  /**
4856
5415
  * Lists the project roles assigned to a user within a project.
4857
5416
  *
@@ -5005,8 +5564,12 @@ class Projects extends APIResource {
5005
5564
  this.serviceAccounts = new ServiceAccounts(this._client);
5006
5565
  this.apiKeys = new APIKeys(this._client);
5007
5566
  this.rateLimits = new RateLimits(this._client);
5567
+ this.modelPermissions = new ModelPermissions(this._client);
5568
+ this.hostedToolPermissions = new HostedToolPermissions(this._client);
5008
5569
  this.groups = new Groups(this._client);
5009
5570
  this.roles = new Roles$3(this._client);
5571
+ this.dataRetention = new DataRetention(this._client);
5572
+ this.spendAlerts = new SpendAlerts(this._client);
5010
5573
  this.certificates = new Certificates(this._client);
5011
5574
  }
5012
5575
  /**
@@ -5104,8 +5667,12 @@ Projects.Users = Users$1;
5104
5667
  Projects.ServiceAccounts = ServiceAccounts;
5105
5668
  Projects.APIKeys = APIKeys;
5106
5669
  Projects.RateLimits = RateLimits;
5670
+ Projects.ModelPermissions = ModelPermissions;
5671
+ Projects.HostedToolPermissions = HostedToolPermissions;
5107
5672
  Projects.Groups = Groups;
5108
5673
  Projects.Roles = Roles$3;
5674
+ Projects.DataRetention = DataRetention;
5675
+ Projects.SpendAlerts = SpendAlerts;
5109
5676
  Projects.Certificates = Certificates;
5110
5677
 
5111
5678
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
@@ -5129,6 +5696,25 @@ class Roles extends APIResource {
5129
5696
  __security: { adminAPIKeyAuth: true },
5130
5697
  });
5131
5698
  }
5699
+ /**
5700
+ * Retrieves an organization role assigned to a user.
5701
+ *
5702
+ * @example
5703
+ * ```ts
5704
+ * const role =
5705
+ * await client.admin.organization.users.roles.retrieve(
5706
+ * 'role_id',
5707
+ * { user_id: 'user_id' },
5708
+ * );
5709
+ * ```
5710
+ */
5711
+ retrieve(roleID, params, options) {
5712
+ const { user_id } = params;
5713
+ return this._client.get(path `/organization/users/${user_id}/roles/${roleID}`, {
5714
+ ...options,
5715
+ __security: { adminAPIKeyAuth: true },
5716
+ });
5717
+ }
5132
5718
  /**
5133
5719
  * Lists the organization roles assigned to a user within the organization.
5134
5720
  *
@@ -5251,6 +5837,8 @@ class Organization extends APIResource {
5251
5837
  this.users = new Users(this._client);
5252
5838
  this.groups = new Groups$1(this._client);
5253
5839
  this.roles = new Roles$5(this._client);
5840
+ this.dataRetention = new DataRetention$1(this._client);
5841
+ this.spendAlerts = new SpendAlerts$1(this._client);
5254
5842
  this.certificates = new Certificates$1(this._client);
5255
5843
  this.projects = new Projects(this._client);
5256
5844
  }
@@ -5262,6 +5850,8 @@ Organization.Invites = Invites;
5262
5850
  Organization.Users = Users;
5263
5851
  Organization.Groups = Groups$1;
5264
5852
  Organization.Roles = Roles$5;
5853
+ Organization.DataRetention = DataRetention$1;
5854
+ Organization.SpendAlerts = SpendAlerts$1;
5265
5855
  Organization.Certificates = Certificates$1;
5266
5856
  Organization.Projects = Projects;
5267
5857
 
@@ -12252,11 +12842,11 @@ function zodTextFormat(zodObject, name, props) {
12252
12842
  }, (content) => zodObject.parse(JSON.parse(content)));
12253
12843
  }
12254
12844
 
12255
- const DEFAULT_MODEL = 'gpt-5-mini';
12845
+ const DEFAULT_MODEL = 'gpt-5.4-mini';
12256
12846
  const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
12257
12847
  const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
12258
12848
  const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
12259
- /** Token costs in USD per 1M tokens. Last updated May 2026. */
12849
+ /** Token costs in USD per 1M tokens. Last updated May 2026 from the OpenAI API pricing page. */
12260
12850
  const openAiModelCosts = {
12261
12851
  'gpt-5': {
12262
12852
  inputCost: 1.25 / 1_000_000,
@@ -12269,9 +12859,14 @@ const openAiModelCosts = {
12269
12859
  outputCost: 2 / 1_000_000,
12270
12860
  },
12271
12861
  'gpt-5.4-mini': {
12272
- inputCost: 0.25 / 1_000_000,
12273
- cacheHitCost: 0.025 / 1_000_000,
12274
- outputCost: 2 / 1_000_000,
12862
+ inputCost: 0.75 / 1_000_000,
12863
+ cacheHitCost: 0.075 / 1_000_000,
12864
+ outputCost: 4.5 / 1_000_000,
12865
+ },
12866
+ 'gpt-5.4-nano': {
12867
+ inputCost: 0.2 / 1_000_000,
12868
+ cacheHitCost: 0.02 / 1_000_000,
12869
+ outputCost: 1.25 / 1_000_000,
12275
12870
  },
12276
12871
  'gpt-5-nano': {
12277
12872
  inputCost: 0.05 / 1_000_000,
@@ -12890,6 +13485,7 @@ async function parseResponse(content, responseFormat) {
12890
13485
  }
12891
13486
 
12892
13487
  // llm-openai.ts
13488
+ const DEFAULT_IMAGE_MIME_TYPE = 'image/webp';
12893
13489
  /**
12894
13490
  * Checks if the given direct OpenAI model supports the temperature parameter.
12895
13491
  * @param model The model to check.
@@ -12924,6 +13520,135 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
12924
13520
  ...(schemaStrict !== undefined ? { strict: schemaStrict } : {}),
12925
13521
  };
12926
13522
  }
13523
+ function resolveOpenAIApiKey(apiKey) {
13524
+ const resolvedApiKey = apiKey || process.env.OPENAI_API_KEY;
13525
+ if (!resolvedApiKey) {
13526
+ throw new Error('OpenAI API key is not provided and OPENAI_API_KEY environment variable is not set');
13527
+ }
13528
+ return resolvedApiKey;
13529
+ }
13530
+ function createOpenAIClient(apiKey) {
13531
+ return new OpenAI({
13532
+ apiKey,
13533
+ });
13534
+ }
13535
+ function normalizeImageDataUrl(imageData, mimeType = DEFAULT_IMAGE_MIME_TYPE) {
13536
+ return imageData.startsWith('data:') ? imageData : `data:${mimeType};base64,${imageData}`;
13537
+ }
13538
+ function getFilenameFromPath(filePath) {
13539
+ const normalizedPath = filePath.replace(/\\/g, '/');
13540
+ const pathSegments = normalizedPath.split('/');
13541
+ const filename = pathSegments[pathSegments.length - 1];
13542
+ if (!filename) {
13543
+ throw new Error(`Could not determine a filename from file path: ${filePath}`);
13544
+ }
13545
+ return filename;
13546
+ }
13547
+ function inferImageMimeType(filePath) {
13548
+ const normalizedPath = filePath.toLowerCase();
13549
+ if (normalizedPath.endsWith('.png')) {
13550
+ return 'image/png';
13551
+ }
13552
+ if (normalizedPath.endsWith('.jpg') || normalizedPath.endsWith('.jpeg')) {
13553
+ return 'image/jpeg';
13554
+ }
13555
+ if (normalizedPath.endsWith('.webp')) {
13556
+ return 'image/webp';
13557
+ }
13558
+ if (normalizedPath.endsWith('.gif')) {
13559
+ return 'image/gif';
13560
+ }
13561
+ return undefined;
13562
+ }
13563
+ async function readLocalFileBytes(filePath) {
13564
+ try {
13565
+ const dynamicImport = new Function('specifier', 'return import(specifier);');
13566
+ const { readFile } = await dynamicImport('node:fs/promises');
13567
+ return await readFile(filePath);
13568
+ }
13569
+ catch {
13570
+ throw new Error('Local image file uploads require a Node.js runtime with access to node:fs/promises');
13571
+ }
13572
+ }
13573
+ async function uploadVisionFileFromPath(openai, filePath, filename, mimeType) {
13574
+ const fileBytes = await readLocalFileBytes(filePath);
13575
+ const resolvedFilename = filename || getFilenameFromPath(filePath);
13576
+ const resolvedMimeType = mimeType || inferImageMimeType(filePath);
13577
+ const uploadableFile = await OpenAI.toFile(fileBytes, resolvedFilename, resolvedMimeType ? { type: resolvedMimeType } : undefined);
13578
+ const uploadedFile = await openai.files.create({
13579
+ file: uploadableFile,
13580
+ purpose: 'vision',
13581
+ });
13582
+ return uploadedFile.id;
13583
+ }
13584
+ function collectImageInputs(image, images, imageBase64) {
13585
+ const collectedImages = [];
13586
+ if (image) {
13587
+ collectedImages.push(image);
13588
+ }
13589
+ if (images && images.length > 0) {
13590
+ collectedImages.push(...images);
13591
+ }
13592
+ if (imageBase64) {
13593
+ collectedImages.push({ base64: imageBase64 });
13594
+ }
13595
+ return collectedImages;
13596
+ }
13597
+ function hasLocalFileImage(images) {
13598
+ return images.some((image) => 'filePath' in image);
13599
+ }
13600
+ async function buildImageContentPart(image, defaultDetail, openai) {
13601
+ const detail = image.detail ?? defaultDetail;
13602
+ if ('url' in image) {
13603
+ return {
13604
+ type: 'input_image',
13605
+ detail,
13606
+ image_url: image.url,
13607
+ };
13608
+ }
13609
+ if ('dataUrl' in image) {
13610
+ return {
13611
+ type: 'input_image',
13612
+ detail,
13613
+ image_url: image.dataUrl,
13614
+ };
13615
+ }
13616
+ if ('base64' in image) {
13617
+ return {
13618
+ type: 'input_image',
13619
+ detail,
13620
+ image_url: normalizeImageDataUrl(image.base64, image.mimeType),
13621
+ };
13622
+ }
13623
+ if ('fileId' in image) {
13624
+ return {
13625
+ type: 'input_image',
13626
+ detail,
13627
+ file_id: image.fileId,
13628
+ };
13629
+ }
13630
+ if (!openai) {
13631
+ throw new Error('A local image file path was provided, but no OpenAI client is available to upload it');
13632
+ }
13633
+ const fileId = await uploadVisionFileFromPath(openai, image.filePath, image.filename, image.mimeType);
13634
+ return {
13635
+ type: 'input_image',
13636
+ detail,
13637
+ file_id: fileId,
13638
+ };
13639
+ }
13640
+ async function buildPromptContent(input, imageInputs, imageDetail, openai) {
13641
+ if (imageInputs.length === 0) {
13642
+ return input;
13643
+ }
13644
+ const imageContent = await Promise.all(imageInputs.map((image) => buildImageContentPart(image, imageDetail, openai)));
13645
+ return [{ type: 'input_text', text: input }, ...imageContent];
13646
+ }
13647
+ async function uploadVisionFile(filePath, options = {}) {
13648
+ const resolvedApiKey = resolveOpenAIApiKey(options.apiKey);
13649
+ const openai = createOpenAIClient(resolvedApiKey);
13650
+ return await uploadVisionFileFromPath(openai, filePath, options.filename, options.mimeType);
13651
+ }
12927
13652
  /**
12928
13653
  * Makes a call to OpenAI's Responses API for more advanced use cases with built-in tools.
12929
13654
  *
@@ -12955,13 +13680,8 @@ const makeResponsesAPICall = async (input, options = {}) => {
12955
13680
  if (!isOpenAIModel(normalizedModel)) {
12956
13681
  throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
12957
13682
  }
12958
- const apiKey = options.apiKey || process.env.OPENAI_API_KEY;
12959
- if (!apiKey) {
12960
- throw new Error('OpenAI API key is not provided and OPENAI_API_KEY environment variable is not set');
12961
- }
12962
- const openai = new OpenAI({
12963
- apiKey: apiKey,
12964
- });
13683
+ const apiKey = resolveOpenAIApiKey(options.apiKey);
13684
+ const openai = createOpenAIClient(apiKey);
12965
13685
  // Remove apiKey from options before creating request body
12966
13686
  const { apiKey: _, model: __, ...cleanOptions } = options;
12967
13687
  const requestBody = {
@@ -13072,12 +13792,16 @@ const makeResponsesAPICall = async (input, options = {}) => {
13072
13792
  * });
13073
13793
  */
13074
13794
  async function makeLLMCall(input, options = {}) {
13075
- const { apiKey, model = DEFAULT_MODEL, responseFormat = 'text', schema, schemaName = 'response', schemaDescription, schemaStrict, tools, useCodeInterpreter = false, useWebSearch = false, imageBase64, imageDetail = 'high', context, } = options;
13795
+ const { apiKey, model = DEFAULT_MODEL, responseFormat = 'text', schema, schemaName = 'response', schemaDescription, schemaStrict, tools, useCodeInterpreter = false, useWebSearch = false, image, images, imageBase64, imageDetail = 'high', context, } = options;
13076
13796
  // Validate model
13077
13797
  const normalizedModel = normalizeModelName(model);
13078
13798
  if (!isOpenAIModel(normalizedModel)) {
13079
13799
  throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
13080
13800
  }
13801
+ const resolvedApiKey = resolveOpenAIApiKey(apiKey);
13802
+ const imageInputs = collectImageInputs(image, images, imageBase64);
13803
+ const openai = hasLocalFileImage(imageInputs) ? createOpenAIClient(resolvedApiKey) : undefined;
13804
+ const promptContent = await buildPromptContent(input, imageInputs, imageDetail, openai);
13081
13805
  // Process input for conversation context and image analysis
13082
13806
  let processedInput;
13083
13807
  if (context && context.length > 0) {
@@ -13092,18 +13816,11 @@ async function makeLLMCall(input, options = {}) {
13092
13816
  });
13093
13817
  }
13094
13818
  // Add current input message
13095
- if (imageBase64) {
13096
- // Current message includes both text and image
13819
+ if (imageInputs.length > 0) {
13820
+ // Current message includes text and one or more images
13097
13821
  conversationMessages.push({
13098
13822
  role: 'user',
13099
- content: [
13100
- { type: 'input_text', text: input },
13101
- {
13102
- type: 'input_image',
13103
- detail: imageDetail,
13104
- image_url: imageBase64.startsWith('data:') ? imageBase64 : `data:image/webp;base64,${imageBase64}`,
13105
- },
13106
- ],
13823
+ content: promptContent,
13107
13824
  type: 'message',
13108
13825
  });
13109
13826
  }
@@ -13117,19 +13834,12 @@ async function makeLLMCall(input, options = {}) {
13117
13834
  }
13118
13835
  processedInput = conversationMessages;
13119
13836
  }
13120
- else if (imageBase64) {
13121
- // No context, but has image - use the original image logic
13837
+ else if (imageInputs.length > 0) {
13838
+ // No context, but has image(s)
13122
13839
  processedInput = [
13123
13840
  {
13124
13841
  role: 'user',
13125
- content: [
13126
- { type: 'input_text', text: input },
13127
- {
13128
- type: 'input_image',
13129
- detail: imageDetail,
13130
- image_url: imageBase64.startsWith('data:') ? imageBase64 : `data:image/webp;base64,${imageBase64}`,
13131
- },
13132
- ],
13842
+ content: promptContent,
13133
13843
  type: 'message',
13134
13844
  },
13135
13845
  ];
@@ -13140,7 +13850,7 @@ async function makeLLMCall(input, options = {}) {
13140
13850
  }
13141
13851
  // Build the options object for makeResponsesAPICall
13142
13852
  let responsesOptions = {
13143
- apiKey,
13853
+ apiKey: resolvedApiKey,
13144
13854
  model: normalizedModel,
13145
13855
  parallel_tool_calls: false,
13146
13856
  tools,
@@ -14626,11 +15336,12 @@ const disco = {
14626
15336
  types: Types,
14627
15337
  llm: {
14628
15338
  call: makeLLMCall,
15339
+ uploadVisionFile: uploadVisionFile,
14629
15340
  seek: makeDeepseekCall,
14630
15341
  images: makeImagesCall,
14631
15342
  },
14632
15343
  time,
14633
15344
  };
14634
15345
 
14635
- export { OPENAI_IMAGE_MODELS, OPENAI_MODELS, OPENROUTER_MODELS, disco, isOpenAIImageModel, isOpenAIModel, isOpenRouterModel, supportsTemperature };
15346
+ export { OPENAI_IMAGE_MODELS, OPENAI_MODELS, OPENROUTER_MODELS, disco, isOpenAIImageModel, isOpenAIModel, isOpenRouterModel, supportsTemperature, uploadVisionFile };
14636
15347
  //# sourceMappingURL=index-frontend.mjs.map