@opensecret/react 1.4.3 → 1.5.1

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,25 @@ 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
+ deleteConversations,
89
+ addConversationItems,
90
+ listConversationItems,
91
+ listConversations,
92
+ createResponse,
93
+ deleteResponse,
94
+ createInstruction,
95
+ listInstructions,
96
+ getInstruction,
97
+ updateInstruction,
98
+ deleteInstruction,
99
+ setDefaultInstruction,
57
100
  LoginResponse,
58
101
  UserResponse,
59
102
  KVListItem,
@@ -81,7 +124,28 @@ declare namespace api {
81
124
  DocumentStatusRequest,
82
125
  DocumentStatusResponse,
83
126
  WhisperTranscriptionRequest,
84
- WhisperTranscriptionResponse
127
+ WhisperTranscriptionResponse,
128
+ ResponsesRetrieveResponse,
129
+ ThreadListItem,
130
+ ResponsesListResponse,
131
+ ResponsesListParams,
132
+ ConversationItem,
133
+ Conversation,
134
+ ConversationCreateRequest,
135
+ ConversationUpdateRequest,
136
+ ConversationItemsResponse,
137
+ ConversationsListResponse,
138
+ ConversationDeleteResponse,
139
+ ConversationsDeleteResponse,
140
+ ResponsesCancelResponse,
141
+ ResponsesDeleteResponse,
142
+ ResponsesCreateRequest,
143
+ Instruction,
144
+ InstructionCreateRequest,
145
+ InstructionUpdateRequest,
146
+ InstructionListParams,
147
+ InstructionListResponse,
148
+ InstructionDeleteResponse
85
149
  }
86
150
  }
87
151
 
@@ -215,6 +279,32 @@ declare function authenticate(attestationDocumentBase64: string, trustedRootCert
215
279
 
216
280
  declare const AWS_ROOT_CERT_DER: Uint8Array;
217
281
 
282
+ /**
283
+ * Cancels an in-progress response
284
+ * @param responseId - The UUID of the response to cancel
285
+ * @returns A promise resolving to the cancelled response
286
+ * @throws {Error} If:
287
+ * - The user is not authenticated
288
+ * - The response is not found
289
+ * - The response is not in 'in_progress' status
290
+ * - The user doesn't have access to the response
291
+ *
292
+ * @description
293
+ * This function cancels a response that is currently being processed.
294
+ * Only responses with status 'in_progress' can be cancelled.
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * try {
299
+ * const cancelled = await cancelResponse("550e8400-e29b-41d4-a716-446655440000");
300
+ * console.log("Response cancelled:", cancelled.status);
301
+ * } catch (error) {
302
+ * console.error("Cannot cancel:", error.message);
303
+ * }
304
+ * ```
305
+ */
306
+ declare function cancelResponse(responseId: string): Promise<ResponsesCancelResponse>;
307
+
218
308
  declare function changePassword(currentPassword: string, newPassword: string): Promise<void>;
219
309
 
220
310
  /**
@@ -298,6 +388,62 @@ declare function confirmPlatformPasswordReset(email: string, alphanumericCode: s
298
388
  message: string;
299
389
  }>;
300
390
 
391
+ export declare type Conversation = {
392
+ id: string;
393
+ object: "conversation";
394
+ created_at: number;
395
+ metadata?: Record<string, any>;
396
+ };
397
+
398
+ export declare type ConversationCreateRequest = {
399
+ metadata?: Record<string, any>;
400
+ };
401
+
402
+ export declare type ConversationDeleteResponse = {
403
+ id: string;
404
+ object: "conversation.deleted";
405
+ deleted: boolean;
406
+ };
407
+
408
+ export declare type ConversationItem = {
409
+ id: string;
410
+ type: "message";
411
+ status: "completed" | "in_progress" | "incomplete";
412
+ role: "user" | "assistant" | "system";
413
+ content: Array<{
414
+ type: "text" | "input_text" | "input_audio" | "item";
415
+ text?: string;
416
+ audio?: string;
417
+ transcript?: string;
418
+ id?: string;
419
+ }>;
420
+ };
421
+
422
+ export declare type ConversationItemsResponse = {
423
+ object: "list";
424
+ data: ConversationItem[];
425
+ first_id?: string;
426
+ last_id?: string;
427
+ has_more: boolean;
428
+ };
429
+
430
+ export declare type ConversationsDeleteResponse = {
431
+ object: "list.deleted";
432
+ deleted: boolean;
433
+ };
434
+
435
+ export declare type ConversationsListResponse = {
436
+ object: "list";
437
+ data: Conversation[];
438
+ first_id?: string;
439
+ last_id?: string;
440
+ has_more: boolean;
441
+ };
442
+
443
+ export declare type ConversationUpdateRequest = {
444
+ metadata?: Record<string, any>;
445
+ };
446
+
301
447
  declare function convertGuestToEmailAccount(email: string, password: string, name?: string | null): Promise<void>;
302
448
 
303
449
  /**
@@ -322,7 +468,56 @@ declare function convertGuestToEmailAccount(email: string, password: string, nam
322
468
  */
323
469
  export declare function createApiKey(name: string): Promise<ApiKeyCreateResponse>;
324
470
 
325
- export declare function createCustomFetch(options?: CustomFetchOptions): (url: RequestInfo, init?: RequestInit) => Promise<Response>;
471
+ /**
472
+ * Creates a new conversation
473
+ * @param metadata - Optional metadata to attach to the conversation
474
+ * @returns A promise resolving to the created conversation
475
+ * @throws {Error} If:
476
+ * - The user is not authenticated
477
+ * - The request fails
478
+ *
479
+ * @description
480
+ * This function creates a new conversation that can be used to group
481
+ * related responses together. The conversation can have metadata
482
+ * attached for organization and filtering purposes.
483
+ *
484
+ * NOTE: Prefer using the OpenAI client directly for conversation operations:
485
+ * ```typescript
486
+ * const openai = new OpenAI({ fetch: customFetch });
487
+ * const conversation = await openai.conversations.create({
488
+ * metadata: { title: "Product Support", category: "technical" }
489
+ * });
490
+ * ```
491
+ *
492
+ * @deprecated Use openai.conversations.create() instead
493
+ */
494
+ declare function createConversation(metadata?: Record<string, any>): Promise<Conversation>;
495
+
496
+ export declare function createCustomFetch(options?: CustomFetchOptions): (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
497
+
498
+ /**
499
+ * Creates a new instruction
500
+ * @param request - The instruction creation parameters
501
+ * @returns A promise resolving to the created instruction
502
+ * @throws {Error} If:\n * - The user is not authenticated
503
+ * - The request fails
504
+ * - Name or prompt are empty strings
505
+ *
506
+ * @description
507
+ * This function creates a new user instruction (system prompt).
508
+ * If is_default is set to true, all other instructions are automatically set to is_default: false.
509
+ * The prompt_tokens field is automatically calculated.
510
+ *
511
+ * @example
512
+ * ```typescript
513
+ * const instruction = await createInstruction({
514
+ * name: "Helpful Assistant",
515
+ * prompt: "You are a helpful assistant that...",
516
+ * is_default: true
517
+ * });
518
+ * ```
519
+ */
520
+ declare function createInstruction(request: InstructionCreateRequest): Promise<Instruction>;
326
521
 
327
522
  declare function createOrganization(name: string): Promise<Organization>;
328
523
 
@@ -330,6 +525,38 @@ declare function createProject(orgId: string, name: string, description?: string
330
525
 
331
526
  declare function createProjectSecret(orgId: string, projectId: string, keyName: string, secret: string): Promise<ProjectSecret>;
332
527
 
528
+ /**
529
+ * Creates a new response with conversation support
530
+ * @param request - The request parameters for creating a response
531
+ * @returns A promise resolving to the created response or a stream
532
+ * @throws {Error} If:
533
+ * - The user is not authenticated
534
+ * - The request fails
535
+ *
536
+ * @description
537
+ * This function creates a new response in the OpenAI-compatible API.
538
+ * It supports both the new conversation parameter and the deprecated
539
+ * previous_response_id parameter for backward compatibility.
540
+ *
541
+ * @example
542
+ * ```typescript
543
+ * // Create a response in a conversation
544
+ * const response = await createResponse({
545
+ * model: "gpt-4",
546
+ * input: "Hello, how are you?",
547
+ * conversation: "550e8400-e29b-41d4-a716-446655440000"
548
+ * });
549
+ *
550
+ * // Or with the deprecated previous_response_id
551
+ * const response = await createResponse({
552
+ * model: "gpt-4",
553
+ * input: "Tell me more",
554
+ * previous_response_id: "response-uuid"
555
+ * });
556
+ * ```
557
+ */
558
+ declare function createResponse(request: ResponsesCreateRequest): Promise<any>;
559
+
333
560
  export declare interface CustomFetchOptions {
334
561
  apiKey?: string;
335
562
  }
@@ -401,6 +628,73 @@ declare type DecryptDataRequest = {
401
628
  */
402
629
  export declare function deleteApiKey(name: string): Promise<void>;
403
630
 
631
+ /**
632
+ * @deprecated Use openai.conversations.delete() instead
633
+ * Deletes a conversation permanently
634
+ * @param conversationId - The UUID of the conversation to delete
635
+ * @returns A promise resolving to deletion confirmation
636
+ * @throws {Error} If:
637
+ * - The user is not authenticated
638
+ * - The conversation is not found
639
+ * - The user doesn't have access to the conversation
640
+ *
641
+ * @description
642
+ * This function permanently deletes a conversation and all associated items.
643
+ * This action cannot be undone.
644
+ *
645
+ * @example
646
+ * ```typescript
647
+ * const result = await deleteConversation("550e8400-e29b-41d4-a716-446655440000");
648
+ * if (result.deleted) {
649
+ * console.log("Conversation deleted successfully");
650
+ * }
651
+ * ```
652
+ */
653
+ declare function deleteConversation(conversationId: string): Promise<ConversationDeleteResponse>;
654
+
655
+ /**
656
+ * Deletes all conversations
657
+ * @returns A promise resolving to deletion confirmation
658
+ * @throws {Error} If:
659
+ * - The user is not authenticated
660
+ * - The request fails
661
+ *
662
+ * @description
663
+ * This function permanently deletes all conversations and their associated items.
664
+ * This action cannot be undone.
665
+ *
666
+ * @example
667
+ * ```typescript
668
+ * const result = await deleteConversations();
669
+ * if (result.deleted) {
670
+ * console.log("All conversations deleted successfully");
671
+ * }
672
+ * ```
673
+ */
674
+ declare function deleteConversations(): Promise<ConversationsDeleteResponse>;
675
+
676
+ /**
677
+ * Deletes an instruction permanently
678
+ * @param instructionId - The UUID of the instruction to delete
679
+ * @returns A promise resolving to deletion confirmation
680
+ * @throws {Error} If:\n * - The user is not authenticated
681
+ * - The instruction is not found (404)
682
+ * - The user doesn't have access to the instruction
683
+ *
684
+ * @description
685
+ * This function permanently deletes an instruction.
686
+ * This action cannot be undone.
687
+ *
688
+ * @example
689
+ * ```typescript
690
+ * const result = await deleteInstruction("550e8400-e29b-41d4-a716-446655440000");
691
+ * if (result.deleted) {
692
+ * console.log("Instruction deleted successfully");
693
+ * }
694
+ * ```
695
+ */
696
+ declare function deleteInstruction(instructionId: string): Promise<InstructionDeleteResponse>;
697
+
404
698
  declare function deleteOrganization(orgId: string): Promise<void>;
405
699
 
406
700
  declare function deleteOrganizationInvite(orgId: string, inviteCode: string): Promise<{
@@ -411,6 +705,29 @@ declare function deleteProject(orgId: string, projectId: string): Promise<void>;
411
705
 
412
706
  declare function deleteProjectSecret(orgId: string, projectId: string, keyName: string): Promise<void>;
413
707
 
708
+ /**
709
+ * Deletes a response permanently
710
+ * @param responseId - The UUID of the response to delete
711
+ * @returns A promise resolving to deletion confirmation
712
+ * @throws {Error} If:
713
+ * - The user is not authenticated
714
+ * - The response is not found
715
+ * - The user doesn't have access to the response
716
+ *
717
+ * @description
718
+ * This function permanently deletes a response and all associated data.
719
+ * This action cannot be undone.
720
+ *
721
+ * @example
722
+ * ```typescript
723
+ * const result = await deleteResponse("550e8400-e29b-41d4-a716-446655440000");
724
+ * if (result.deleted) {
725
+ * console.log("Response deleted successfully");
726
+ * }
727
+ * ```
728
+ */
729
+ declare function deleteResponse(responseId: string): Promise<ResponsesDeleteResponse>;
730
+
414
731
  declare type DeveloperResponse = PlatformUser & {
415
732
  organizations: PlatformOrg[];
416
733
  };
@@ -609,6 +926,68 @@ declare function fetchPublicKey(algorithm: SigningAlgorithm, key_options?: KeyOp
609
926
 
610
927
  declare function fetchPut(key: string, value: string): Promise<string>;
611
928
 
929
+ /**
930
+ * Retrieves a single response by ID
931
+ * @param responseId - The UUID of the response to retrieve
932
+ * @returns A promise resolving to the response details
933
+ * @throws {Error} If:
934
+ * - The user is not authenticated
935
+ * - The response is not found
936
+ * - The user doesn't have access to the response
937
+ *
938
+ * @description
939
+ * This function fetches detailed information about a specific response,
940
+ * including full output and usage statistics.
941
+ *
942
+ * @example
943
+ * ```typescript
944
+ * const response = await fetchResponse("550e8400-e29b-41d4-a716-446655440000");
945
+ * console.log(response.output); // The full response text
946
+ * console.log(response.usage); // Token usage statistics
947
+ * ```
948
+ */
949
+ declare function fetchResponse(responseId: string): Promise<ResponsesRetrieveResponse>;
950
+
951
+ /**
952
+ * Lists user's conversation threads with pagination
953
+ * @param params - Optional parameters for pagination and filtering
954
+ * @returns A promise resolving to a paginated list of conversation threads
955
+ * @throws {Error} If:
956
+ * - The user is not authenticated
957
+ * - The request fails
958
+ * - Invalid pagination parameters
959
+ *
960
+ * @description
961
+ * This function fetches a paginated list of the user's conversation threads.
962
+ * Each thread represents a conversation, not individual messages.
963
+ * Threads are sorted by updated_at (most recently active threads first).
964
+ *
965
+ * Query Parameters:
966
+ * - limit: Number of results per page (1-100, default: 20)
967
+ * - after: UUID cursor for forward pagination
968
+ * - before: UUID cursor for backward pagination
969
+ * - order: Sort order (currently not implemented, reserved for future use)
970
+ *
971
+ * Pagination Examples:
972
+ * ```typescript
973
+ * // First page
974
+ * const threads = await fetchResponsesList({ limit: 20 });
975
+ *
976
+ * // Next page
977
+ * const nextPage = await fetchResponsesList({
978
+ * limit: 20,
979
+ * after: threads.last_id
980
+ * });
981
+ *
982
+ * // Previous page
983
+ * const prevPage = await fetchResponsesList({
984
+ * limit: 20,
985
+ * before: threads.first_id
986
+ * });
987
+ * ```
988
+ */
989
+ declare function fetchResponsesList(params?: ResponsesListParams): Promise<ResponsesListResponse>;
990
+
612
991
  declare function fetchSignUp(email: string, password: string, inviteCode: string, client_id: string, name?: string | null): Promise<LoginResponse>;
613
992
 
614
993
  declare function fetchUser(): Promise<UserResponse>;
@@ -630,8 +1009,42 @@ declare function getApiUrl(): string;
630
1009
 
631
1010
  declare function getAttestation(forceRefresh?: boolean, explicitApiUrl?: string): Promise<Attestation>;
632
1011
 
1012
+ /**
1013
+ * @deprecated Use openai.conversations.retrieve() instead
1014
+ * Retrieves a conversation by ID
1015
+ * @param conversationId - The UUID of the conversation to retrieve
1016
+ * @returns A promise resolving to the conversation
1017
+ * @throws {Error} If:
1018
+ * - The user is not authenticated
1019
+ * - The conversation is not found
1020
+ * - The user doesn't have access to the conversation
1021
+ *
1022
+ * @example
1023
+ * ```typescript
1024
+ * const conversation = await getConversation("550e8400-e29b-41d4-a716-446655440000");
1025
+ * console.log(conversation.metadata);
1026
+ * ```
1027
+ */
1028
+ declare function getConversation(conversationId: string): Promise<Conversation>;
1029
+
633
1030
  declare function getEmailSettings(orgId: string, projectId: string): Promise<EmailSettings>;
634
1031
 
1032
+ /**
1033
+ * Retrieves a single instruction by ID
1034
+ * @param instructionId - The UUID of the instruction to retrieve
1035
+ * @returns A promise resolving to the instruction details
1036
+ * @throws {Error} If:\n * - The user is not authenticated
1037
+ * - The instruction is not found (404)
1038
+ * - The user doesn't have access to the instruction
1039
+ *
1040
+ * @example
1041
+ * ```typescript
1042
+ * const instruction = await getInstruction("550e8400-e29b-41d4-a716-446655440000");
1043
+ * console.log(instruction.name, instruction.prompt);
1044
+ * ```
1045
+ */
1046
+ declare function getInstruction(instructionId: string): Promise<Instruction>;
1047
+
635
1048
  declare function getOAuthSettings(orgId: string, projectId: string): Promise<OAuthSettings>;
636
1049
 
637
1050
  declare function getOrganizationInvite(orgId: string, inviteCode: string): Promise<OrganizationInvite>;
@@ -718,6 +1131,50 @@ declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Pro
718
1131
 
719
1132
  declare function initiateGoogleAuth(client_id: string, inviteCode?: string): Promise<GoogleAuthResponse>;
720
1133
 
1134
+ declare type Instruction = {
1135
+ id: string;
1136
+ object: "instruction";
1137
+ name: string;
1138
+ prompt: string;
1139
+ prompt_tokens: number;
1140
+ is_default: boolean;
1141
+ created_at: number;
1142
+ updated_at: number;
1143
+ };
1144
+
1145
+ declare type InstructionCreateRequest = {
1146
+ name: string;
1147
+ prompt: string;
1148
+ is_default?: boolean;
1149
+ };
1150
+
1151
+ declare type InstructionDeleteResponse = {
1152
+ id: string;
1153
+ object: "instruction.deleted";
1154
+ deleted: true;
1155
+ };
1156
+
1157
+ declare type InstructionListParams = {
1158
+ limit?: number;
1159
+ after?: string;
1160
+ before?: string;
1161
+ order?: string;
1162
+ };
1163
+
1164
+ declare type InstructionListResponse = {
1165
+ object: "list";
1166
+ data: Instruction[];
1167
+ has_more: boolean;
1168
+ first_id: string | null;
1169
+ last_id: string | null;
1170
+ };
1171
+
1172
+ declare type InstructionUpdateRequest = {
1173
+ name?: string;
1174
+ prompt?: string;
1175
+ is_default?: boolean;
1176
+ };
1177
+
721
1178
  declare function inviteDeveloper(orgId: string, email: string, role?: string): Promise<OrganizationInvite>;
722
1179
 
723
1180
  declare function keyExchange(clientPublicKey: string, nonce: string, explicitApiUrl?: string): Promise<{
@@ -772,6 +1229,90 @@ export declare function listApiKeys(): Promise<{
772
1229
  keys: ApiKeyListResponse;
773
1230
  }>;
774
1231
 
1232
+ /**
1233
+ * @deprecated Use openai.conversations.items.list() instead
1234
+ * Lists items in a conversation
1235
+ * @param conversationId - The UUID of the conversation
1236
+ * @param params - Optional pagination parameters
1237
+ * @returns A promise resolving to a paginated list of conversation items
1238
+ * @throws {Error} If:
1239
+ * - The user is not authenticated
1240
+ * - The conversation is not found
1241
+ * - The user doesn't have access to the conversation
1242
+ *
1243
+ * @example
1244
+ * ```typescript
1245
+ * const items = await listConversationItems("550e8400-e29b-41d4-a716-446655440000", {
1246
+ * limit: 20
1247
+ * });
1248
+ * for (const item of items.data) {
1249
+ * console.log(item.role, item.content);
1250
+ * }
1251
+ * ```
1252
+ */
1253
+ declare function listConversationItems(conversationId: string, params?: {
1254
+ limit?: number;
1255
+ after?: string;
1256
+ before?: string;
1257
+ }): Promise<ConversationItemsResponse>;
1258
+
1259
+ /**
1260
+ * Lists all conversations with pagination (non-standard endpoint)
1261
+ * @param params - Optional pagination parameters
1262
+ * @returns A promise resolving to a paginated list of conversations
1263
+ * @throws {Error} If:
1264
+ * - The user is not authenticated
1265
+ * - The request fails
1266
+ *
1267
+ * @description
1268
+ * This is a custom extension not part of the standard OpenAI Conversations API.
1269
+ * This function fetches a paginated list of the user's conversations.
1270
+ * Conversations are sorted by created_at (most recent first).
1271
+ *
1272
+ * @example
1273
+ * ```typescript
1274
+ * const conversations = await listConversations({ limit: 20 });
1275
+ * for (const conv of conversations.data) {
1276
+ * console.log(conv.id, conv.metadata);
1277
+ * }
1278
+ * ```
1279
+ */
1280
+ declare function listConversations(params?: {
1281
+ limit?: number;
1282
+ after?: string;
1283
+ before?: string;
1284
+ }): Promise<ConversationsListResponse>;
1285
+
1286
+ /**
1287
+ * Lists user's instructions with pagination
1288
+ * @param params - Optional parameters for pagination and ordering
1289
+ * @returns A promise resolving to a paginated list of instructions
1290
+ * @throws {Error} If:\n * - The user is not authenticated
1291
+ * - The request fails
1292
+ *
1293
+ * @description
1294
+ * This function fetches a paginated list of the user's instructions.
1295
+ * Results are ordered by updated_at by default (most recently updated first).
1296
+ *
1297
+ * Query Parameters:
1298
+ * - limit: Number of results per page (1-100, default: 20)
1299
+ * - after: UUID cursor for forward pagination
1300
+ * - before: UUID cursor for backward pagination
1301
+ * - order: Sort order ("asc" or "desc", default: "desc")
1302
+ *
1303
+ * @example
1304
+ * ```typescript
1305
+ * const instructions = await listInstructions({ limit: 20 });
1306
+ *
1307
+ * // Next page
1308
+ * const nextPage = await listInstructions({
1309
+ * limit: 20,
1310
+ * after: instructions.last_id
1311
+ * });
1312
+ * ```
1313
+ */
1314
+ declare function listInstructions(params?: InstructionListParams): Promise<InstructionListResponse>;
1315
+
775
1316
  declare function listOrganizationInvites(orgId: string): Promise<OrganizationInvite[]>;
776
1317
 
777
1318
  declare function listOrganizationMembers(orgId: string): Promise<OrganizationMember[]>;
@@ -1131,7 +1672,7 @@ export declare type OpenSecretContextType = {
1131
1672
  * });
1132
1673
  * ```
1133
1674
  */
1134
- aiCustomFetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
1675
+ aiCustomFetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
1135
1676
  /**
1136
1677
  * Returns the current OpenSecret enclave API URL being used
1137
1678
  * @returns The current API URL
@@ -1418,6 +1959,157 @@ export declare type OpenSecretContextType = {
1418
1959
  * ```
1419
1960
  */
1420
1961
  transcribeAudio: typeof api.transcribeAudio;
1962
+ /**
1963
+ * Lists user's responses with pagination
1964
+ * @param params - Optional parameters for pagination and filtering
1965
+ * @returns A promise resolving to a paginated list of responses
1966
+ * @throws {Error} If:
1967
+ * - The user is not authenticated
1968
+ * - The request fails
1969
+ * - Invalid pagination parameters
1970
+ *
1971
+ * @description
1972
+ * This function fetches a paginated list of the user's responses.
1973
+ * In list view, the usage and output fields are always null for performance reasons.
1974
+ *
1975
+ * Query Parameters:
1976
+ * - limit: Number of results per page (1-100, default: 20)
1977
+ * - after: UUID cursor for forward pagination
1978
+ * - before: UUID cursor for backward pagination
1979
+ * - order: Sort order (currently not implemented, reserved for future use)
1980
+ *
1981
+ * Pagination Examples:
1982
+ * ```typescript
1983
+ * // First page
1984
+ * const responses = await context.fetchResponsesList({ limit: 20 });
1985
+ *
1986
+ * // Next page
1987
+ * const nextPage = await context.fetchResponsesList({
1988
+ * limit: 20,
1989
+ * after: responses.last_id
1990
+ * });
1991
+ *
1992
+ * // Previous page
1993
+ * const prevPage = await context.fetchResponsesList({
1994
+ * limit: 20,
1995
+ * before: responses.first_id
1996
+ * });
1997
+ * ```
1998
+ */
1999
+ fetchResponsesList: (params?: api.ResponsesListParams) => Promise<api.ResponsesListResponse>;
2000
+ /**
2001
+ * Retrieves a single response by ID
2002
+ * @param responseId - The UUID of the response to retrieve
2003
+ * @returns A promise resolving to the response details
2004
+ */
2005
+ fetchResponse: (responseId: string) => Promise<api.ResponsesRetrieveResponse>;
2006
+ /**
2007
+ * Cancels an in-progress response
2008
+ * @param responseId - The UUID of the response to cancel
2009
+ * @returns A promise resolving to the cancelled response
2010
+ */
2011
+ cancelResponse: (responseId: string) => Promise<api.ResponsesCancelResponse>;
2012
+ /**
2013
+ * Deletes a response permanently
2014
+ * @param responseId - The UUID of the response to delete
2015
+ * @returns A promise resolving to deletion confirmation
2016
+ */
2017
+ deleteResponse: (responseId: string) => Promise<api.ResponsesDeleteResponse>;
2018
+ /**
2019
+ * Creates a new response with conversation support
2020
+ * @param request - The request parameters for creating a response
2021
+ * @returns A promise resolving to the created response or a stream
2022
+ */
2023
+ createResponse: (request: api.ResponsesCreateRequest) => Promise<any>;
2024
+ /**
2025
+ * Lists all conversations with pagination (non-standard endpoint)
2026
+ * @param params - Optional pagination parameters
2027
+ * @returns A promise resolving to a paginated list of conversations
2028
+ * @description
2029
+ * This is a custom extension not part of the standard OpenAI API.
2030
+ * For standard conversation operations, use the OpenAI client directly:
2031
+ * - openai.conversations.create()
2032
+ * - openai.conversations.retrieve()
2033
+ * - openai.conversations.update()
2034
+ * - openai.conversations.delete()
2035
+ * - openai.conversations.items.list()
2036
+ * - openai.conversations.items.retrieve()
2037
+ */
2038
+ listConversations: (params?: {
2039
+ limit?: number;
2040
+ after?: string;
2041
+ before?: string;
2042
+ }) => Promise<api.ConversationsListResponse>;
2043
+ /**
2044
+ * Deletes all conversations
2045
+ * @returns A promise resolving to deletion confirmation
2046
+ */
2047
+ deleteConversations: typeof api.deleteConversations;
2048
+ /**
2049
+ * Creates a new instruction
2050
+ * @param request - The instruction creation parameters
2051
+ * @returns A promise resolving to the created instruction
2052
+ * @throws {Error} If the user is not authenticated or the request fails
2053
+ *
2054
+ * @description
2055
+ * Creates a new user instruction (system prompt).
2056
+ * If is_default is set to true, all other instructions are automatically set to is_default: false.
2057
+ * The prompt_tokens field is automatically calculated.
2058
+ */
2059
+ createInstruction: typeof api.createInstruction;
2060
+ /**
2061
+ * Lists user's instructions with pagination
2062
+ * @param params - Optional parameters for pagination and ordering
2063
+ * @returns A promise resolving to a paginated list of instructions
2064
+ * @throws {Error} If the user is not authenticated or the request fails
2065
+ *
2066
+ * @description
2067
+ * Fetches a paginated list of the user's instructions.
2068
+ * Results are ordered by updated_at by default (most recently updated first).
2069
+ */
2070
+ listInstructions: typeof api.listInstructions;
2071
+ /**
2072
+ * Retrieves a single instruction by ID
2073
+ * @param instructionId - The UUID of the instruction to retrieve
2074
+ * @returns A promise resolving to the instruction details
2075
+ * @throws {Error} If the instruction is not found or user doesn't have access
2076
+ */
2077
+ getInstruction: typeof api.getInstruction;
2078
+ /**
2079
+ * Updates an existing instruction
2080
+ * @param instructionId - The UUID of the instruction to update
2081
+ * @param request - The fields to update
2082
+ * @returns A promise resolving to the updated instruction
2083
+ * @throws {Error} If the instruction is not found or validation fails
2084
+ *
2085
+ * @description
2086
+ * At least one field must be provided.
2087
+ * If is_default: true is set, all other instructions are automatically set to is_default: false.
2088
+ * The prompt_tokens field is recalculated automatically if prompt changes.
2089
+ */
2090
+ updateInstruction: typeof api.updateInstruction;
2091
+ /**
2092
+ * Deletes an instruction permanently
2093
+ * @param instructionId - The UUID of the instruction to delete
2094
+ * @returns A promise resolving to deletion confirmation
2095
+ * @throws {Error} If the instruction is not found or user doesn't have access
2096
+ *
2097
+ * @description
2098
+ * Permanently deletes an instruction. This action cannot be undone.
2099
+ */
2100
+ deleteInstruction: typeof api.deleteInstruction;
2101
+ /**
2102
+ * Sets an instruction as the default
2103
+ * @param instructionId - The UUID of the instruction to set as default
2104
+ * @returns A promise resolving to the updated instruction
2105
+ * @throws {Error} If the instruction is not found
2106
+ *
2107
+ * @description
2108
+ * Sets the specified instruction as the default.
2109
+ * All other instructions for this user are automatically set to is_default: false.
2110
+ * This operation is idempotent.
2111
+ */
2112
+ setDefaultInstruction: typeof api.setDefaultInstruction;
1421
2113
  };
1422
2114
 
1423
2115
  /**
@@ -2093,8 +2785,88 @@ declare function requestPasswordReset(email: string, hashedSecret: string, clien
2093
2785
  */
2094
2786
  declare function requestPlatformPasswordReset(email: string, hashedSecret: string): Promise<void>;
2095
2787
 
2788
+ export declare type ResponsesCancelResponse = {
2789
+ id: string;
2790
+ object: "response";
2791
+ created_at: number;
2792
+ status: "cancelled";
2793
+ model: string;
2794
+ };
2795
+
2796
+ export declare type ResponsesCreateRequest = {
2797
+ model: string;
2798
+ input: string;
2799
+ conversation?: string | {
2800
+ id: string;
2801
+ };
2802
+ previous_response_id?: string;
2803
+ stream?: boolean;
2804
+ metadata?: Record<string, any>;
2805
+ };
2806
+
2807
+ export declare type ResponsesDeleteResponse = {
2808
+ id: string;
2809
+ object: "response.deleted";
2810
+ deleted: boolean;
2811
+ };
2812
+
2813
+ export declare type ResponsesListParams = {
2814
+ limit?: number;
2815
+ after?: string;
2816
+ before?: string;
2817
+ order?: string;
2818
+ };
2819
+
2820
+ export declare type ResponsesListResponse = {
2821
+ object: "list";
2822
+ data: ThreadListItem[];
2823
+ has_more: boolean;
2824
+ first_id?: string;
2825
+ last_id?: string;
2826
+ };
2827
+
2828
+ export declare type ResponsesRetrieveResponse = {
2829
+ id: string;
2830
+ object: "response";
2831
+ created_at: number;
2832
+ status: "queued" | "in_progress" | "completed" | "failed" | "cancelled";
2833
+ model: string;
2834
+ usage?: {
2835
+ input_tokens: number;
2836
+ input_tokens_details: {
2837
+ cached_tokens: number;
2838
+ };
2839
+ output_tokens: number;
2840
+ output_tokens_details: {
2841
+ reasoning_tokens: number;
2842
+ };
2843
+ total_tokens: number;
2844
+ };
2845
+ output?: string | any[];
2846
+ };
2847
+
2096
2848
  declare function setApiUrl(url: string): void;
2097
2849
 
2850
+ /**
2851
+ * Sets an instruction as the default
2852
+ * @param instructionId - The UUID of the instruction to set as default
2853
+ * @returns A promise resolving to the updated instruction
2854
+ * @throws {Error} If:\n * - The user is not authenticated
2855
+ * - The instruction is not found (404)
2856
+ *
2857
+ * @description
2858
+ * This function sets the specified instruction as the default.
2859
+ * All other instructions for this user are automatically set to is_default: false.
2860
+ * This operation is idempotent - calling it on an already-default instruction succeeds.
2861
+ *
2862
+ * @example
2863
+ * ```typescript
2864
+ * const instruction = await setDefaultInstruction("550e8400-e29b-41d4-a716-446655440000");
2865
+ * console.log(instruction.is_default); // Always true
2866
+ * ```
2867
+ */
2868
+ declare function setDefaultInstruction(instructionId: string): Promise<Instruction>;
2869
+
2098
2870
  declare function setPlatformApiUrl(url: string): void;
2099
2871
 
2100
2872
  declare type SigningAlgorithm = "schnorr" | "ecdsa";
@@ -2162,6 +2934,14 @@ declare type ThirdPartyTokenResponse = {
2162
2934
  token: string;
2163
2935
  };
2164
2936
 
2937
+ declare type ThreadListItem = {
2938
+ id: string;
2939
+ object: "thread";
2940
+ created_at: number;
2941
+ updated_at: number;
2942
+ title: string;
2943
+ };
2944
+
2165
2945
  /**
2166
2946
  * Transcribes audio using the Whisper API
2167
2947
  * @param file - The audio file to transcribe (File or Blob object)
@@ -2198,8 +2978,53 @@ declare type ThirdPartyTokenResponse = {
2198
2978
  */
2199
2979
  declare function transcribeAudio(file: File | Blob, model?: string, language?: string, prompt?: string, temperature?: number, apiKey?: string): Promise<WhisperTranscriptionResponse>;
2200
2980
 
2981
+ /**
2982
+ * @deprecated Use openai.conversations.update() instead
2983
+ * Updates a conversation's metadata
2984
+ * @param conversationId - The UUID of the conversation to update
2985
+ * @param metadata - The metadata to update
2986
+ * @returns A promise resolving to the updated conversation
2987
+ * @throws {Error} If:
2988
+ * - The user is not authenticated
2989
+ * - The conversation is not found
2990
+ * - The user doesn't have access to the conversation
2991
+ *
2992
+ * @example
2993
+ * ```typescript
2994
+ * const updated = await updateConversation("550e8400-e29b-41d4-a716-446655440000", {
2995
+ * metadata: { title: "Updated Title", status: "resolved" }
2996
+ * });
2997
+ * ```
2998
+ */
2999
+ declare function updateConversation(conversationId: string, metadata: Record<string, any>): Promise<Conversation>;
3000
+
2201
3001
  declare function updateEmailSettings(orgId: string, projectId: string, settings: EmailSettings): Promise<EmailSettings>;
2202
3002
 
3003
+ /**
3004
+ * Updates an existing instruction
3005
+ * @param instructionId - The UUID of the instruction to update
3006
+ * @param request - The fields to update
3007
+ * @returns A promise resolving to the updated instruction
3008
+ * @throws {Error} If:\n * - The user is not authenticated
3009
+ * - The instruction is not found (404)
3010
+ * - No fields are provided (400)
3011
+ * - Name or prompt are empty strings (400)
3012
+ *
3013
+ * @description
3014
+ * At least one field must be provided.
3015
+ * If is_default: true is set, all other instructions are automatically set to is_default: false.
3016
+ * The prompt_tokens field is recalculated automatically if prompt changes.
3017
+ *
3018
+ * @example
3019
+ * ```typescript
3020
+ * const updated = await updateInstruction("550e8400-e29b-41d4-a716-446655440000", {
3021
+ * name: "Updated Name",
3022
+ * prompt: "Updated prompt text"
3023
+ * });
3024
+ * ```
3025
+ */
3026
+ declare function updateInstruction(instructionId: string, request: InstructionUpdateRequest): Promise<Instruction>;
3027
+
2203
3028
  declare function updateMemberRole(orgId: string, userId: string, role: string): Promise<OrganizationMember>;
2204
3029
 
2205
3030
  declare function updateOAuthSettings(orgId: string, projectId: string, settings: OAuthSettings): Promise<OAuthSettings>;