@papr/memory 1.9.0 → 1.13.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +11 -9
  3. package/client.d.mts +23 -11
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +23 -11
  6. package/client.d.ts.map +1 -1
  7. package/client.js +41 -21
  8. package/client.js.map +1 -1
  9. package/client.mjs +41 -21
  10. package/client.mjs.map +1 -1
  11. package/internal/request-options.d.mts +42 -0
  12. package/internal/request-options.d.mts.map +1 -1
  13. package/internal/request-options.d.ts +42 -0
  14. package/internal/request-options.d.ts.map +1 -1
  15. package/internal/request-options.js.map +1 -1
  16. package/internal/request-options.mjs.map +1 -1
  17. package/internal/uploads.js +1 -1
  18. package/internal/uploads.js.map +1 -1
  19. package/internal/uploads.mjs +1 -1
  20. package/internal/uploads.mjs.map +1 -1
  21. package/internal/utils/log.d.mts.map +1 -1
  22. package/internal/utils/log.d.ts.map +1 -1
  23. package/internal/utils/log.js +4 -3
  24. package/internal/utils/log.js.map +1 -1
  25. package/internal/utils/log.mjs +4 -3
  26. package/internal/utils/log.mjs.map +1 -1
  27. package/internal/utils/path.d.mts.map +1 -1
  28. package/internal/utils/path.d.ts.map +1 -1
  29. package/internal/utils/path.js +26 -5
  30. package/internal/utils/path.js.map +1 -1
  31. package/internal/utils/path.mjs +26 -5
  32. package/internal/utils/path.mjs.map +1 -1
  33. package/package.json +1 -1
  34. package/resources/feedback.d.mts +333 -0
  35. package/resources/feedback.d.mts.map +1 -0
  36. package/resources/feedback.d.ts +333 -0
  37. package/resources/feedback.d.ts.map +1 -0
  38. package/resources/feedback.js +108 -0
  39. package/resources/feedback.js.map +1 -0
  40. package/resources/feedback.mjs +104 -0
  41. package/resources/feedback.mjs.map +1 -0
  42. package/resources/index.d.mts +2 -1
  43. package/resources/index.d.mts.map +1 -1
  44. package/resources/index.d.ts +2 -1
  45. package/resources/index.d.ts.map +1 -1
  46. package/resources/index.js +3 -1
  47. package/resources/index.js.map +1 -1
  48. package/resources/index.mjs +1 -0
  49. package/resources/index.mjs.map +1 -1
  50. package/resources/memory.d.mts +48 -11
  51. package/resources/memory.d.mts.map +1 -1
  52. package/resources/memory.d.ts +48 -11
  53. package/resources/memory.d.ts.map +1 -1
  54. package/resources/memory.js +11 -0
  55. package/resources/memory.js.map +1 -1
  56. package/resources/memory.mjs +11 -0
  57. package/resources/memory.mjs.map +1 -1
  58. package/resources/user.d.mts +24 -88
  59. package/resources/user.d.mts.map +1 -1
  60. package/resources/user.d.ts +24 -88
  61. package/resources/user.d.ts.map +1 -1
  62. package/resources/user.js +17 -56
  63. package/resources/user.js.map +1 -1
  64. package/resources/user.mjs +17 -56
  65. package/resources/user.mjs.map +1 -1
  66. package/src/client.ts +74 -28
  67. package/src/internal/request-options.ts +53 -0
  68. package/src/internal/uploads.ts +1 -1
  69. package/src/internal/utils/log.ts +3 -2
  70. package/src/internal/utils/path.ts +32 -7
  71. package/src/resources/feedback.ts +424 -0
  72. package/src/resources/index.ts +9 -1
  73. package/src/resources/memory.ts +44 -11
  74. package/src/resources/user.ts +29 -130
  75. package/src/version.ts +1 -1
  76. package/version.d.mts +1 -1
  77. package/version.d.mts.map +1 -1
  78. package/version.d.ts +1 -1
  79. package/version.d.ts.map +1 -1
  80. package/version.js +1 -1
  81. package/version.js.map +1 -1
  82. package/version.mjs +1 -1
  83. package/version.mjs.map +1 -1
@@ -0,0 +1,424 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+ import { path } from '../internal/utils/path';
7
+
8
+ export class Feedback extends APIResource {
9
+ /**
10
+ * Retrieve feedback by ID.
11
+ *
12
+ * This endpoint allows developers to fetch feedback details by feedback ID.
13
+ * Only the user who created the feedback or users with appropriate permissions can access it.
14
+ *
15
+ * **Authentication Required**:
16
+ * One of the following authentication methods must be used:
17
+ * - Bearer token in `Authorization` header
18
+ * - API Key in `X-API-Key` header
19
+ * - Session token in `X-Session-Token` header
20
+ *
21
+ * **Required Headers**:
22
+ * - X-Client-Type: (e.g., 'papr_plugin', 'browser_extension')
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const feedbackResponse = await client.feedback.getByID(
27
+ * 'feedback_id',
28
+ * );
29
+ * ```
30
+ */
31
+ getByID(feedbackID: string, options?: RequestOptions): APIPromise<FeedbackResponse> {
32
+ return this._client.get(path`/v1/feedback/${feedbackID}`, options);
33
+ }
34
+
35
+ /**
36
+ * Submit feedback on search results to help improve model performance.
37
+ *
38
+ * This endpoint allows developers to provide feedback on:
39
+ * - Overall answer quality (thumbs up/down, ratings)
40
+ * - Specific memory relevance and accuracy
41
+ * - User engagement signals (copy, save, create document actions)
42
+ * - Corrections and improvements
43
+ *
44
+ * The feedback is used to train and improve:
45
+ * - Router model tier predictions
46
+ * - Memory retrieval ranking
47
+ * - Answer generation quality
48
+ * - Agentic graph search performance
49
+ *
50
+ * **Authentication Required**:
51
+ * One of the following authentication methods must be used:
52
+ * - Bearer token in `Authorization` header
53
+ * - API Key in `X-API-Key` header
54
+ * - Session token in `X-Session-Token` header
55
+ *
56
+ * **Required Headers**:
57
+ * - Content-Type: application/json
58
+ * - X-Client-Type: (e.g., 'papr_plugin', 'browser_extension')
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const feedbackResponse = await client.feedback.submit({
63
+ * feedbackData: {
64
+ * feedbackSource: 'inline',
65
+ * feedbackType: 'thumbs_up',
66
+ * },
67
+ * search_id: 'abc123def456',
68
+ * });
69
+ * ```
70
+ */
71
+ submit(body: FeedbackSubmitParams, options?: RequestOptions): APIPromise<FeedbackResponse> {
72
+ return this._client.post('/v1/feedback', { body, ...options });
73
+ }
74
+
75
+ /**
76
+ * Submit multiple feedback items in a single request.
77
+ *
78
+ * Useful for submitting session-end feedback or bulk feedback collection.
79
+ * Each feedback item is processed independently, so partial success is possible.
80
+ *
81
+ * **Authentication Required**:
82
+ * One of the following authentication methods must be used:
83
+ * - Bearer token in `Authorization` header
84
+ * - API Key in `X-API-Key` header
85
+ * - Session token in `X-Session-Token` header
86
+ *
87
+ * **Required Headers**:
88
+ * - Content-Type: application/json
89
+ * - X-Client-Type: (e.g., 'papr_plugin', 'browser_extension')
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * const batchResponse = await client.feedback.submitBatch({
94
+ * feedback_items: [
95
+ * {
96
+ * feedbackData: {
97
+ * feedbackSource: 'inline',
98
+ * feedbackType: 'thumbs_up',
99
+ * },
100
+ * search_id: 'abc123def456',
101
+ * },
102
+ * ],
103
+ * });
104
+ * ```
105
+ */
106
+ submitBatch(body: FeedbackSubmitBatchParams, options?: RequestOptions): APIPromise<BatchResponse> {
107
+ return this._client.post('/v1/feedback/batch', { body, ...options });
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Request model for submitting multiple feedback items
113
+ */
114
+ export interface BatchRequest {
115
+ /**
116
+ * List of feedback items to submit
117
+ */
118
+ feedback_items: Array<FeedbackRequest>;
119
+
120
+ /**
121
+ * Session-level context for batch feedback
122
+ */
123
+ session_context?: { [key: string]: unknown } | null;
124
+ }
125
+
126
+ /**
127
+ * Response model for batch feedback submission
128
+ */
129
+ export interface BatchResponse {
130
+ /**
131
+ * HTTP status code
132
+ */
133
+ code: number;
134
+
135
+ /**
136
+ * Human-readable message
137
+ */
138
+ message: string;
139
+
140
+ /**
141
+ * 'success' or 'error'
142
+ */
143
+ status: string;
144
+
145
+ /**
146
+ * Error message if status is 'error'
147
+ */
148
+ error?: string | null;
149
+
150
+ /**
151
+ * List of error details
152
+ */
153
+ errors?: Array<{ [key: string]: unknown }>;
154
+
155
+ /**
156
+ * Number of failed feedback items
157
+ */
158
+ failed_count?: number;
159
+
160
+ /**
161
+ * List of feedback IDs
162
+ */
163
+ feedback_ids?: Array<string>;
164
+
165
+ /**
166
+ * Number of successfully processed feedback items
167
+ */
168
+ successful_count?: number;
169
+ }
170
+
171
+ /**
172
+ * Request model for submitting feedback on search results
173
+ */
174
+ export interface FeedbackRequest {
175
+ /**
176
+ * The feedback data containing all feedback information
177
+ */
178
+ feedbackData: FeedbackRequest.FeedbackData;
179
+
180
+ /**
181
+ * The search_id from SearchResponse that this feedback relates to
182
+ */
183
+ search_id: string;
184
+
185
+ /**
186
+ * External user ID for developer API keys acting on behalf of end users
187
+ */
188
+ external_user_id?: string | null;
189
+
190
+ /**
191
+ * Internal user ID (if not provided, will be resolved from authentication)
192
+ */
193
+ user_id?: string | null;
194
+ }
195
+
196
+ export namespace FeedbackRequest {
197
+ /**
198
+ * The feedback data containing all feedback information
199
+ */
200
+ export interface FeedbackData {
201
+ /**
202
+ * Where the feedback was provided from
203
+ */
204
+ feedbackSource: 'inline' | 'post_query' | 'session_end' | 'memory_citation' | 'answer_panel';
205
+
206
+ /**
207
+ * Types of feedback that can be provided
208
+ */
209
+ feedbackType:
210
+ | 'thumbs_up'
211
+ | 'thumbs_down'
212
+ | 'rating'
213
+ | 'correction'
214
+ | 'report'
215
+ | 'copy_action'
216
+ | 'save_action'
217
+ | 'create_document'
218
+ | 'memory_relevance'
219
+ | 'answer_quality';
220
+
221
+ /**
222
+ * A pointer to a Parse object
223
+ */
224
+ assistantMessage?: FeedbackData.AssistantMessage | null;
225
+
226
+ citedMemoryIds?: Array<string> | null;
227
+
228
+ citedNodeIds?: Array<string> | null;
229
+
230
+ feedbackImpact?: string | null;
231
+
232
+ feedbackProcessed?: boolean | null;
233
+
234
+ feedbackScore?: number | null;
235
+
236
+ feedbackText?: string | null;
237
+
238
+ feedbackValue?: string | null;
239
+
240
+ /**
241
+ * A pointer to a Parse object
242
+ */
243
+ userMessage?: FeedbackData.UserMessage | null;
244
+ }
245
+
246
+ export namespace FeedbackData {
247
+ /**
248
+ * A pointer to a Parse object
249
+ */
250
+ export interface AssistantMessage {
251
+ className: string;
252
+
253
+ objectId: string;
254
+
255
+ __type?: string;
256
+ }
257
+
258
+ /**
259
+ * A pointer to a Parse object
260
+ */
261
+ export interface UserMessage {
262
+ className: string;
263
+
264
+ objectId: string;
265
+
266
+ __type?: string;
267
+ }
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Response model for feedback submission
273
+ */
274
+ export interface FeedbackResponse {
275
+ /**
276
+ * HTTP status code
277
+ */
278
+ code: number;
279
+
280
+ /**
281
+ * Human-readable message
282
+ */
283
+ message: string;
284
+
285
+ /**
286
+ * 'success' or 'error'
287
+ */
288
+ status: string;
289
+
290
+ /**
291
+ * Additional error details
292
+ */
293
+ details?: { [key: string]: unknown } | null;
294
+
295
+ /**
296
+ * Error message if status is 'error'
297
+ */
298
+ error?: string | null;
299
+
300
+ /**
301
+ * Unique feedback ID
302
+ */
303
+ feedback_id?: string | null;
304
+ }
305
+
306
+ export interface FeedbackSubmitParams {
307
+ /**
308
+ * The feedback data containing all feedback information
309
+ */
310
+ feedbackData: FeedbackSubmitParams.FeedbackData;
311
+
312
+ /**
313
+ * The search_id from SearchResponse that this feedback relates to
314
+ */
315
+ search_id: string;
316
+
317
+ /**
318
+ * External user ID for developer API keys acting on behalf of end users
319
+ */
320
+ external_user_id?: string | null;
321
+
322
+ /**
323
+ * Internal user ID (if not provided, will be resolved from authentication)
324
+ */
325
+ user_id?: string | null;
326
+ }
327
+
328
+ export namespace FeedbackSubmitParams {
329
+ /**
330
+ * The feedback data containing all feedback information
331
+ */
332
+ export interface FeedbackData {
333
+ /**
334
+ * Where the feedback was provided from
335
+ */
336
+ feedbackSource: 'inline' | 'post_query' | 'session_end' | 'memory_citation' | 'answer_panel';
337
+
338
+ /**
339
+ * Types of feedback that can be provided
340
+ */
341
+ feedbackType:
342
+ | 'thumbs_up'
343
+ | 'thumbs_down'
344
+ | 'rating'
345
+ | 'correction'
346
+ | 'report'
347
+ | 'copy_action'
348
+ | 'save_action'
349
+ | 'create_document'
350
+ | 'memory_relevance'
351
+ | 'answer_quality';
352
+
353
+ /**
354
+ * A pointer to a Parse object
355
+ */
356
+ assistantMessage?: FeedbackData.AssistantMessage | null;
357
+
358
+ citedMemoryIds?: Array<string> | null;
359
+
360
+ citedNodeIds?: Array<string> | null;
361
+
362
+ feedbackImpact?: string | null;
363
+
364
+ feedbackProcessed?: boolean | null;
365
+
366
+ feedbackScore?: number | null;
367
+
368
+ feedbackText?: string | null;
369
+
370
+ feedbackValue?: string | null;
371
+
372
+ /**
373
+ * A pointer to a Parse object
374
+ */
375
+ userMessage?: FeedbackData.UserMessage | null;
376
+ }
377
+
378
+ export namespace FeedbackData {
379
+ /**
380
+ * A pointer to a Parse object
381
+ */
382
+ export interface AssistantMessage {
383
+ className: string;
384
+
385
+ objectId: string;
386
+
387
+ __type?: string;
388
+ }
389
+
390
+ /**
391
+ * A pointer to a Parse object
392
+ */
393
+ export interface UserMessage {
394
+ className: string;
395
+
396
+ objectId: string;
397
+
398
+ __type?: string;
399
+ }
400
+ }
401
+ }
402
+
403
+ export interface FeedbackSubmitBatchParams {
404
+ /**
405
+ * List of feedback items to submit
406
+ */
407
+ feedback_items: Array<FeedbackRequest>;
408
+
409
+ /**
410
+ * Session-level context for batch feedback
411
+ */
412
+ session_context?: { [key: string]: unknown } | null;
413
+ }
414
+
415
+ export declare namespace Feedback {
416
+ export {
417
+ type BatchRequest as BatchRequest,
418
+ type BatchResponse as BatchResponse,
419
+ type FeedbackRequest as FeedbackRequest,
420
+ type FeedbackResponse as FeedbackResponse,
421
+ type FeedbackSubmitParams as FeedbackSubmitParams,
422
+ type FeedbackSubmitBatchParams as FeedbackSubmitBatchParams,
423
+ };
424
+ }
@@ -1,5 +1,14 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ export {
4
+ Feedback,
5
+ type BatchRequest,
6
+ type BatchResponse,
7
+ type FeedbackRequest,
8
+ type FeedbackResponse,
9
+ type FeedbackSubmitParams,
10
+ type FeedbackSubmitBatchParams,
11
+ } from './feedback';
3
12
  export {
4
13
  Memory,
5
14
  type AddMemory,
@@ -30,5 +39,4 @@ export {
30
39
  type UserListParams,
31
40
  type UserDeleteParams,
32
41
  type UserCreateBatchParams,
33
- type UserGetParams,
34
42
  } from './user';
@@ -167,6 +167,17 @@ export class Memory extends APIResource {
167
167
  *
168
168
  * The API supports response compression for improved performance. Responses larger than 1KB will be automatically compressed when this header is present.
169
169
  *
170
+ * **HIGHLY RECOMMENDED SETTINGS FOR BEST RESULTS:**
171
+ * - Set `enable_agentic_graph: true` for intelligent, context-aware search that can understand ambiguous references
172
+ * - Use `max_memories: 15-20` for comprehensive memory coverage
173
+ * - Use `max_nodes: 10-15` for comprehensive graph entity relationships
174
+ *
175
+ * **Agentic Graph Benefits:**
176
+ * When enabled, the system can understand vague references by first identifying specific entities from your memory graph, then performing targeted searches. For example:
177
+ * - "customer feedback" → identifies your customers first, then finds their specific feedback
178
+ * - "project issues" → identifies your projects first, then finds related issues
179
+ * - "team meeting notes" → identifies your team members first, then finds meeting notes
180
+ *
170
181
  * **User Resolution Precedence:**
171
182
  * - If both user_id and external_user_id are provided, user_id takes precedence.
172
183
  * - If only external_user_id is provided, it will be resolved to the internal user.
@@ -370,7 +381,7 @@ export type MemoryType = 'text' | 'code_snippet' | 'document';
370
381
  export interface RelationshipItem {
371
382
  relation_type: string;
372
383
 
373
- metadata?: unknown;
384
+ metadata?: { [key: string]: unknown };
374
385
 
375
386
  related_item_id?: string | null;
376
387
 
@@ -382,7 +393,7 @@ export interface RelationshipItem {
382
393
  /**
383
394
  * Enum for relationship types
384
395
  */
385
- relationship_type?: 'previous_memory_item_id' | 'all_previous_memory_items' | null;
396
+ relationship_type?: 'previous_memory_item_id' | 'all_previous_memory_items' | 'link_to_id' | null;
386
397
  }
387
398
 
388
399
  export interface SearchResponse {
@@ -406,6 +417,12 @@ export interface SearchResponse {
406
417
  */
407
418
  error?: string | null;
408
419
 
420
+ /**
421
+ * Unique identifier for this search query, maps to QueryLog objectId in Parse
422
+ * Server
423
+ */
424
+ search_id?: string | null;
425
+
409
426
  /**
410
427
  * 'success' or 'error'
411
428
  */
@@ -445,7 +462,7 @@ export namespace SearchResponse {
445
462
 
446
463
  current_step?: string | null;
447
464
 
448
- customMetadata?: unknown | null;
465
+ customMetadata?: { [key: string]: unknown } | null;
449
466
 
450
467
  external_user_id?: string | null;
451
468
 
@@ -461,7 +478,7 @@ export namespace SearchResponse {
461
478
 
462
479
  location?: string | null;
463
480
 
464
- metadata?: string | unknown | null;
481
+ metadata?: string | { [key: string]: unknown } | null;
465
482
 
466
483
  page?: string | null;
467
484
 
@@ -1094,6 +1111,8 @@ export namespace MemoryDeleteResponse {
1094
1111
  parse?: boolean;
1095
1112
 
1096
1113
  pinecone?: boolean;
1114
+
1115
+ qdrant?: boolean;
1097
1116
  }
1098
1117
  }
1099
1118
 
@@ -1258,25 +1277,39 @@ export interface MemorySearchParams {
1258
1277
  /**
1259
1278
  * Body param: Detailed search query describing what you're looking for. For best
1260
1279
  * results, write 2-3 sentences that include specific details, context, and time
1261
- * frame. For example: 'Find recurring customer complaints about API performance
1262
- * from the last month. Focus on issues where customers specifically mentioned
1263
- * timeout errors or slow response times in their conversations.'
1280
+ * frame. Examples: 'Find recurring customer complaints about API performance from
1281
+ * the last month. Focus on issues where customers specifically mentioned timeout
1282
+ * errors or slow response times in their conversations.' 'What are the main issues
1283
+ * and blockers in my current projects? Focus on technical challenges and timeline
1284
+ * impacts.' 'Find insights about team collaboration and communication patterns
1285
+ * from recent meetings and discussions.'
1264
1286
  */
1265
1287
  query: string;
1266
1288
 
1267
1289
  /**
1268
- * Query param: Maximum number of memories to return
1290
+ * Query param: HIGHLY RECOMMENDED: Maximum number of memories to return. Use at
1291
+ * least 15-20 for comprehensive results. Lower values (5-10) may miss relevant
1292
+ * information. Default is 20 for optimal coverage.
1269
1293
  */
1270
1294
  max_memories?: number;
1271
1295
 
1272
1296
  /**
1273
- * Query param: Maximum number of neo nodes to return
1297
+ * Query param: HIGHLY RECOMMENDED: Maximum number of neo nodes to return. Use at
1298
+ * least 10-15 for comprehensive graph results. Lower values may miss important
1299
+ * entity relationships. Default is 15 for optimal coverage.
1274
1300
  */
1275
1301
  max_nodes?: number;
1276
1302
 
1277
1303
  /**
1278
- * Body param: Whether to enable agentic graph search. Default is false (graph
1279
- * search is skipped). Set to true to use agentic graph search.
1304
+ * Body param: HIGHLY RECOMMENDED: Enable agentic graph search for intelligent,
1305
+ * context-aware results. When enabled, the system can understand ambiguous
1306
+ * references by first identifying specific entities from your memory graph, then
1307
+ * performing targeted searches. Examples: 'customer feedback' → identifies your
1308
+ * customers first, then finds their specific feedback; 'project issues' →
1309
+ * identifies your projects first, then finds related issues; 'team meeting notes'
1310
+ * → identifies team members first, then finds meeting notes. This provides much
1311
+ * more relevant and comprehensive results. Set to false only if you need faster,
1312
+ * simpler keyword-based search.
1280
1313
  */
1281
1314
  enable_agentic_graph?: boolean;
1282
1315