@opensecret/react 1.4.3 → 1.5.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.d.ts CHANGED
@@ -7,6 +7,30 @@ declare function acceptInvite(code: string): Promise<{
7
7
  message: string;
8
8
  }>;
9
9
 
10
+ /**
11
+ * @deprecated Use openai.conversations.create() with items parameter instead
12
+ * Adds items to a conversation
13
+ * @param conversationId - The UUID of the conversation
14
+ * @param items - Array of items to add to the conversation
15
+ * @returns A promise resolving to the updated conversation with items
16
+ * @throws {Error} If:
17
+ * - The user is not authenticated
18
+ * - The conversation is not found
19
+ * - The user doesn't have access to the conversation
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * await addConversationItems("550e8400-e29b-41d4-a716-446655440000", [
24
+ * {
25
+ * type: "message",
26
+ * role: "user",
27
+ * content: [{ type: "text", text: "Hello" }]
28
+ * }
29
+ * ]);
30
+ * ```
31
+ */
32
+ declare function addConversationItems(conversationId: string, items: Partial<ConversationItem>[]): Promise<Conversation>;
33
+
10
34
  declare namespace api {
11
35
  export {
12
36
  setApiUrl,
@@ -54,6 +78,24 @@ declare namespace api {
54
78
  checkDocumentStatus,
55
79
  uploadDocumentWithPolling,
56
80
  transcribeAudio,
81
+ fetchResponsesList,
82
+ fetchResponse,
83
+ cancelResponse,
84
+ createConversation,
85
+ getConversation,
86
+ updateConversation,
87
+ deleteConversation,
88
+ addConversationItems,
89
+ listConversationItems,
90
+ listConversations,
91
+ createResponse,
92
+ deleteResponse,
93
+ createInstruction,
94
+ listInstructions,
95
+ getInstruction,
96
+ updateInstruction,
97
+ deleteInstruction,
98
+ setDefaultInstruction,
57
99
  LoginResponse,
58
100
  UserResponse,
59
101
  KVListItem,
@@ -81,7 +123,27 @@ declare namespace api {
81
123
  DocumentStatusRequest,
82
124
  DocumentStatusResponse,
83
125
  WhisperTranscriptionRequest,
84
- WhisperTranscriptionResponse
126
+ WhisperTranscriptionResponse,
127
+ ResponsesRetrieveResponse,
128
+ ThreadListItem,
129
+ ResponsesListResponse,
130
+ ResponsesListParams,
131
+ ConversationItem,
132
+ Conversation,
133
+ ConversationCreateRequest,
134
+ ConversationUpdateRequest,
135
+ ConversationItemsResponse,
136
+ ConversationsListResponse,
137
+ ConversationDeleteResponse,
138
+ ResponsesCancelResponse,
139
+ ResponsesDeleteResponse,
140
+ ResponsesCreateRequest,
141
+ Instruction,
142
+ InstructionCreateRequest,
143
+ InstructionUpdateRequest,
144
+ InstructionListParams,
145
+ InstructionListResponse,
146
+ InstructionDeleteResponse
85
147
  }
86
148
  }
87
149
 
@@ -215,6 +277,32 @@ declare function authenticate(attestationDocumentBase64: string, trustedRootCert
215
277
 
216
278
  declare const AWS_ROOT_CERT_DER: Uint8Array;
217
279
 
280
+ /**
281
+ * Cancels an in-progress response
282
+ * @param responseId - The UUID of the response to cancel
283
+ * @returns A promise resolving to the cancelled response
284
+ * @throws {Error} If:
285
+ * - The user is not authenticated
286
+ * - The response is not found
287
+ * - The response is not in 'in_progress' status
288
+ * - The user doesn't have access to the response
289
+ *
290
+ * @description
291
+ * This function cancels a response that is currently being processed.
292
+ * Only responses with status 'in_progress' can be cancelled.
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * try {
297
+ * const cancelled = await cancelResponse("550e8400-e29b-41d4-a716-446655440000");
298
+ * console.log("Response cancelled:", cancelled.status);
299
+ * } catch (error) {
300
+ * console.error("Cannot cancel:", error.message);
301
+ * }
302
+ * ```
303
+ */
304
+ declare function cancelResponse(responseId: string): Promise<ResponsesCancelResponse>;
305
+
218
306
  declare function changePassword(currentPassword: string, newPassword: string): Promise<void>;
219
307
 
220
308
  /**
@@ -298,6 +386,57 @@ declare function confirmPlatformPasswordReset(email: string, alphanumericCode: s
298
386
  message: string;
299
387
  }>;
300
388
 
389
+ export declare type Conversation = {
390
+ id: string;
391
+ object: "conversation";
392
+ created_at: number;
393
+ metadata?: Record<string, any>;
394
+ };
395
+
396
+ export declare type ConversationCreateRequest = {
397
+ metadata?: Record<string, any>;
398
+ };
399
+
400
+ export declare type ConversationDeleteResponse = {
401
+ id: string;
402
+ object: "conversation.deleted";
403
+ deleted: boolean;
404
+ };
405
+
406
+ export declare type ConversationItem = {
407
+ id: string;
408
+ type: "message";
409
+ status: "completed" | "in_progress" | "incomplete";
410
+ role: "user" | "assistant" | "system";
411
+ content: Array<{
412
+ type: "text" | "input_text" | "input_audio" | "item";
413
+ text?: string;
414
+ audio?: string;
415
+ transcript?: string;
416
+ id?: string;
417
+ }>;
418
+ };
419
+
420
+ export declare type ConversationItemsResponse = {
421
+ object: "list";
422
+ data: ConversationItem[];
423
+ first_id?: string;
424
+ last_id?: string;
425
+ has_more: boolean;
426
+ };
427
+
428
+ export declare type ConversationsListResponse = {
429
+ object: "list";
430
+ data: Conversation[];
431
+ first_id?: string;
432
+ last_id?: string;
433
+ has_more: boolean;
434
+ };
435
+
436
+ export declare type ConversationUpdateRequest = {
437
+ metadata?: Record<string, any>;
438
+ };
439
+
301
440
  declare function convertGuestToEmailAccount(email: string, password: string, name?: string | null): Promise<void>;
302
441
 
303
442
  /**
@@ -322,7 +461,56 @@ declare function convertGuestToEmailAccount(email: string, password: string, nam
322
461
  */
323
462
  export declare function createApiKey(name: string): Promise<ApiKeyCreateResponse>;
324
463
 
325
- export declare function createCustomFetch(options?: CustomFetchOptions): (url: RequestInfo, init?: RequestInit) => Promise<Response>;
464
+ /**
465
+ * Creates a new conversation
466
+ * @param metadata - Optional metadata to attach to the conversation
467
+ * @returns A promise resolving to the created conversation
468
+ * @throws {Error} If:
469
+ * - The user is not authenticated
470
+ * - The request fails
471
+ *
472
+ * @description
473
+ * This function creates a new conversation that can be used to group
474
+ * related responses together. The conversation can have metadata
475
+ * attached for organization and filtering purposes.
476
+ *
477
+ * NOTE: Prefer using the OpenAI client directly for conversation operations:
478
+ * ```typescript
479
+ * const openai = new OpenAI({ fetch: customFetch });
480
+ * const conversation = await openai.conversations.create({
481
+ * metadata: { title: "Product Support", category: "technical" }
482
+ * });
483
+ * ```
484
+ *
485
+ * @deprecated Use openai.conversations.create() instead
486
+ */
487
+ declare function createConversation(metadata?: Record<string, any>): Promise<Conversation>;
488
+
489
+ export declare function createCustomFetch(options?: CustomFetchOptions): (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
490
+
491
+ /**
492
+ * Creates a new instruction
493
+ * @param request - The instruction creation parameters
494
+ * @returns A promise resolving to the created instruction
495
+ * @throws {Error} If:\n * - The user is not authenticated
496
+ * - The request fails
497
+ * - Name or prompt are empty strings
498
+ *
499
+ * @description
500
+ * This function creates a new user instruction (system prompt).
501
+ * If is_default is set to true, all other instructions are automatically set to is_default: false.
502
+ * The prompt_tokens field is automatically calculated.
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const instruction = await createInstruction({
507
+ * name: "Helpful Assistant",
508
+ * prompt: "You are a helpful assistant that...",
509
+ * is_default: true
510
+ * });
511
+ * ```
512
+ */
513
+ declare function createInstruction(request: InstructionCreateRequest): Promise<Instruction>;
326
514
 
327
515
  declare function createOrganization(name: string): Promise<Organization>;
328
516
 
@@ -330,6 +518,38 @@ declare function createProject(orgId: string, name: string, description?: string
330
518
 
331
519
  declare function createProjectSecret(orgId: string, projectId: string, keyName: string, secret: string): Promise<ProjectSecret>;
332
520
 
521
+ /**
522
+ * Creates a new response with conversation support
523
+ * @param request - The request parameters for creating a response
524
+ * @returns A promise resolving to the created response or a stream
525
+ * @throws {Error} If:
526
+ * - The user is not authenticated
527
+ * - The request fails
528
+ *
529
+ * @description
530
+ * This function creates a new response in the OpenAI-compatible API.
531
+ * It supports both the new conversation parameter and the deprecated
532
+ * previous_response_id parameter for backward compatibility.
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * // Create a response in a conversation
537
+ * const response = await createResponse({
538
+ * model: "gpt-4",
539
+ * input: "Hello, how are you?",
540
+ * conversation: "550e8400-e29b-41d4-a716-446655440000"
541
+ * });
542
+ *
543
+ * // Or with the deprecated previous_response_id
544
+ * const response = await createResponse({
545
+ * model: "gpt-4",
546
+ * input: "Tell me more",
547
+ * previous_response_id: "response-uuid"
548
+ * });
549
+ * ```
550
+ */
551
+ declare function createResponse(request: ResponsesCreateRequest): Promise<any>;
552
+
333
553
  export declare interface CustomFetchOptions {
334
554
  apiKey?: string;
335
555
  }
@@ -401,6 +621,52 @@ declare type DecryptDataRequest = {
401
621
  */
402
622
  export declare function deleteApiKey(name: string): Promise<void>;
403
623
 
624
+ /**
625
+ * @deprecated Use openai.conversations.delete() instead
626
+ * Deletes a conversation permanently
627
+ * @param conversationId - The UUID of the conversation to delete
628
+ * @returns A promise resolving to deletion confirmation
629
+ * @throws {Error} If:
630
+ * - The user is not authenticated
631
+ * - The conversation is not found
632
+ * - The user doesn't have access to the conversation
633
+ *
634
+ * @description
635
+ * This function permanently deletes a conversation and all associated items.
636
+ * This action cannot be undone.
637
+ *
638
+ * @example
639
+ * ```typescript
640
+ * const result = await deleteConversation("550e8400-e29b-41d4-a716-446655440000");
641
+ * if (result.deleted) {
642
+ * console.log("Conversation deleted successfully");
643
+ * }
644
+ * ```
645
+ */
646
+ declare function deleteConversation(conversationId: string): Promise<ConversationDeleteResponse>;
647
+
648
+ /**
649
+ * Deletes an instruction permanently
650
+ * @param instructionId - The UUID of the instruction to delete
651
+ * @returns A promise resolving to deletion confirmation
652
+ * @throws {Error} If:\n * - The user is not authenticated
653
+ * - The instruction is not found (404)
654
+ * - The user doesn't have access to the instruction
655
+ *
656
+ * @description
657
+ * This function permanently deletes an instruction.
658
+ * This action cannot be undone.
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const result = await deleteInstruction("550e8400-e29b-41d4-a716-446655440000");
663
+ * if (result.deleted) {
664
+ * console.log("Instruction deleted successfully");
665
+ * }
666
+ * ```
667
+ */
668
+ declare function deleteInstruction(instructionId: string): Promise<InstructionDeleteResponse>;
669
+
404
670
  declare function deleteOrganization(orgId: string): Promise<void>;
405
671
 
406
672
  declare function deleteOrganizationInvite(orgId: string, inviteCode: string): Promise<{
@@ -411,6 +677,29 @@ declare function deleteProject(orgId: string, projectId: string): Promise<void>;
411
677
 
412
678
  declare function deleteProjectSecret(orgId: string, projectId: string, keyName: string): Promise<void>;
413
679
 
680
+ /**
681
+ * Deletes a response permanently
682
+ * @param responseId - The UUID of the response to delete
683
+ * @returns A promise resolving to deletion confirmation
684
+ * @throws {Error} If:
685
+ * - The user is not authenticated
686
+ * - The response is not found
687
+ * - The user doesn't have access to the response
688
+ *
689
+ * @description
690
+ * This function permanently deletes a response and all associated data.
691
+ * This action cannot be undone.
692
+ *
693
+ * @example
694
+ * ```typescript
695
+ * const result = await deleteResponse("550e8400-e29b-41d4-a716-446655440000");
696
+ * if (result.deleted) {
697
+ * console.log("Response deleted successfully");
698
+ * }
699
+ * ```
700
+ */
701
+ declare function deleteResponse(responseId: string): Promise<ResponsesDeleteResponse>;
702
+
414
703
  declare type DeveloperResponse = PlatformUser & {
415
704
  organizations: PlatformOrg[];
416
705
  };
@@ -609,6 +898,68 @@ declare function fetchPublicKey(algorithm: SigningAlgorithm, key_options?: KeyOp
609
898
 
610
899
  declare function fetchPut(key: string, value: string): Promise<string>;
611
900
 
901
+ /**
902
+ * Retrieves a single response by ID
903
+ * @param responseId - The UUID of the response to retrieve
904
+ * @returns A promise resolving to the response details
905
+ * @throws {Error} If:
906
+ * - The user is not authenticated
907
+ * - The response is not found
908
+ * - The user doesn't have access to the response
909
+ *
910
+ * @description
911
+ * This function fetches detailed information about a specific response,
912
+ * including full output and usage statistics.
913
+ *
914
+ * @example
915
+ * ```typescript
916
+ * const response = await fetchResponse("550e8400-e29b-41d4-a716-446655440000");
917
+ * console.log(response.output); // The full response text
918
+ * console.log(response.usage); // Token usage statistics
919
+ * ```
920
+ */
921
+ declare function fetchResponse(responseId: string): Promise<ResponsesRetrieveResponse>;
922
+
923
+ /**
924
+ * Lists user's conversation threads with pagination
925
+ * @param params - Optional parameters for pagination and filtering
926
+ * @returns A promise resolving to a paginated list of conversation threads
927
+ * @throws {Error} If:
928
+ * - The user is not authenticated
929
+ * - The request fails
930
+ * - Invalid pagination parameters
931
+ *
932
+ * @description
933
+ * This function fetches a paginated list of the user's conversation threads.
934
+ * Each thread represents a conversation, not individual messages.
935
+ * Threads are sorted by updated_at (most recently active threads first).
936
+ *
937
+ * Query Parameters:
938
+ * - limit: Number of results per page (1-100, default: 20)
939
+ * - after: UUID cursor for forward pagination
940
+ * - before: UUID cursor for backward pagination
941
+ * - order: Sort order (currently not implemented, reserved for future use)
942
+ *
943
+ * Pagination Examples:
944
+ * ```typescript
945
+ * // First page
946
+ * const threads = await fetchResponsesList({ limit: 20 });
947
+ *
948
+ * // Next page
949
+ * const nextPage = await fetchResponsesList({
950
+ * limit: 20,
951
+ * after: threads.last_id
952
+ * });
953
+ *
954
+ * // Previous page
955
+ * const prevPage = await fetchResponsesList({
956
+ * limit: 20,
957
+ * before: threads.first_id
958
+ * });
959
+ * ```
960
+ */
961
+ declare function fetchResponsesList(params?: ResponsesListParams): Promise<ResponsesListResponse>;
962
+
612
963
  declare function fetchSignUp(email: string, password: string, inviteCode: string, client_id: string, name?: string | null): Promise<LoginResponse>;
613
964
 
614
965
  declare function fetchUser(): Promise<UserResponse>;
@@ -630,8 +981,42 @@ declare function getApiUrl(): string;
630
981
 
631
982
  declare function getAttestation(forceRefresh?: boolean, explicitApiUrl?: string): Promise<Attestation>;
632
983
 
984
+ /**
985
+ * @deprecated Use openai.conversations.retrieve() instead
986
+ * Retrieves a conversation by ID
987
+ * @param conversationId - The UUID of the conversation to retrieve
988
+ * @returns A promise resolving to the conversation
989
+ * @throws {Error} If:
990
+ * - The user is not authenticated
991
+ * - The conversation is not found
992
+ * - The user doesn't have access to the conversation
993
+ *
994
+ * @example
995
+ * ```typescript
996
+ * const conversation = await getConversation("550e8400-e29b-41d4-a716-446655440000");
997
+ * console.log(conversation.metadata);
998
+ * ```
999
+ */
1000
+ declare function getConversation(conversationId: string): Promise<Conversation>;
1001
+
633
1002
  declare function getEmailSettings(orgId: string, projectId: string): Promise<EmailSettings>;
634
1003
 
1004
+ /**
1005
+ * Retrieves a single instruction by ID
1006
+ * @param instructionId - The UUID of the instruction to retrieve
1007
+ * @returns A promise resolving to the instruction details
1008
+ * @throws {Error} If:\n * - The user is not authenticated
1009
+ * - The instruction is not found (404)
1010
+ * - The user doesn't have access to the instruction
1011
+ *
1012
+ * @example
1013
+ * ```typescript
1014
+ * const instruction = await getInstruction("550e8400-e29b-41d4-a716-446655440000");
1015
+ * console.log(instruction.name, instruction.prompt);
1016
+ * ```
1017
+ */
1018
+ declare function getInstruction(instructionId: string): Promise<Instruction>;
1019
+
635
1020
  declare function getOAuthSettings(orgId: string, projectId: string): Promise<OAuthSettings>;
636
1021
 
637
1022
  declare function getOrganizationInvite(orgId: string, inviteCode: string): Promise<OrganizationInvite>;
@@ -718,6 +1103,50 @@ declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Pro
718
1103
 
719
1104
  declare function initiateGoogleAuth(client_id: string, inviteCode?: string): Promise<GoogleAuthResponse>;
720
1105
 
1106
+ declare type Instruction = {
1107
+ id: string;
1108
+ object: "instruction";
1109
+ name: string;
1110
+ prompt: string;
1111
+ prompt_tokens: number;
1112
+ is_default: boolean;
1113
+ created_at: number;
1114
+ updated_at: number;
1115
+ };
1116
+
1117
+ declare type InstructionCreateRequest = {
1118
+ name: string;
1119
+ prompt: string;
1120
+ is_default?: boolean;
1121
+ };
1122
+
1123
+ declare type InstructionDeleteResponse = {
1124
+ id: string;
1125
+ object: "instruction.deleted";
1126
+ deleted: true;
1127
+ };
1128
+
1129
+ declare type InstructionListParams = {
1130
+ limit?: number;
1131
+ after?: string;
1132
+ before?: string;
1133
+ order?: string;
1134
+ };
1135
+
1136
+ declare type InstructionListResponse = {
1137
+ object: "list";
1138
+ data: Instruction[];
1139
+ has_more: boolean;
1140
+ first_id: string | null;
1141
+ last_id: string | null;
1142
+ };
1143
+
1144
+ declare type InstructionUpdateRequest = {
1145
+ name?: string;
1146
+ prompt?: string;
1147
+ is_default?: boolean;
1148
+ };
1149
+
721
1150
  declare function inviteDeveloper(orgId: string, email: string, role?: string): Promise<OrganizationInvite>;
722
1151
 
723
1152
  declare function keyExchange(clientPublicKey: string, nonce: string, explicitApiUrl?: string): Promise<{
@@ -772,6 +1201,90 @@ export declare function listApiKeys(): Promise<{
772
1201
  keys: ApiKeyListResponse;
773
1202
  }>;
774
1203
 
1204
+ /**
1205
+ * @deprecated Use openai.conversations.items.list() instead
1206
+ * Lists items in a conversation
1207
+ * @param conversationId - The UUID of the conversation
1208
+ * @param params - Optional pagination parameters
1209
+ * @returns A promise resolving to a paginated list of conversation items
1210
+ * @throws {Error} If:
1211
+ * - The user is not authenticated
1212
+ * - The conversation is not found
1213
+ * - The user doesn't have access to the conversation
1214
+ *
1215
+ * @example
1216
+ * ```typescript
1217
+ * const items = await listConversationItems("550e8400-e29b-41d4-a716-446655440000", {
1218
+ * limit: 20
1219
+ * });
1220
+ * for (const item of items.data) {
1221
+ * console.log(item.role, item.content);
1222
+ * }
1223
+ * ```
1224
+ */
1225
+ declare function listConversationItems(conversationId: string, params?: {
1226
+ limit?: number;
1227
+ after?: string;
1228
+ before?: string;
1229
+ }): Promise<ConversationItemsResponse>;
1230
+
1231
+ /**
1232
+ * Lists all conversations with pagination (non-standard endpoint)
1233
+ * @param params - Optional pagination parameters
1234
+ * @returns A promise resolving to a paginated list of conversations
1235
+ * @throws {Error} If:
1236
+ * - The user is not authenticated
1237
+ * - The request fails
1238
+ *
1239
+ * @description
1240
+ * This is a custom extension not part of the standard OpenAI Conversations API.
1241
+ * This function fetches a paginated list of the user's conversations.
1242
+ * Conversations are sorted by created_at (most recent first).
1243
+ *
1244
+ * @example
1245
+ * ```typescript
1246
+ * const conversations = await listConversations({ limit: 20 });
1247
+ * for (const conv of conversations.data) {
1248
+ * console.log(conv.id, conv.metadata);
1249
+ * }
1250
+ * ```
1251
+ */
1252
+ declare function listConversations(params?: {
1253
+ limit?: number;
1254
+ after?: string;
1255
+ before?: string;
1256
+ }): Promise<ConversationsListResponse>;
1257
+
1258
+ /**
1259
+ * Lists user's instructions with pagination
1260
+ * @param params - Optional parameters for pagination and ordering
1261
+ * @returns A promise resolving to a paginated list of instructions
1262
+ * @throws {Error} If:\n * - The user is not authenticated
1263
+ * - The request fails
1264
+ *
1265
+ * @description
1266
+ * This function fetches a paginated list of the user's instructions.
1267
+ * Results are ordered by updated_at by default (most recently updated first).
1268
+ *
1269
+ * Query Parameters:
1270
+ * - limit: Number of results per page (1-100, default: 20)
1271
+ * - after: UUID cursor for forward pagination
1272
+ * - before: UUID cursor for backward pagination
1273
+ * - order: Sort order ("asc" or "desc", default: "desc")
1274
+ *
1275
+ * @example
1276
+ * ```typescript
1277
+ * const instructions = await listInstructions({ limit: 20 });
1278
+ *
1279
+ * // Next page
1280
+ * const nextPage = await listInstructions({
1281
+ * limit: 20,
1282
+ * after: instructions.last_id
1283
+ * });
1284
+ * ```
1285
+ */
1286
+ declare function listInstructions(params?: InstructionListParams): Promise<InstructionListResponse>;
1287
+
775
1288
  declare function listOrganizationInvites(orgId: string): Promise<OrganizationInvite[]>;
776
1289
 
777
1290
  declare function listOrganizationMembers(orgId: string): Promise<OrganizationMember[]>;
@@ -1131,7 +1644,7 @@ export declare type OpenSecretContextType = {
1131
1644
  * });
1132
1645
  * ```
1133
1646
  */
1134
- aiCustomFetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
1647
+ aiCustomFetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
1135
1648
  /**
1136
1649
  * Returns the current OpenSecret enclave API URL being used
1137
1650
  * @returns The current API URL
@@ -1418,6 +1931,152 @@ export declare type OpenSecretContextType = {
1418
1931
  * ```
1419
1932
  */
1420
1933
  transcribeAudio: typeof api.transcribeAudio;
1934
+ /**
1935
+ * Lists user's responses with pagination
1936
+ * @param params - Optional parameters for pagination and filtering
1937
+ * @returns A promise resolving to a paginated list of responses
1938
+ * @throws {Error} If:
1939
+ * - The user is not authenticated
1940
+ * - The request fails
1941
+ * - Invalid pagination parameters
1942
+ *
1943
+ * @description
1944
+ * This function fetches a paginated list of the user's responses.
1945
+ * In list view, the usage and output fields are always null for performance reasons.
1946
+ *
1947
+ * Query Parameters:
1948
+ * - limit: Number of results per page (1-100, default: 20)
1949
+ * - after: UUID cursor for forward pagination
1950
+ * - before: UUID cursor for backward pagination
1951
+ * - order: Sort order (currently not implemented, reserved for future use)
1952
+ *
1953
+ * Pagination Examples:
1954
+ * ```typescript
1955
+ * // First page
1956
+ * const responses = await context.fetchResponsesList({ limit: 20 });
1957
+ *
1958
+ * // Next page
1959
+ * const nextPage = await context.fetchResponsesList({
1960
+ * limit: 20,
1961
+ * after: responses.last_id
1962
+ * });
1963
+ *
1964
+ * // Previous page
1965
+ * const prevPage = await context.fetchResponsesList({
1966
+ * limit: 20,
1967
+ * before: responses.first_id
1968
+ * });
1969
+ * ```
1970
+ */
1971
+ fetchResponsesList: (params?: api.ResponsesListParams) => Promise<api.ResponsesListResponse>;
1972
+ /**
1973
+ * Retrieves a single response by ID
1974
+ * @param responseId - The UUID of the response to retrieve
1975
+ * @returns A promise resolving to the response details
1976
+ */
1977
+ fetchResponse: (responseId: string) => Promise<api.ResponsesRetrieveResponse>;
1978
+ /**
1979
+ * Cancels an in-progress response
1980
+ * @param responseId - The UUID of the response to cancel
1981
+ * @returns A promise resolving to the cancelled response
1982
+ */
1983
+ cancelResponse: (responseId: string) => Promise<api.ResponsesCancelResponse>;
1984
+ /**
1985
+ * Deletes a response permanently
1986
+ * @param responseId - The UUID of the response to delete
1987
+ * @returns A promise resolving to deletion confirmation
1988
+ */
1989
+ deleteResponse: (responseId: string) => Promise<api.ResponsesDeleteResponse>;
1990
+ /**
1991
+ * Creates a new response with conversation support
1992
+ * @param request - The request parameters for creating a response
1993
+ * @returns A promise resolving to the created response or a stream
1994
+ */
1995
+ createResponse: (request: api.ResponsesCreateRequest) => Promise<any>;
1996
+ /**
1997
+ * Lists all conversations with pagination (non-standard endpoint)
1998
+ * @param params - Optional pagination parameters
1999
+ * @returns A promise resolving to a paginated list of conversations
2000
+ * @description
2001
+ * This is a custom extension not part of the standard OpenAI API.
2002
+ * For standard conversation operations, use the OpenAI client directly:
2003
+ * - openai.conversations.create()
2004
+ * - openai.conversations.retrieve()
2005
+ * - openai.conversations.update()
2006
+ * - openai.conversations.delete()
2007
+ * - openai.conversations.items.list()
2008
+ * - openai.conversations.items.retrieve()
2009
+ */
2010
+ listConversations: (params?: {
2011
+ limit?: number;
2012
+ after?: string;
2013
+ before?: string;
2014
+ }) => Promise<api.ConversationsListResponse>;
2015
+ /**
2016
+ * Creates a new instruction
2017
+ * @param request - The instruction creation parameters
2018
+ * @returns A promise resolving to the created instruction
2019
+ * @throws {Error} If the user is not authenticated or the request fails
2020
+ *
2021
+ * @description
2022
+ * Creates a new user instruction (system prompt).
2023
+ * If is_default is set to true, all other instructions are automatically set to is_default: false.
2024
+ * The prompt_tokens field is automatically calculated.
2025
+ */
2026
+ createInstruction: typeof api.createInstruction;
2027
+ /**
2028
+ * Lists user's instructions with pagination
2029
+ * @param params - Optional parameters for pagination and ordering
2030
+ * @returns A promise resolving to a paginated list of instructions
2031
+ * @throws {Error} If the user is not authenticated or the request fails
2032
+ *
2033
+ * @description
2034
+ * Fetches a paginated list of the user's instructions.
2035
+ * Results are ordered by updated_at by default (most recently updated first).
2036
+ */
2037
+ listInstructions: typeof api.listInstructions;
2038
+ /**
2039
+ * Retrieves a single instruction by ID
2040
+ * @param instructionId - The UUID of the instruction to retrieve
2041
+ * @returns A promise resolving to the instruction details
2042
+ * @throws {Error} If the instruction is not found or user doesn't have access
2043
+ */
2044
+ getInstruction: typeof api.getInstruction;
2045
+ /**
2046
+ * Updates an existing instruction
2047
+ * @param instructionId - The UUID of the instruction to update
2048
+ * @param request - The fields to update
2049
+ * @returns A promise resolving to the updated instruction
2050
+ * @throws {Error} If the instruction is not found or validation fails
2051
+ *
2052
+ * @description
2053
+ * At least one field must be provided.
2054
+ * If is_default: true is set, all other instructions are automatically set to is_default: false.
2055
+ * The prompt_tokens field is recalculated automatically if prompt changes.
2056
+ */
2057
+ updateInstruction: typeof api.updateInstruction;
2058
+ /**
2059
+ * Deletes an instruction permanently
2060
+ * @param instructionId - The UUID of the instruction to delete
2061
+ * @returns A promise resolving to deletion confirmation
2062
+ * @throws {Error} If the instruction is not found or user doesn't have access
2063
+ *
2064
+ * @description
2065
+ * Permanently deletes an instruction. This action cannot be undone.
2066
+ */
2067
+ deleteInstruction: typeof api.deleteInstruction;
2068
+ /**
2069
+ * Sets an instruction as the default
2070
+ * @param instructionId - The UUID of the instruction to set as default
2071
+ * @returns A promise resolving to the updated instruction
2072
+ * @throws {Error} If the instruction is not found
2073
+ *
2074
+ * @description
2075
+ * Sets the specified instruction as the default.
2076
+ * All other instructions for this user are automatically set to is_default: false.
2077
+ * This operation is idempotent.
2078
+ */
2079
+ setDefaultInstruction: typeof api.setDefaultInstruction;
1421
2080
  };
1422
2081
 
1423
2082
  /**
@@ -2093,8 +2752,88 @@ declare function requestPasswordReset(email: string, hashedSecret: string, clien
2093
2752
  */
2094
2753
  declare function requestPlatformPasswordReset(email: string, hashedSecret: string): Promise<void>;
2095
2754
 
2755
+ export declare type ResponsesCancelResponse = {
2756
+ id: string;
2757
+ object: "response";
2758
+ created_at: number;
2759
+ status: "cancelled";
2760
+ model: string;
2761
+ };
2762
+
2763
+ export declare type ResponsesCreateRequest = {
2764
+ model: string;
2765
+ input: string;
2766
+ conversation?: string | {
2767
+ id: string;
2768
+ };
2769
+ previous_response_id?: string;
2770
+ stream?: boolean;
2771
+ metadata?: Record<string, any>;
2772
+ };
2773
+
2774
+ export declare type ResponsesDeleteResponse = {
2775
+ id: string;
2776
+ object: "response.deleted";
2777
+ deleted: boolean;
2778
+ };
2779
+
2780
+ export declare type ResponsesListParams = {
2781
+ limit?: number;
2782
+ after?: string;
2783
+ before?: string;
2784
+ order?: string;
2785
+ };
2786
+
2787
+ export declare type ResponsesListResponse = {
2788
+ object: "list";
2789
+ data: ThreadListItem[];
2790
+ has_more: boolean;
2791
+ first_id?: string;
2792
+ last_id?: string;
2793
+ };
2794
+
2795
+ export declare type ResponsesRetrieveResponse = {
2796
+ id: string;
2797
+ object: "response";
2798
+ created_at: number;
2799
+ status: "queued" | "in_progress" | "completed" | "failed" | "cancelled";
2800
+ model: string;
2801
+ usage?: {
2802
+ input_tokens: number;
2803
+ input_tokens_details: {
2804
+ cached_tokens: number;
2805
+ };
2806
+ output_tokens: number;
2807
+ output_tokens_details: {
2808
+ reasoning_tokens: number;
2809
+ };
2810
+ total_tokens: number;
2811
+ };
2812
+ output?: string;
2813
+ };
2814
+
2096
2815
  declare function setApiUrl(url: string): void;
2097
2816
 
2817
+ /**
2818
+ * Sets an instruction as the default
2819
+ * @param instructionId - The UUID of the instruction to set as default
2820
+ * @returns A promise resolving to the updated instruction
2821
+ * @throws {Error} If:\n * - The user is not authenticated
2822
+ * - The instruction is not found (404)
2823
+ *
2824
+ * @description
2825
+ * This function sets the specified instruction as the default.
2826
+ * All other instructions for this user are automatically set to is_default: false.
2827
+ * This operation is idempotent - calling it on an already-default instruction succeeds.
2828
+ *
2829
+ * @example
2830
+ * ```typescript
2831
+ * const instruction = await setDefaultInstruction("550e8400-e29b-41d4-a716-446655440000");
2832
+ * console.log(instruction.is_default); // Always true
2833
+ * ```
2834
+ */
2835
+ declare function setDefaultInstruction(instructionId: string): Promise<Instruction>;
2836
+
2098
2837
  declare function setPlatformApiUrl(url: string): void;
2099
2838
 
2100
2839
  declare type SigningAlgorithm = "schnorr" | "ecdsa";
@@ -2162,6 +2901,14 @@ declare type ThirdPartyTokenResponse = {
2162
2901
  token: string;
2163
2902
  };
2164
2903
 
2904
+ declare type ThreadListItem = {
2905
+ id: string;
2906
+ object: "thread";
2907
+ created_at: number;
2908
+ updated_at: number;
2909
+ title: string;
2910
+ };
2911
+
2165
2912
  /**
2166
2913
  * Transcribes audio using the Whisper API
2167
2914
  * @param file - The audio file to transcribe (File or Blob object)
@@ -2198,8 +2945,53 @@ declare type ThirdPartyTokenResponse = {
2198
2945
  */
2199
2946
  declare function transcribeAudio(file: File | Blob, model?: string, language?: string, prompt?: string, temperature?: number, apiKey?: string): Promise<WhisperTranscriptionResponse>;
2200
2947
 
2948
+ /**
2949
+ * @deprecated Use openai.conversations.update() instead
2950
+ * Updates a conversation's metadata
2951
+ * @param conversationId - The UUID of the conversation to update
2952
+ * @param metadata - The metadata to update
2953
+ * @returns A promise resolving to the updated conversation
2954
+ * @throws {Error} If:
2955
+ * - The user is not authenticated
2956
+ * - The conversation is not found
2957
+ * - The user doesn't have access to the conversation
2958
+ *
2959
+ * @example
2960
+ * ```typescript
2961
+ * const updated = await updateConversation("550e8400-e29b-41d4-a716-446655440000", {
2962
+ * metadata: { title: "Updated Title", status: "resolved" }
2963
+ * });
2964
+ * ```
2965
+ */
2966
+ declare function updateConversation(conversationId: string, metadata: Record<string, any>): Promise<Conversation>;
2967
+
2201
2968
  declare function updateEmailSettings(orgId: string, projectId: string, settings: EmailSettings): Promise<EmailSettings>;
2202
2969
 
2970
+ /**
2971
+ * Updates an existing instruction
2972
+ * @param instructionId - The UUID of the instruction to update
2973
+ * @param request - The fields to update
2974
+ * @returns A promise resolving to the updated instruction
2975
+ * @throws {Error} If:\n * - The user is not authenticated
2976
+ * - The instruction is not found (404)
2977
+ * - No fields are provided (400)
2978
+ * - Name or prompt are empty strings (400)
2979
+ *
2980
+ * @description
2981
+ * At least one field must be provided.
2982
+ * If is_default: true is set, all other instructions are automatically set to is_default: false.
2983
+ * The prompt_tokens field is recalculated automatically if prompt changes.
2984
+ *
2985
+ * @example
2986
+ * ```typescript
2987
+ * const updated = await updateInstruction("550e8400-e29b-41d4-a716-446655440000", {
2988
+ * name: "Updated Name",
2989
+ * prompt: "Updated prompt text"
2990
+ * });
2991
+ * ```
2992
+ */
2993
+ declare function updateInstruction(instructionId: string, request: InstructionUpdateRequest): Promise<Instruction>;
2994
+
2203
2995
  declare function updateMemberRole(orgId: string, userId: string, role: string): Promise<OrganizationMember>;
2204
2996
 
2205
2997
  declare function updateOAuthSettings(orgId: string, projectId: string, settings: OAuthSettings): Promise<OAuthSettings>;