@bodhiapp/ts-client 0.1.31 → 0.1.32

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.
@@ -162,6 +162,7 @@ export type ApiAliasResponse = {
162
162
  forward_all_with_prefix: boolean;
163
163
  extra_headers?: unknown;
164
164
  extra_body?: unknown;
165
+ llm_liberty?: null | LlmLibertySummary;
165
166
  created_at: string;
166
167
  updated_at: string;
167
168
  };
@@ -169,7 +170,7 @@ export type ApiAliasResponse = {
169
170
  /**
170
171
  * API format/protocol specification
171
172
  */
172
- export type ApiFormat = 'openai' | 'openai_responses' | 'anthropic' | 'anthropic_oauth' | 'gemini';
173
+ export type ApiFormat = 'openai' | 'openai_responses' | 'anthropic' | 'anthropic_oauth' | 'gemini' | 'llm_liberty_oauth';
173
174
 
174
175
  /**
175
176
  * Response containing available API formats
@@ -210,42 +211,22 @@ export type ApiModel = (Model & {
210
211
 
211
212
  /**
212
213
  * Input request for creating or updating an API model configuration.
214
+ * Discriminated by `api_format` — `llm_liberty_oauth` uses `LlmLibertyApiModelRequest`,
215
+ * every other format uses `DefaultApiModelRequest`.
213
216
  */
214
- export type ApiModelRequest = {
215
- /**
216
- * API format/protocol (e.g., "openai")
217
- */
218
- api_format: ApiFormat;
219
- /**
220
- * API base URL
221
- */
222
- base_url: string;
223
- /**
224
- * API key update action (Keep/Set with Some or None)
225
- */
226
- api_key?: ApiKeyUpdate;
227
- /**
228
- * List of available models
229
- */
230
- models: Array<string>;
231
- /**
232
- * Optional prefix for model namespacing (e.g., "azure/" for "azure/gpt-4")
233
- */
234
- prefix?: string | null;
235
- /**
236
- * Whether to forward all requests with this prefix (true) or only selected models (false)
237
- */
238
- forward_all_with_prefix?: boolean;
239
- /**
240
- * Optional extra HTTP headers to send upstream. Cannot include `Authorization`
241
- * or `x-api-key` — those are owned by provider clients.
242
- */
243
- extra_headers?: unknown;
244
- /**
245
- * Optional extra fields to merge into the request body sent upstream
246
- */
247
- extra_body?: unknown;
248
- };
217
+ export type ApiModelRequest = (DefaultApiModelRequest & {
218
+ api_format: 'openai';
219
+ }) | (DefaultApiModelRequest & {
220
+ api_format: 'openai_responses';
221
+ }) | (DefaultApiModelRequest & {
222
+ api_format: 'anthropic';
223
+ }) | (DefaultApiModelRequest & {
224
+ api_format: 'anthropic_oauth';
225
+ }) | (DefaultApiModelRequest & {
226
+ api_format: 'gemini';
227
+ }) | (LlmLibertyApiModelRequest & {
228
+ api_format: 'llm_liberty_oauth';
229
+ });
249
230
 
250
231
  /**
251
232
  * DB-storable `Vec<ApiModel>` — stored as JSON binary in SeaORM columns.
@@ -529,6 +510,94 @@ export type DashboardUser = {
529
510
  last_name?: string | null;
530
511
  };
531
512
 
513
+ /**
514
+ * Inner request shape for the five non-llm-liberty `api_format` values.
515
+ * Shared across `openai`, `openai_responses`, `anthropic`, `anthropic_oauth`, `gemini`.
516
+ */
517
+ export type DefaultApiModelRequest = {
518
+ /**
519
+ * API base URL
520
+ */
521
+ base_url: string;
522
+ /**
523
+ * API key update action (Keep/Set with Some or None)
524
+ */
525
+ api_key?: ApiKeyUpdate;
526
+ /**
527
+ * List of available models
528
+ */
529
+ models: Array<string>;
530
+ /**
531
+ * Optional prefix for model namespacing (e.g., "azure/" for "azure/gpt-4")
532
+ */
533
+ prefix?: string | null;
534
+ /**
535
+ * Whether to forward all requests with this prefix (true) or only selected models (false)
536
+ */
537
+ forward_all_with_prefix?: boolean;
538
+ /**
539
+ * Optional extra HTTP headers to send upstream. Cannot include `Authorization`
540
+ * or `x-api-key` — those are owned by provider clients.
541
+ */
542
+ extra_headers?: unknown;
543
+ /**
544
+ * Optional extra fields to merge into the request body sent upstream
545
+ */
546
+ extra_body?: unknown;
547
+ };
548
+
549
+ /**
550
+ * Inner request for the five non-llm-liberty `api_format` values.
551
+ */
552
+ export type DefaultFetchModelsRequest = {
553
+ /**
554
+ * Credentials to use for fetching models
555
+ */
556
+ creds?: TestCreds;
557
+ /**
558
+ * API base URL (required - always needed to know where to fetch models from)
559
+ */
560
+ base_url: string;
561
+ /**
562
+ * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
563
+ */
564
+ extra_headers?: unknown;
565
+ /**
566
+ * Optional extra fields to merge into the request body
567
+ */
568
+ extra_body?: unknown;
569
+ };
570
+
571
+ /**
572
+ * Inner request for the five non-llm-liberty `api_format` values.
573
+ */
574
+ export type DefaultTestPromptRequest = {
575
+ /**
576
+ * Credentials to use for testing
577
+ */
578
+ creds?: TestCreds;
579
+ /**
580
+ * API base URL
581
+ */
582
+ base_url: string;
583
+ /**
584
+ * Model to use for testing
585
+ */
586
+ model: string;
587
+ /**
588
+ * Test prompt (max 30 characters for cost control)
589
+ */
590
+ prompt: string;
591
+ /**
592
+ * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
593
+ */
594
+ extra_headers?: unknown;
595
+ /**
596
+ * Optional extra fields to merge into the request body
597
+ */
598
+ extra_body?: unknown;
599
+ };
600
+
532
601
  export type DeploymentMode = 'standalone' | 'multi_tenant';
533
602
 
534
603
  export type DownloadRequest = {
@@ -570,30 +639,21 @@ export type EffortCapability = {
570
639
  };
571
640
 
572
641
  /**
573
- * Request to fetch available models from provider
642
+ * Request to fetch available models from provider. Discriminated on `api_format`.
574
643
  */
575
- export type FetchModelsRequest = {
576
- /**
577
- * Credentials to use for fetching models
578
- */
579
- creds?: TestCreds;
580
- /**
581
- * API base URL (required - always needed to know where to fetch models from)
582
- */
583
- base_url: string;
584
- /**
585
- * API format to use for fetching models (defaults to OpenAI Chat Completions)
586
- */
587
- api_format?: ApiFormat;
588
- /**
589
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
590
- */
591
- extra_headers?: unknown;
592
- /**
593
- * Optional extra fields to merge into the request body
594
- */
595
- extra_body?: unknown;
596
- };
644
+ export type FetchModelsRequest = (DefaultFetchModelsRequest & {
645
+ api_format: 'openai';
646
+ }) | (DefaultFetchModelsRequest & {
647
+ api_format: 'openai_responses';
648
+ }) | (DefaultFetchModelsRequest & {
649
+ api_format: 'anthropic';
650
+ }) | (DefaultFetchModelsRequest & {
651
+ api_format: 'anthropic_oauth';
652
+ }) | (DefaultFetchModelsRequest & {
653
+ api_format: 'gemini';
654
+ }) | (LlmLibertyFetchModelsRequest & {
655
+ api_format: 'llm_liberty_oauth';
656
+ });
597
657
 
598
658
  /**
599
659
  * Returns model IDs only (not full metadata) to minimize information exposure —
@@ -642,6 +702,136 @@ export type ListUsersParams = {
642
702
  page_size?: number | null;
643
703
  };
644
704
 
705
+ export type LlmLibertyApiEndpoints = {
706
+ base_url: string;
707
+ chat_url: string;
708
+ models_url?: string | null;
709
+ };
710
+
711
+ /**
712
+ * Request shape for `api_format == "llm_liberty_oauth"`. Carries the full envelope
713
+ * (or `Keep` to leave existing credentials untouched on update).
714
+ */
715
+ export type LlmLibertyApiModelRequest = {
716
+ /**
717
+ * Envelope update action — Keep (update only) or Set (create/replace credentials).
718
+ */
719
+ envelope?: LlmLibertyEnvelopeUpdate;
720
+ /**
721
+ * List of available models
722
+ */
723
+ models?: Array<string>;
724
+ /**
725
+ * Optional prefix for model namespacing
726
+ */
727
+ prefix?: string | null;
728
+ /**
729
+ * Whether to forward all requests with this prefix
730
+ */
731
+ forward_all_with_prefix?: boolean;
732
+ };
733
+
734
+ export type LlmLibertyAuthSpec = {
735
+ in: string;
736
+ key: string;
737
+ scheme: string;
738
+ };
739
+
740
+ /**
741
+ * The JSON blob emitted by `npx @bodhiapp/llm-liberty@latest login`.
742
+ *
743
+ * Version field allows BodhiApp to detect breaking changes in the envelope
744
+ * schema (major-version bump = breaking). Currently only `"1.0.0"` is accepted.
745
+ */
746
+ export type LlmLibertyEnvelope = {
747
+ /**
748
+ * Envelope schema version — must be "1.0.0".
749
+ */
750
+ version: string;
751
+ /**
752
+ * Provider identifier, e.g. "anthropic" or "openai-codex".
753
+ */
754
+ provider: string;
755
+ access_token: string;
756
+ refresh_token: string;
757
+ /**
758
+ * Unix epoch seconds when the access token expires.
759
+ */
760
+ expires_at: number;
761
+ auth: LlmLibertyAuthSpec;
762
+ oauth: LlmLibertyOauthEndpoints;
763
+ api: LlmLibertyApiEndpoints;
764
+ headers?: unknown;
765
+ body?: unknown;
766
+ extra?: unknown;
767
+ };
768
+
769
+ /**
770
+ * Tagged envelope update action — either keep the existing credentials or replace them.
771
+ */
772
+ export type LlmLibertyEnvelopeUpdate = {
773
+ action: 'keep';
774
+ } | {
775
+ /**
776
+ * Replace with a new envelope (atomic re-paste).
777
+ */
778
+ value: LlmLibertyEnvelope;
779
+ action: 'set';
780
+ };
781
+
782
+ /**
783
+ * Inner request for `api_format == "llm_liberty_oauth"`. Either `id` (use stored creds)
784
+ * or `envelope` (use the provided envelope directly) must be set, never both.
785
+ */
786
+ export type LlmLibertyFetchModelsRequest = {
787
+ /**
788
+ * Edit mode: alias id whose stored credentials should be used.
789
+ */
790
+ id?: string | null;
791
+ envelope?: null | LlmLibertyEnvelope;
792
+ };
793
+
794
+ export type LlmLibertyOauthEndpoints = {
795
+ authorize_url: string;
796
+ token_url: string;
797
+ revoke_url?: string | null;
798
+ client_id: string;
799
+ client_secret?: string | null;
800
+ };
801
+
802
+ /**
803
+ * Non-secret summary of stored LLM Liberty OAuth credentials for API responses.
804
+ */
805
+ export type LlmLibertySummary = {
806
+ provider: string;
807
+ envelope_version: string;
808
+ /**
809
+ * Unix epoch seconds — when the stored access token expires.
810
+ */
811
+ expires_at: number;
812
+ has_refresh_token: boolean;
813
+ };
814
+
815
+ /**
816
+ * Inner request for `api_format == "llm_liberty_oauth"`. Either `id` (use stored creds)
817
+ * or `envelope` (use the provided envelope directly) must be set, never both.
818
+ */
819
+ export type LlmLibertyTestPromptRequest = {
820
+ /**
821
+ * Edit mode: alias id whose stored credentials should be used.
822
+ */
823
+ id?: string | null;
824
+ envelope?: null | LlmLibertyEnvelope;
825
+ /**
826
+ * Model to use for testing
827
+ */
828
+ model: string;
829
+ /**
830
+ * Test prompt (max 30 characters for cost control)
831
+ */
832
+ prompt: string;
833
+ };
834
+
645
835
  /**
646
836
  * Local model file response
647
837
  */
@@ -1322,38 +1512,21 @@ export type TestCreds = {
1322
1512
  };
1323
1513
 
1324
1514
  /**
1325
- * Request to test API connectivity with a prompt
1515
+ * Request to test API connectivity with a prompt. Discriminated on `api_format`.
1326
1516
  */
1327
- export type TestPromptRequest = {
1328
- /**
1329
- * Credentials to use for testing
1330
- */
1331
- creds?: TestCreds;
1332
- /**
1333
- * API base URL
1334
- */
1335
- base_url: string;
1336
- /**
1337
- * Model to use for testing
1338
- */
1339
- model: string;
1340
- /**
1341
- * Test prompt (max 30 characters for cost control)
1342
- */
1343
- prompt: string;
1344
- /**
1345
- * API format to use for the test request (defaults to OpenAI Chat Completions)
1346
- */
1347
- api_format?: ApiFormat;
1348
- /**
1349
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
1350
- */
1351
- extra_headers?: unknown;
1352
- /**
1353
- * Optional extra fields to merge into the request body
1354
- */
1355
- extra_body?: unknown;
1356
- };
1517
+ export type TestPromptRequest = (DefaultTestPromptRequest & {
1518
+ api_format: 'openai';
1519
+ }) | (DefaultTestPromptRequest & {
1520
+ api_format: 'openai_responses';
1521
+ }) | (DefaultTestPromptRequest & {
1522
+ api_format: 'anthropic';
1523
+ }) | (DefaultTestPromptRequest & {
1524
+ api_format: 'anthropic_oauth';
1525
+ }) | (DefaultTestPromptRequest & {
1526
+ api_format: 'gemini';
1527
+ }) | (LlmLibertyTestPromptRequest & {
1528
+ api_format: 'llm_liberty_oauth';
1529
+ });
1357
1530
 
1358
1531
  /**
1359
1532
  * Response from testing API connectivity
@@ -2101,7 +2101,7 @@ export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use
2101
2101
  /**
2102
2102
  * The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
2103
2103
  */
2104
- export type Model = string | 'claude-mythos-preview' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-1-20250805' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-3-haiku-20240307';
2104
+ export type Model = string | 'claude-mythos-preview' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-1-20250805' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514';
2105
2105
  export type MessagesPostData = {
2106
2106
  body: CreateMessageParams;
2107
2107
  headers?: {
@@ -2260,7 +2260,7 @@ export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use
2260
2260
  /**
2261
2261
  * The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
2262
2262
  */
2263
- export type Model = string | 'claude-mythos-preview' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-1-20250805' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-3-haiku-20240307';
2263
+ export type Model = string | 'claude-mythos-preview' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-1-20250805' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514';
2264
2264
 
2265
2265
  export type MessagesPostData = {
2266
2266
  body: CreateMessageParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhiapp/ts-client",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "TypeScript types for Bodhi API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",