@papr/memory 1.20.0 → 2.0.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 (128) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +1 -1
  3. package/README.md +13 -1
  4. package/client.d.mts +37 -9
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +37 -9
  7. package/client.d.ts.map +1 -1
  8. package/client.js +17 -2
  9. package/client.js.map +1 -1
  10. package/client.mjs +17 -2
  11. package/client.mjs.map +1 -1
  12. package/internal/parse.d.mts.map +1 -1
  13. package/internal/parse.d.ts.map +1 -1
  14. package/internal/parse.js +5 -0
  15. package/internal/parse.js.map +1 -1
  16. package/internal/parse.mjs +5 -0
  17. package/internal/parse.mjs.map +1 -1
  18. package/internal/tslib.js +22 -22
  19. package/package.json +1 -1
  20. package/resources/document.d.mts +16 -3
  21. package/resources/document.d.mts.map +1 -1
  22. package/resources/document.d.ts +16 -3
  23. package/resources/document.d.ts.map +1 -1
  24. package/resources/index.d.mts +6 -3
  25. package/resources/index.d.mts.map +1 -1
  26. package/resources/index.d.ts +6 -3
  27. package/resources/index.d.ts.map +1 -1
  28. package/resources/index.js +7 -1
  29. package/resources/index.js.map +1 -1
  30. package/resources/index.mjs +3 -0
  31. package/resources/index.mjs.map +1 -1
  32. package/resources/memory.d.mts +498 -119
  33. package/resources/memory.d.mts.map +1 -1
  34. package/resources/memory.d.ts +498 -119
  35. package/resources/memory.d.ts.map +1 -1
  36. package/resources/memory.js +8 -4
  37. package/resources/memory.js.map +1 -1
  38. package/resources/memory.mjs +8 -4
  39. package/resources/memory.mjs.map +1 -1
  40. package/resources/messages/index.d.mts +3 -0
  41. package/resources/messages/index.d.mts.map +1 -0
  42. package/resources/messages/index.d.ts +3 -0
  43. package/resources/messages/index.d.ts.map +1 -0
  44. package/resources/messages/index.js +9 -0
  45. package/resources/messages/index.js.map +1 -0
  46. package/resources/messages/index.mjs +4 -0
  47. package/resources/messages/index.mjs.map +1 -0
  48. package/resources/messages/messages.d.mts +160 -0
  49. package/resources/messages/messages.d.mts.map +1 -0
  50. package/resources/messages/messages.d.ts +160 -0
  51. package/resources/messages/messages.d.ts.map +1 -0
  52. package/resources/messages/messages.js +54 -0
  53. package/resources/messages/messages.js.map +1 -0
  54. package/resources/messages/messages.mjs +49 -0
  55. package/resources/messages/messages.mjs.map +1 -0
  56. package/resources/messages/sessions.d.mts +262 -0
  57. package/resources/messages/sessions.d.mts.map +1 -0
  58. package/resources/messages/sessions.d.ts +262 -0
  59. package/resources/messages/sessions.d.ts.map +1 -0
  60. package/resources/messages/sessions.js +122 -0
  61. package/resources/messages/sessions.js.map +1 -0
  62. package/resources/messages/sessions.mjs +118 -0
  63. package/resources/messages/sessions.mjs.map +1 -0
  64. package/resources/messages.d.mts +2 -0
  65. package/resources/messages.d.mts.map +1 -0
  66. package/resources/messages.d.ts +2 -0
  67. package/resources/messages.d.ts.map +1 -0
  68. package/resources/messages.js +6 -0
  69. package/resources/messages.js.map +1 -0
  70. package/resources/messages.mjs +3 -0
  71. package/resources/messages.mjs.map +1 -0
  72. package/resources/omo.d.mts +98 -0
  73. package/resources/omo.d.mts.map +1 -0
  74. package/resources/omo.d.ts +98 -0
  75. package/resources/omo.d.ts.map +1 -0
  76. package/resources/omo.js +36 -0
  77. package/resources/omo.js.map +1 -0
  78. package/resources/omo.mjs +32 -0
  79. package/resources/omo.mjs.map +1 -0
  80. package/resources/schemas.d.mts +667 -76
  81. package/resources/schemas.d.mts.map +1 -1
  82. package/resources/schemas.d.ts +667 -76
  83. package/resources/schemas.d.ts.map +1 -1
  84. package/resources/schemas.js.map +1 -1
  85. package/resources/schemas.mjs.map +1 -1
  86. package/resources/shared.d.mts +671 -0
  87. package/resources/shared.d.mts.map +1 -1
  88. package/resources/shared.d.ts +671 -0
  89. package/resources/shared.d.ts.map +1 -1
  90. package/resources/sync.d.mts +142 -0
  91. package/resources/sync.d.mts.map +1 -0
  92. package/resources/sync.d.ts +142 -0
  93. package/resources/sync.d.ts.map +1 -0
  94. package/resources/sync.js +36 -0
  95. package/resources/sync.js.map +1 -0
  96. package/resources/sync.mjs +32 -0
  97. package/resources/sync.mjs.map +1 -0
  98. package/resources/user.d.mts +18 -1
  99. package/resources/user.d.mts.map +1 -1
  100. package/resources/user.d.ts +18 -1
  101. package/resources/user.d.ts.map +1 -1
  102. package/resources/user.js +11 -0
  103. package/resources/user.js.map +1 -1
  104. package/resources/user.mjs +11 -0
  105. package/resources/user.mjs.map +1 -1
  106. package/src/client.ts +80 -8
  107. package/src/internal/parse.ts +6 -0
  108. package/src/resources/document.ts +17 -4
  109. package/src/resources/index.ts +21 -0
  110. package/src/resources/memory.ts +548 -163
  111. package/src/resources/messages/index.ts +11 -0
  112. package/src/resources/messages/messages.ts +193 -0
  113. package/src/resources/messages/sessions.ts +315 -0
  114. package/src/resources/messages.ts +3 -0
  115. package/src/resources/omo.ts +132 -0
  116. package/src/resources/schemas.ts +701 -95
  117. package/src/resources/shared.ts +752 -0
  118. package/src/resources/sync.ts +179 -0
  119. package/src/resources/user.ts +23 -0
  120. package/src/version.ts +1 -1
  121. package/version.d.mts +1 -1
  122. package/version.d.mts.map +1 -1
  123. package/version.d.ts +1 -1
  124. package/version.d.ts.map +1 -1
  125. package/version.js +1 -1
  126. package/version.js.map +1 -1
  127. package/version.mjs +1 -1
  128. package/version.mjs.map +1 -1
@@ -0,0 +1,262 @@
1
+ import { APIResource } from "../../core/resource.mjs";
2
+ import { APIPromise } from "../../core/api-promise.mjs";
3
+ import { RequestOptions } from "../../internal/request-options.mjs";
4
+ export declare class Sessions extends APIResource {
5
+ /**
6
+ * Get compressed conversation context for a session.
7
+ *
8
+ * Compress your conversation into hierarchical summaries with rich metadata,
9
+ * perfect for reducing token usage in LLM context windows.
10
+ *
11
+ * **Authentication Required**: Bearer token, API key, or session token
12
+ *
13
+ * **What it returns**:
14
+ * - **short_term**: Last 15 messages compressed
15
+ * - **medium_term**: Last ~100 messages compressed
16
+ * - **long_term**: Full session compressed
17
+ * - **topics**: Key topics discussed
18
+ * - **enhanced_fields**: Project context, tech stack, key decisions, next steps, files accessed
19
+ *
20
+ * **Perfect for**:
21
+ * - Reducing token usage in LLM prompts (96% savings)
22
+ * - Providing conversation context without full history
23
+ * - Quick conversation overview for AI agents
24
+ * - Project documentation and status snapshots
25
+ *
26
+ * **Input**: Just the session ID - all context is extracted automatically
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const response = await client.messages.sessions.compress(
31
+ * 'session_id',
32
+ * );
33
+ * ```
34
+ */
35
+ compress(sessionID: string, options?: RequestOptions): APIPromise<SessionCompressResponse>;
36
+ /**
37
+ * Process all stored messages in a session that were previously stored with
38
+ * process_messages=false.
39
+ *
40
+ * **Authentication Required**: Bearer token, API key, or session token
41
+ *
42
+ * This endpoint allows you to retroactively process messages that were initially stored
43
+ * without processing. Useful for:
44
+ * - Processing messages after deciding you want them as memories
45
+ * - Batch processing large conversation sessions
46
+ * - Re-processing sessions with updated AI models
47
+ *
48
+ * **Processing Behavior**:
49
+ * - Only processes messages with status 'stored_only' or 'pending'
50
+ * - Uses the same smart batch analysis (every 15 messages)
51
+ * - Respects existing memory creation pipeline
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const response = await client.messages.sessions.process(
56
+ * 'session_id',
57
+ * );
58
+ * ```
59
+ */
60
+ process(sessionID: string, options?: RequestOptions): APIPromise<unknown>;
61
+ /**
62
+ * Retrieve message history for a specific conversation session.
63
+ *
64
+ * **Authentication Required**: Bearer token, API key, or session token
65
+ *
66
+ * **Pagination**:
67
+ * - Use `limit` and `skip` parameters for pagination
68
+ * - Messages are returned in chronological order (oldest first)
69
+ * - `total_count` indicates total messages in the session
70
+ *
71
+ * **Summaries** (if available):
72
+ * - Returns hierarchical conversation summaries (short/medium/long-term)
73
+ * - Includes `context_for_llm` field with pre-compressed context
74
+ * - Summaries are automatically generated every 15 messages
75
+ * - Use `/sessions/{session_id}/compress` endpoint to retrieve on-demand
76
+ *
77
+ * **Access Control**:
78
+ * - Only returns messages for the authenticated user
79
+ * - Workspace scoping is applied if available
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const response =
84
+ * await client.messages.sessions.retrieveHistory(
85
+ * 'session_id',
86
+ * );
87
+ * ```
88
+ */
89
+ retrieveHistory(sessionID: string, query?: SessionRetrieveHistoryParams | null | undefined, options?: RequestOptions): APIPromise<SessionRetrieveHistoryResponse>;
90
+ /**
91
+ * Get processing status for messages in a session.
92
+ *
93
+ * **Authentication Required**: Bearer token, API key, or session token
94
+ *
95
+ * **Status Information**:
96
+ * - Total messages in session
97
+ * - Processing status breakdown (queued, analyzing, completed, failed)
98
+ * - Any messages with processing errors
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const response =
103
+ * await client.messages.sessions.retrieveStatus(
104
+ * 'session_id',
105
+ * );
106
+ * ```
107
+ */
108
+ retrieveStatus(sessionID: string, options?: RequestOptions): APIPromise<unknown>;
109
+ }
110
+ /**
111
+ * Response model for session summarization endpoint
112
+ */
113
+ export interface SessionCompressResponse {
114
+ /**
115
+ * Instructions for AI agents on how to search for more details about this
116
+ * conversation
117
+ */
118
+ ai_agent_note: string;
119
+ /**
120
+ * Whether summaries were retrieved from cache (true) or just generated (false)
121
+ */
122
+ from_cache: boolean;
123
+ /**
124
+ * Session ID of the conversation
125
+ */
126
+ session_id: string;
127
+ /**
128
+ * Hierarchical conversation summaries
129
+ */
130
+ summaries: SessionCompressResponse.Summaries;
131
+ /**
132
+ * Number of messages summarized (only present if just generated)
133
+ */
134
+ message_count?: number | null;
135
+ }
136
+ export declare namespace SessionCompressResponse {
137
+ /**
138
+ * Hierarchical conversation summaries
139
+ */
140
+ interface Summaries {
141
+ /**
142
+ * When summaries were last updated
143
+ */
144
+ last_updated?: string | null;
145
+ /**
146
+ * Full session summary
147
+ */
148
+ long_term?: string | null;
149
+ /**
150
+ * Summary of last ~100 messages
151
+ */
152
+ medium_term?: string | null;
153
+ /**
154
+ * Summary of last 15 messages
155
+ */
156
+ short_term?: string | null;
157
+ /**
158
+ * Key topics discussed
159
+ */
160
+ topics?: Array<string>;
161
+ }
162
+ }
163
+ export type SessionProcessResponse = unknown;
164
+ /**
165
+ * Response model for retrieving message history
166
+ */
167
+ export interface SessionRetrieveHistoryResponse {
168
+ /**
169
+ * List of messages in chronological order
170
+ */
171
+ messages: Array<SessionRetrieveHistoryResponse.Message>;
172
+ /**
173
+ * Session ID of the conversation
174
+ */
175
+ sessionId: string;
176
+ /**
177
+ * Total number of messages in the session
178
+ */
179
+ total_count: number;
180
+ /**
181
+ * Pre-formatted compressed context ready for LLM consumption (summaries + recent
182
+ * messages)
183
+ */
184
+ context_for_llm?: string | null;
185
+ /**
186
+ * Hierarchical conversation summaries for context window compression
187
+ */
188
+ summaries?: SessionRetrieveHistoryResponse.Summaries | null;
189
+ }
190
+ export declare namespace SessionRetrieveHistoryResponse {
191
+ /**
192
+ * Response model for message storage
193
+ */
194
+ interface Message {
195
+ /**
196
+ * Content of the message - can be a simple string or structured content objects
197
+ */
198
+ content: string | Array<{
199
+ [key: string]: unknown;
200
+ }>;
201
+ /**
202
+ * When the message was created
203
+ */
204
+ createdAt: string;
205
+ /**
206
+ * Parse Server objectId of the stored message
207
+ */
208
+ objectId: string;
209
+ /**
210
+ * Role of the message sender
211
+ */
212
+ role: 'user' | 'assistant';
213
+ /**
214
+ * Session ID of the conversation
215
+ */
216
+ sessionId: string;
217
+ /**
218
+ * Status of background processing (queued, analyzing, completed, failed)
219
+ */
220
+ processing_status?: string;
221
+ }
222
+ /**
223
+ * Hierarchical conversation summaries for context window compression
224
+ */
225
+ interface Summaries {
226
+ /**
227
+ * When summaries were last updated
228
+ */
229
+ last_updated?: string | null;
230
+ /**
231
+ * Full session summary
232
+ */
233
+ long_term?: string | null;
234
+ /**
235
+ * Summary of last ~100 messages
236
+ */
237
+ medium_term?: string | null;
238
+ /**
239
+ * Summary of last 15 messages
240
+ */
241
+ short_term?: string | null;
242
+ /**
243
+ * Key topics discussed
244
+ */
245
+ topics?: Array<string>;
246
+ }
247
+ }
248
+ export type SessionRetrieveStatusResponse = unknown;
249
+ export interface SessionRetrieveHistoryParams {
250
+ /**
251
+ * Maximum number of messages to return
252
+ */
253
+ limit?: number;
254
+ /**
255
+ * Number of messages to skip for pagination
256
+ */
257
+ skip?: number;
258
+ }
259
+ export declare namespace Sessions {
260
+ export { type SessionCompressResponse as SessionCompressResponse, type SessionProcessResponse as SessionProcessResponse, type SessionRetrieveHistoryResponse as SessionRetrieveHistoryResponse, type SessionRetrieveStatusResponse as SessionRetrieveStatusResponse, type SessionRetrieveHistoryParams as SessionRetrieveHistoryParams, };
261
+ }
262
+ //# sourceMappingURL=sessions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.mts","sourceRoot":"","sources":["../../src/resources/messages/sessions.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,uBAAuB,CAAC;IAI1F;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIzE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,4BAA4B,GAAG,IAAI,GAAG,SAAc,EAC3D,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,8BAA8B,CAAC;IAI7C;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,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G,OAAO,CAAA;SAAE,CAAC,CAAC;QAEpD;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAElB;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAE3B;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAElB;;WAEG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;IAED;;OAEG;IACH,UAAiB,SAAS;QACxB;;WAEG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE7B;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE1B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE5B;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE3B;;WAEG;QACH,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACxB;CACF;AAED,MAAM,MAAM,6BAA6B,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,4BAA4B,IAAI,4BAA4B,GAClE,CAAC;CACH"}
@@ -0,0 +1,262 @@
1
+ import { APIResource } from "../../core/resource.js";
2
+ import { APIPromise } from "../../core/api-promise.js";
3
+ import { RequestOptions } from "../../internal/request-options.js";
4
+ export declare class Sessions extends APIResource {
5
+ /**
6
+ * Get compressed conversation context for a session.
7
+ *
8
+ * Compress your conversation into hierarchical summaries with rich metadata,
9
+ * perfect for reducing token usage in LLM context windows.
10
+ *
11
+ * **Authentication Required**: Bearer token, API key, or session token
12
+ *
13
+ * **What it returns**:
14
+ * - **short_term**: Last 15 messages compressed
15
+ * - **medium_term**: Last ~100 messages compressed
16
+ * - **long_term**: Full session compressed
17
+ * - **topics**: Key topics discussed
18
+ * - **enhanced_fields**: Project context, tech stack, key decisions, next steps, files accessed
19
+ *
20
+ * **Perfect for**:
21
+ * - Reducing token usage in LLM prompts (96% savings)
22
+ * - Providing conversation context without full history
23
+ * - Quick conversation overview for AI agents
24
+ * - Project documentation and status snapshots
25
+ *
26
+ * **Input**: Just the session ID - all context is extracted automatically
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const response = await client.messages.sessions.compress(
31
+ * 'session_id',
32
+ * );
33
+ * ```
34
+ */
35
+ compress(sessionID: string, options?: RequestOptions): APIPromise<SessionCompressResponse>;
36
+ /**
37
+ * Process all stored messages in a session that were previously stored with
38
+ * process_messages=false.
39
+ *
40
+ * **Authentication Required**: Bearer token, API key, or session token
41
+ *
42
+ * This endpoint allows you to retroactively process messages that were initially stored
43
+ * without processing. Useful for:
44
+ * - Processing messages after deciding you want them as memories
45
+ * - Batch processing large conversation sessions
46
+ * - Re-processing sessions with updated AI models
47
+ *
48
+ * **Processing Behavior**:
49
+ * - Only processes messages with status 'stored_only' or 'pending'
50
+ * - Uses the same smart batch analysis (every 15 messages)
51
+ * - Respects existing memory creation pipeline
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const response = await client.messages.sessions.process(
56
+ * 'session_id',
57
+ * );
58
+ * ```
59
+ */
60
+ process(sessionID: string, options?: RequestOptions): APIPromise<unknown>;
61
+ /**
62
+ * Retrieve message history for a specific conversation session.
63
+ *
64
+ * **Authentication Required**: Bearer token, API key, or session token
65
+ *
66
+ * **Pagination**:
67
+ * - Use `limit` and `skip` parameters for pagination
68
+ * - Messages are returned in chronological order (oldest first)
69
+ * - `total_count` indicates total messages in the session
70
+ *
71
+ * **Summaries** (if available):
72
+ * - Returns hierarchical conversation summaries (short/medium/long-term)
73
+ * - Includes `context_for_llm` field with pre-compressed context
74
+ * - Summaries are automatically generated every 15 messages
75
+ * - Use `/sessions/{session_id}/compress` endpoint to retrieve on-demand
76
+ *
77
+ * **Access Control**:
78
+ * - Only returns messages for the authenticated user
79
+ * - Workspace scoping is applied if available
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const response =
84
+ * await client.messages.sessions.retrieveHistory(
85
+ * 'session_id',
86
+ * );
87
+ * ```
88
+ */
89
+ retrieveHistory(sessionID: string, query?: SessionRetrieveHistoryParams | null | undefined, options?: RequestOptions): APIPromise<SessionRetrieveHistoryResponse>;
90
+ /**
91
+ * Get processing status for messages in a session.
92
+ *
93
+ * **Authentication Required**: Bearer token, API key, or session token
94
+ *
95
+ * **Status Information**:
96
+ * - Total messages in session
97
+ * - Processing status breakdown (queued, analyzing, completed, failed)
98
+ * - Any messages with processing errors
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const response =
103
+ * await client.messages.sessions.retrieveStatus(
104
+ * 'session_id',
105
+ * );
106
+ * ```
107
+ */
108
+ retrieveStatus(sessionID: string, options?: RequestOptions): APIPromise<unknown>;
109
+ }
110
+ /**
111
+ * Response model for session summarization endpoint
112
+ */
113
+ export interface SessionCompressResponse {
114
+ /**
115
+ * Instructions for AI agents on how to search for more details about this
116
+ * conversation
117
+ */
118
+ ai_agent_note: string;
119
+ /**
120
+ * Whether summaries were retrieved from cache (true) or just generated (false)
121
+ */
122
+ from_cache: boolean;
123
+ /**
124
+ * Session ID of the conversation
125
+ */
126
+ session_id: string;
127
+ /**
128
+ * Hierarchical conversation summaries
129
+ */
130
+ summaries: SessionCompressResponse.Summaries;
131
+ /**
132
+ * Number of messages summarized (only present if just generated)
133
+ */
134
+ message_count?: number | null;
135
+ }
136
+ export declare namespace SessionCompressResponse {
137
+ /**
138
+ * Hierarchical conversation summaries
139
+ */
140
+ interface Summaries {
141
+ /**
142
+ * When summaries were last updated
143
+ */
144
+ last_updated?: string | null;
145
+ /**
146
+ * Full session summary
147
+ */
148
+ long_term?: string | null;
149
+ /**
150
+ * Summary of last ~100 messages
151
+ */
152
+ medium_term?: string | null;
153
+ /**
154
+ * Summary of last 15 messages
155
+ */
156
+ short_term?: string | null;
157
+ /**
158
+ * Key topics discussed
159
+ */
160
+ topics?: Array<string>;
161
+ }
162
+ }
163
+ export type SessionProcessResponse = unknown;
164
+ /**
165
+ * Response model for retrieving message history
166
+ */
167
+ export interface SessionRetrieveHistoryResponse {
168
+ /**
169
+ * List of messages in chronological order
170
+ */
171
+ messages: Array<SessionRetrieveHistoryResponse.Message>;
172
+ /**
173
+ * Session ID of the conversation
174
+ */
175
+ sessionId: string;
176
+ /**
177
+ * Total number of messages in the session
178
+ */
179
+ total_count: number;
180
+ /**
181
+ * Pre-formatted compressed context ready for LLM consumption (summaries + recent
182
+ * messages)
183
+ */
184
+ context_for_llm?: string | null;
185
+ /**
186
+ * Hierarchical conversation summaries for context window compression
187
+ */
188
+ summaries?: SessionRetrieveHistoryResponse.Summaries | null;
189
+ }
190
+ export declare namespace SessionRetrieveHistoryResponse {
191
+ /**
192
+ * Response model for message storage
193
+ */
194
+ interface Message {
195
+ /**
196
+ * Content of the message - can be a simple string or structured content objects
197
+ */
198
+ content: string | Array<{
199
+ [key: string]: unknown;
200
+ }>;
201
+ /**
202
+ * When the message was created
203
+ */
204
+ createdAt: string;
205
+ /**
206
+ * Parse Server objectId of the stored message
207
+ */
208
+ objectId: string;
209
+ /**
210
+ * Role of the message sender
211
+ */
212
+ role: 'user' | 'assistant';
213
+ /**
214
+ * Session ID of the conversation
215
+ */
216
+ sessionId: string;
217
+ /**
218
+ * Status of background processing (queued, analyzing, completed, failed)
219
+ */
220
+ processing_status?: string;
221
+ }
222
+ /**
223
+ * Hierarchical conversation summaries for context window compression
224
+ */
225
+ interface Summaries {
226
+ /**
227
+ * When summaries were last updated
228
+ */
229
+ last_updated?: string | null;
230
+ /**
231
+ * Full session summary
232
+ */
233
+ long_term?: string | null;
234
+ /**
235
+ * Summary of last ~100 messages
236
+ */
237
+ medium_term?: string | null;
238
+ /**
239
+ * Summary of last 15 messages
240
+ */
241
+ short_term?: string | null;
242
+ /**
243
+ * Key topics discussed
244
+ */
245
+ topics?: Array<string>;
246
+ }
247
+ }
248
+ export type SessionRetrieveStatusResponse = unknown;
249
+ export interface SessionRetrieveHistoryParams {
250
+ /**
251
+ * Maximum number of messages to return
252
+ */
253
+ limit?: number;
254
+ /**
255
+ * Number of messages to skip for pagination
256
+ */
257
+ skip?: number;
258
+ }
259
+ export declare namespace Sessions {
260
+ export { type SessionCompressResponse as SessionCompressResponse, type SessionProcessResponse as SessionProcessResponse, type SessionRetrieveHistoryResponse as SessionRetrieveHistoryResponse, type SessionRetrieveStatusResponse as SessionRetrieveStatusResponse, type SessionRetrieveHistoryParams as SessionRetrieveHistoryParams, };
261
+ }
262
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/resources/messages/sessions.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,uBAAuB,CAAC;IAI1F;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIzE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,4BAA4B,GAAG,IAAI,GAAG,SAAc,EAC3D,OAA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 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Sessions = void 0;
5
+ const resource_1 = require("../../core/resource.js");
6
+ const path_1 = require("../../internal/utils/path.js");
7
+ class Sessions extends resource_1.APIResource {
8
+ /**
9
+ * Get compressed conversation context for a session.
10
+ *
11
+ * Compress your conversation into hierarchical summaries with rich metadata,
12
+ * perfect for reducing token usage in LLM context windows.
13
+ *
14
+ * **Authentication Required**: Bearer token, API key, or session token
15
+ *
16
+ * **What it returns**:
17
+ * - **short_term**: Last 15 messages compressed
18
+ * - **medium_term**: Last ~100 messages compressed
19
+ * - **long_term**: Full session compressed
20
+ * - **topics**: Key topics discussed
21
+ * - **enhanced_fields**: Project context, tech stack, key decisions, next steps, files accessed
22
+ *
23
+ * **Perfect for**:
24
+ * - Reducing token usage in LLM prompts (96% savings)
25
+ * - Providing conversation context without full history
26
+ * - Quick conversation overview for AI agents
27
+ * - Project documentation and status snapshots
28
+ *
29
+ * **Input**: Just the session ID - all context is extracted automatically
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const response = await client.messages.sessions.compress(
34
+ * 'session_id',
35
+ * );
36
+ * ```
37
+ */
38
+ compress(sessionID, options) {
39
+ return this._client.get((0, path_1.path) `/v1/messages/sessions/${sessionID}/compress`, options);
40
+ }
41
+ /**
42
+ * Process all stored messages in a session that were previously stored with
43
+ * process_messages=false.
44
+ *
45
+ * **Authentication Required**: Bearer token, API key, or session token
46
+ *
47
+ * This endpoint allows you to retroactively process messages that were initially stored
48
+ * without processing. Useful for:
49
+ * - Processing messages after deciding you want them as memories
50
+ * - Batch processing large conversation sessions
51
+ * - Re-processing sessions with updated AI models
52
+ *
53
+ * **Processing Behavior**:
54
+ * - Only processes messages with status 'stored_only' or 'pending'
55
+ * - Uses the same smart batch analysis (every 15 messages)
56
+ * - Respects existing memory creation pipeline
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const response = await client.messages.sessions.process(
61
+ * 'session_id',
62
+ * );
63
+ * ```
64
+ */
65
+ process(sessionID, options) {
66
+ return this._client.post((0, path_1.path) `/v1/messages/sessions/${sessionID}/process`, options);
67
+ }
68
+ /**
69
+ * Retrieve message history for a specific conversation session.
70
+ *
71
+ * **Authentication Required**: Bearer token, API key, or session token
72
+ *
73
+ * **Pagination**:
74
+ * - Use `limit` and `skip` parameters for pagination
75
+ * - Messages are returned in chronological order (oldest first)
76
+ * - `total_count` indicates total messages in the session
77
+ *
78
+ * **Summaries** (if available):
79
+ * - Returns hierarchical conversation summaries (short/medium/long-term)
80
+ * - Includes `context_for_llm` field with pre-compressed context
81
+ * - Summaries are automatically generated every 15 messages
82
+ * - Use `/sessions/{session_id}/compress` endpoint to retrieve on-demand
83
+ *
84
+ * **Access Control**:
85
+ * - Only returns messages for the authenticated user
86
+ * - Workspace scoping is applied if available
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const response =
91
+ * await client.messages.sessions.retrieveHistory(
92
+ * 'session_id',
93
+ * );
94
+ * ```
95
+ */
96
+ retrieveHistory(sessionID, query = {}, options) {
97
+ return this._client.get((0, path_1.path) `/v1/messages/sessions/${sessionID}`, { query, ...options });
98
+ }
99
+ /**
100
+ * Get processing status for messages in a session.
101
+ *
102
+ * **Authentication Required**: Bearer token, API key, or session token
103
+ *
104
+ * **Status Information**:
105
+ * - Total messages in session
106
+ * - Processing status breakdown (queued, analyzing, completed, failed)
107
+ * - Any messages with processing errors
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const response =
112
+ * await client.messages.sessions.retrieveStatus(
113
+ * 'session_id',
114
+ * );
115
+ * ```
116
+ */
117
+ retrieveStatus(sessionID, options) {
118
+ return this._client.get((0, path_1.path) `/v1/messages/sessions/${sessionID}/status`, options);
119
+ }
120
+ }
121
+ exports.Sessions = Sessions;
122
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/resources/messages/sessions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAGlD,uDAAiD;AAEjD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,QAAQ,CAAC,SAAiB,EAAE,OAAwB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,yBAAyB,SAAS,WAAW,EAAE,OAAO,CAAC,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,SAAiB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,yBAAyB,SAAS,UAAU,EAAE,OAAO,CAAC,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,eAAe,CACb,SAAiB,EACjB,QAAyD,EAAE,EAC3D,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,yBAAyB,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,SAAiB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,yBAAyB,SAAS,SAAS,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AAxHD,4BAwHC"}