@vectorize-io/hindsight-client 0.4.10 → 0.4.12
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/generated/sdk.gen.d.ts +49 -2
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/sdk.gen.js +68 -1
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/types.gen.d.ts +252 -1
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/src/index.d.ts +31 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +45 -2
- package/dist/src/index.js.map +1 -1
- package/generated/sdk.gen.ts +112 -1
- package/generated/types.gen.ts +283 -1
- package/package.json +1 -1
- package/src/index.ts +67 -2
package/generated/types.gen.ts
CHANGED
|
@@ -59,6 +59,52 @@ export type BackgroundResponse = {
|
|
|
59
59
|
disposition?: DispositionTraits | null;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* BankConfigResponse
|
|
64
|
+
*
|
|
65
|
+
* Response model for bank configuration.
|
|
66
|
+
*/
|
|
67
|
+
export type BankConfigResponse = {
|
|
68
|
+
/**
|
|
69
|
+
* Bank Id
|
|
70
|
+
*
|
|
71
|
+
* Bank identifier
|
|
72
|
+
*/
|
|
73
|
+
bank_id: string;
|
|
74
|
+
/**
|
|
75
|
+
* Config
|
|
76
|
+
*
|
|
77
|
+
* Fully resolved configuration with all hierarchical overrides applied (Python field names)
|
|
78
|
+
*/
|
|
79
|
+
config: {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Overrides
|
|
84
|
+
*
|
|
85
|
+
* Bank-specific configuration overrides only (Python field names)
|
|
86
|
+
*/
|
|
87
|
+
overrides: {
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* BankConfigUpdate
|
|
94
|
+
*
|
|
95
|
+
* Request model for updating bank configuration.
|
|
96
|
+
*/
|
|
97
|
+
export type BankConfigUpdate = {
|
|
98
|
+
/**
|
|
99
|
+
* Updates
|
|
100
|
+
*
|
|
101
|
+
* Configuration overrides. Keys can be in Python field format (llm_provider) or environment variable format (HINDSIGHT_API_LLM_PROVIDER). Only hierarchical fields can be overridden per-bank.
|
|
102
|
+
*/
|
|
103
|
+
updates: {
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
62
108
|
/**
|
|
63
109
|
* BankListItem
|
|
64
110
|
*
|
|
@@ -205,6 +251,24 @@ export type BankStatsResponse = {
|
|
|
205
251
|
total_observations?: number;
|
|
206
252
|
};
|
|
207
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Body_file_retain
|
|
256
|
+
*/
|
|
257
|
+
export type BodyFileRetain = {
|
|
258
|
+
/**
|
|
259
|
+
* Files
|
|
260
|
+
*
|
|
261
|
+
* Files to upload and convert
|
|
262
|
+
*/
|
|
263
|
+
files: Array<Blob | File>;
|
|
264
|
+
/**
|
|
265
|
+
* Request
|
|
266
|
+
*
|
|
267
|
+
* JSON string with FileRetainRequest model
|
|
268
|
+
*/
|
|
269
|
+
request: string;
|
|
270
|
+
};
|
|
271
|
+
|
|
208
272
|
/**
|
|
209
273
|
* Budget
|
|
210
274
|
*
|
|
@@ -232,6 +296,34 @@ export type CancelOperationResponse = {
|
|
|
232
296
|
operation_id: string;
|
|
233
297
|
};
|
|
234
298
|
|
|
299
|
+
/**
|
|
300
|
+
* ChildOperationStatus
|
|
301
|
+
*
|
|
302
|
+
* Status of a child operation (for batch operations).
|
|
303
|
+
*/
|
|
304
|
+
export type ChildOperationStatus = {
|
|
305
|
+
/**
|
|
306
|
+
* Operation Id
|
|
307
|
+
*/
|
|
308
|
+
operation_id: string;
|
|
309
|
+
/**
|
|
310
|
+
* Status
|
|
311
|
+
*/
|
|
312
|
+
status: string;
|
|
313
|
+
/**
|
|
314
|
+
* Sub Batch Index
|
|
315
|
+
*/
|
|
316
|
+
sub_batch_index?: number | null;
|
|
317
|
+
/**
|
|
318
|
+
* Items Count
|
|
319
|
+
*/
|
|
320
|
+
items_count?: number | null;
|
|
321
|
+
/**
|
|
322
|
+
* Error Message
|
|
323
|
+
*/
|
|
324
|
+
error_message?: string | null;
|
|
325
|
+
};
|
|
326
|
+
|
|
235
327
|
/**
|
|
236
328
|
* ChunkData
|
|
237
329
|
*
|
|
@@ -816,6 +908,32 @@ export type FeaturesInfo = {
|
|
|
816
908
|
* Whether the background worker is enabled
|
|
817
909
|
*/
|
|
818
910
|
worker: boolean;
|
|
911
|
+
/**
|
|
912
|
+
* Bank Config Api
|
|
913
|
+
*
|
|
914
|
+
* Whether per-bank configuration API is enabled
|
|
915
|
+
*/
|
|
916
|
+
bank_config_api: boolean;
|
|
917
|
+
/**
|
|
918
|
+
* File Upload Api
|
|
919
|
+
*
|
|
920
|
+
* Whether file upload/conversion API is enabled
|
|
921
|
+
*/
|
|
922
|
+
file_upload_api: boolean;
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* FileRetainResponse
|
|
927
|
+
*
|
|
928
|
+
* Response model for file upload endpoint.
|
|
929
|
+
*/
|
|
930
|
+
export type FileRetainResponse = {
|
|
931
|
+
/**
|
|
932
|
+
* Operation Ids
|
|
933
|
+
*
|
|
934
|
+
* Operation IDs for tracking file conversion operations. Use GET /v1/default/banks/{bank_id}/operations to list operations.
|
|
935
|
+
*/
|
|
936
|
+
operation_ids: Array<string>;
|
|
819
937
|
};
|
|
820
938
|
|
|
821
939
|
/**
|
|
@@ -1149,6 +1267,20 @@ export type OperationStatusResponse = {
|
|
|
1149
1267
|
* Error Message
|
|
1150
1268
|
*/
|
|
1151
1269
|
error_message?: string | null;
|
|
1270
|
+
/**
|
|
1271
|
+
* Result Metadata
|
|
1272
|
+
*
|
|
1273
|
+
* Internal metadata for debugging. Structure may change without notice. Not for production use.
|
|
1274
|
+
*/
|
|
1275
|
+
result_metadata?: {
|
|
1276
|
+
[key: string]: unknown;
|
|
1277
|
+
} | null;
|
|
1278
|
+
/**
|
|
1279
|
+
* Child Operations
|
|
1280
|
+
*
|
|
1281
|
+
* Child operations for batch operations (if applicable)
|
|
1282
|
+
*/
|
|
1283
|
+
child_operations?: Array<ChildOperationStatus> | null;
|
|
1152
1284
|
};
|
|
1153
1285
|
|
|
1154
1286
|
/**
|
|
@@ -1666,7 +1798,7 @@ export type RetainResponse = {
|
|
|
1666
1798
|
/**
|
|
1667
1799
|
* Operation Id
|
|
1668
1800
|
*
|
|
1669
|
-
* Operation ID for tracking async operations. Use GET /v1/default/banks/{bank_id}/operations to list operations
|
|
1801
|
+
* Operation ID for tracking async operations. Use GET /v1/default/banks/{bank_id}/operations to list operations. Only present when async=true.
|
|
1670
1802
|
*/
|
|
1671
1803
|
operation_id?: string | null;
|
|
1672
1804
|
/**
|
|
@@ -3426,6 +3558,119 @@ export type ClearObservationsResponses = {
|
|
|
3426
3558
|
export type ClearObservationsResponse =
|
|
3427
3559
|
ClearObservationsResponses[keyof ClearObservationsResponses];
|
|
3428
3560
|
|
|
3561
|
+
export type ResetBankConfigData = {
|
|
3562
|
+
body?: never;
|
|
3563
|
+
headers?: {
|
|
3564
|
+
/**
|
|
3565
|
+
* Authorization
|
|
3566
|
+
*/
|
|
3567
|
+
authorization?: string | null;
|
|
3568
|
+
};
|
|
3569
|
+
path: {
|
|
3570
|
+
/**
|
|
3571
|
+
* Bank Id
|
|
3572
|
+
*/
|
|
3573
|
+
bank_id: string;
|
|
3574
|
+
};
|
|
3575
|
+
query?: never;
|
|
3576
|
+
url: "/v1/default/banks/{bank_id}/config";
|
|
3577
|
+
};
|
|
3578
|
+
|
|
3579
|
+
export type ResetBankConfigErrors = {
|
|
3580
|
+
/**
|
|
3581
|
+
* Validation Error
|
|
3582
|
+
*/
|
|
3583
|
+
422: HttpValidationError;
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3586
|
+
export type ResetBankConfigError =
|
|
3587
|
+
ResetBankConfigErrors[keyof ResetBankConfigErrors];
|
|
3588
|
+
|
|
3589
|
+
export type ResetBankConfigResponses = {
|
|
3590
|
+
/**
|
|
3591
|
+
* Successful Response
|
|
3592
|
+
*/
|
|
3593
|
+
200: BankConfigResponse;
|
|
3594
|
+
};
|
|
3595
|
+
|
|
3596
|
+
export type ResetBankConfigResponse =
|
|
3597
|
+
ResetBankConfigResponses[keyof ResetBankConfigResponses];
|
|
3598
|
+
|
|
3599
|
+
export type GetBankConfigData = {
|
|
3600
|
+
body?: never;
|
|
3601
|
+
headers?: {
|
|
3602
|
+
/**
|
|
3603
|
+
* Authorization
|
|
3604
|
+
*/
|
|
3605
|
+
authorization?: string | null;
|
|
3606
|
+
};
|
|
3607
|
+
path: {
|
|
3608
|
+
/**
|
|
3609
|
+
* Bank Id
|
|
3610
|
+
*/
|
|
3611
|
+
bank_id: string;
|
|
3612
|
+
};
|
|
3613
|
+
query?: never;
|
|
3614
|
+
url: "/v1/default/banks/{bank_id}/config";
|
|
3615
|
+
};
|
|
3616
|
+
|
|
3617
|
+
export type GetBankConfigErrors = {
|
|
3618
|
+
/**
|
|
3619
|
+
* Validation Error
|
|
3620
|
+
*/
|
|
3621
|
+
422: HttpValidationError;
|
|
3622
|
+
};
|
|
3623
|
+
|
|
3624
|
+
export type GetBankConfigError = GetBankConfigErrors[keyof GetBankConfigErrors];
|
|
3625
|
+
|
|
3626
|
+
export type GetBankConfigResponses = {
|
|
3627
|
+
/**
|
|
3628
|
+
* Successful Response
|
|
3629
|
+
*/
|
|
3630
|
+
200: BankConfigResponse;
|
|
3631
|
+
};
|
|
3632
|
+
|
|
3633
|
+
export type GetBankConfigResponse =
|
|
3634
|
+
GetBankConfigResponses[keyof GetBankConfigResponses];
|
|
3635
|
+
|
|
3636
|
+
export type UpdateBankConfigData = {
|
|
3637
|
+
body: BankConfigUpdate;
|
|
3638
|
+
headers?: {
|
|
3639
|
+
/**
|
|
3640
|
+
* Authorization
|
|
3641
|
+
*/
|
|
3642
|
+
authorization?: string | null;
|
|
3643
|
+
};
|
|
3644
|
+
path: {
|
|
3645
|
+
/**
|
|
3646
|
+
* Bank Id
|
|
3647
|
+
*/
|
|
3648
|
+
bank_id: string;
|
|
3649
|
+
};
|
|
3650
|
+
query?: never;
|
|
3651
|
+
url: "/v1/default/banks/{bank_id}/config";
|
|
3652
|
+
};
|
|
3653
|
+
|
|
3654
|
+
export type UpdateBankConfigErrors = {
|
|
3655
|
+
/**
|
|
3656
|
+
* Validation Error
|
|
3657
|
+
*/
|
|
3658
|
+
422: HttpValidationError;
|
|
3659
|
+
};
|
|
3660
|
+
|
|
3661
|
+
export type UpdateBankConfigError =
|
|
3662
|
+
UpdateBankConfigErrors[keyof UpdateBankConfigErrors];
|
|
3663
|
+
|
|
3664
|
+
export type UpdateBankConfigResponses = {
|
|
3665
|
+
/**
|
|
3666
|
+
* Successful Response
|
|
3667
|
+
*/
|
|
3668
|
+
200: BankConfigResponse;
|
|
3669
|
+
};
|
|
3670
|
+
|
|
3671
|
+
export type UpdateBankConfigResponse =
|
|
3672
|
+
UpdateBankConfigResponses[keyof UpdateBankConfigResponses];
|
|
3673
|
+
|
|
3429
3674
|
export type TriggerConsolidationData = {
|
|
3430
3675
|
body?: never;
|
|
3431
3676
|
headers?: {
|
|
@@ -3546,3 +3791,40 @@ export type RetainMemoriesResponses = {
|
|
|
3546
3791
|
|
|
3547
3792
|
export type RetainMemoriesResponse =
|
|
3548
3793
|
RetainMemoriesResponses[keyof RetainMemoriesResponses];
|
|
3794
|
+
|
|
3795
|
+
export type FileRetainData = {
|
|
3796
|
+
body: BodyFileRetain;
|
|
3797
|
+
headers?: {
|
|
3798
|
+
/**
|
|
3799
|
+
* Authorization
|
|
3800
|
+
*/
|
|
3801
|
+
authorization?: string | null;
|
|
3802
|
+
};
|
|
3803
|
+
path: {
|
|
3804
|
+
/**
|
|
3805
|
+
* Bank Id
|
|
3806
|
+
*/
|
|
3807
|
+
bank_id: string;
|
|
3808
|
+
};
|
|
3809
|
+
query?: never;
|
|
3810
|
+
url: "/v1/default/banks/{bank_id}/files/retain";
|
|
3811
|
+
};
|
|
3812
|
+
|
|
3813
|
+
export type FileRetainErrors = {
|
|
3814
|
+
/**
|
|
3815
|
+
* Validation Error
|
|
3816
|
+
*/
|
|
3817
|
+
422: HttpValidationError;
|
|
3818
|
+
};
|
|
3819
|
+
|
|
3820
|
+
export type FileRetainError = FileRetainErrors[keyof FileRetainErrors];
|
|
3821
|
+
|
|
3822
|
+
export type FileRetainResponses = {
|
|
3823
|
+
/**
|
|
3824
|
+
* Successful Response
|
|
3825
|
+
*/
|
|
3826
|
+
200: FileRetainResponse;
|
|
3827
|
+
};
|
|
3828
|
+
|
|
3829
|
+
export type FileRetainResponse2 =
|
|
3830
|
+
FileRetainResponses[keyof FileRetainResponses];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorize-io/hindsight-client",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "TypeScript client for Hindsight - Semantic memory system with personality-driven thinking",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
RecallResult,
|
|
37
37
|
ReflectRequest,
|
|
38
38
|
ReflectResponse,
|
|
39
|
+
FileRetainResponse,
|
|
39
40
|
ListMemoryUnitsResponse,
|
|
40
41
|
BankProfileResponse,
|
|
41
42
|
CreateBankRequest,
|
|
@@ -50,6 +51,22 @@ export interface HindsightClientOptions {
|
|
|
50
51
|
apiKey?: string;
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown by the Hindsight client when an API request fails.
|
|
56
|
+
* Includes the HTTP status code and error details from the API.
|
|
57
|
+
*/
|
|
58
|
+
export class HindsightError extends Error {
|
|
59
|
+
public statusCode?: number;
|
|
60
|
+
public details?: unknown;
|
|
61
|
+
|
|
62
|
+
constructor(message: string, statusCode?: number, details?: unknown) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = 'HindsightError';
|
|
65
|
+
this.statusCode = statusCode;
|
|
66
|
+
this.details = details;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
export interface EntityInput {
|
|
54
71
|
text: string;
|
|
55
72
|
type?: string;
|
|
@@ -82,9 +99,22 @@ export class HindsightClient {
|
|
|
82
99
|
/**
|
|
83
100
|
* Validates the API response and throws an error if the request failed.
|
|
84
101
|
*/
|
|
85
|
-
private validateResponse<T>(response: { data?: T; error?: unknown }, operation: string): T {
|
|
102
|
+
private validateResponse<T>(response: { data?: T; error?: unknown; response?: Response }, operation: string): T {
|
|
86
103
|
if (!response.data) {
|
|
87
|
-
|
|
104
|
+
// The generated client returns { error, response, request }
|
|
105
|
+
// Status code is in response.status, not in the error object
|
|
106
|
+
const error = response.error as any;
|
|
107
|
+
const httpResponse = (response as any).response as Response | undefined;
|
|
108
|
+
|
|
109
|
+
// Extract status code from the HTTP response object
|
|
110
|
+
const statusCode = httpResponse?.status;
|
|
111
|
+
const details = error?.detail || error?.message || error;
|
|
112
|
+
|
|
113
|
+
throw new HindsightError(
|
|
114
|
+
`${operation} failed: ${JSON.stringify(details)}`,
|
|
115
|
+
statusCode,
|
|
116
|
+
details
|
|
117
|
+
);
|
|
88
118
|
}
|
|
89
119
|
return response.data;
|
|
90
120
|
}
|
|
@@ -182,6 +212,40 @@ export class HindsightClient {
|
|
|
182
212
|
return this.validateResponse(response, 'retainBatch');
|
|
183
213
|
}
|
|
184
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Upload files and retain their contents as memories.
|
|
217
|
+
*
|
|
218
|
+
* Files are automatically converted to text (PDF, DOCX, images via OCR, audio via
|
|
219
|
+
* transcription, and more) and ingested as memories. Processing is always asynchronous —
|
|
220
|
+
* use the returned operation IDs to track progress via the operations endpoint.
|
|
221
|
+
*
|
|
222
|
+
* @param bankId - The memory bank ID
|
|
223
|
+
* @param files - Array of File or Blob objects to upload
|
|
224
|
+
* @param options - Optional settings: context, documentTags, filesMetadata
|
|
225
|
+
*/
|
|
226
|
+
async retainFiles(
|
|
227
|
+
bankId: string,
|
|
228
|
+
files: Array<File | Blob>,
|
|
229
|
+
options?: {
|
|
230
|
+
context?: string;
|
|
231
|
+
filesMetadata?: Array<{ context?: string; document_id?: string; tags?: string[]; metadata?: Record<string, string> }>;
|
|
232
|
+
}
|
|
233
|
+
): Promise<FileRetainResponse> {
|
|
234
|
+
const meta = options?.filesMetadata ?? files.map(() => options?.context ? { context: options.context } : {});
|
|
235
|
+
|
|
236
|
+
const requestBody = JSON.stringify({
|
|
237
|
+
files_metadata: meta,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const response = await sdk.fileRetain({
|
|
241
|
+
client: this.client,
|
|
242
|
+
path: { bank_id: bankId },
|
|
243
|
+
body: { files, request: requestBody },
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return this.validateResponse(response, 'retainFiles');
|
|
247
|
+
}
|
|
248
|
+
|
|
185
249
|
/**
|
|
186
250
|
* Recall memories with a natural language query.
|
|
187
251
|
*/
|
|
@@ -551,6 +615,7 @@ export type {
|
|
|
551
615
|
RecallResult,
|
|
552
616
|
ReflectRequest,
|
|
553
617
|
ReflectResponse,
|
|
618
|
+
FileRetainResponse,
|
|
554
619
|
ListMemoryUnitsResponse,
|
|
555
620
|
BankProfileResponse,
|
|
556
621
|
CreateBankRequest,
|