@papr/memory 1.19.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 (130) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +1 -1
  3. package/README.md +13 -1
  4. package/client.d.mts +38 -10
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +38 -10
  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 +527 -95
  33. package/resources/memory.d.mts.map +1 -1
  34. package/resources/memory.d.ts +527 -95
  35. package/resources/memory.d.ts.map +1 -1
  36. package/resources/memory.js +21 -6
  37. package/resources/memory.js.map +1 -1
  38. package/resources/memory.mjs +21 -6
  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 +712 -92
  81. package/resources/schemas.d.mts.map +1 -1
  82. package/resources/schemas.d.ts +712 -92
  83. package/resources/schemas.d.ts.map +1 -1
  84. package/resources/schemas.js +23 -10
  85. package/resources/schemas.js.map +1 -1
  86. package/resources/schemas.mjs +23 -10
  87. package/resources/schemas.mjs.map +1 -1
  88. package/resources/shared.d.mts +671 -0
  89. package/resources/shared.d.mts.map +1 -1
  90. package/resources/shared.d.ts +671 -0
  91. package/resources/shared.d.ts.map +1 -1
  92. package/resources/sync.d.mts +142 -0
  93. package/resources/sync.d.mts.map +1 -0
  94. package/resources/sync.d.ts +142 -0
  95. package/resources/sync.d.ts.map +1 -0
  96. package/resources/sync.js +36 -0
  97. package/resources/sync.js.map +1 -0
  98. package/resources/sync.mjs +32 -0
  99. package/resources/sync.mjs.map +1 -0
  100. package/resources/user.d.mts +18 -1
  101. package/resources/user.d.mts.map +1 -1
  102. package/resources/user.d.ts +18 -1
  103. package/resources/user.d.ts.map +1 -1
  104. package/resources/user.js +11 -0
  105. package/resources/user.js.map +1 -1
  106. package/resources/user.mjs +11 -0
  107. package/resources/user.mjs.map +1 -1
  108. package/src/client.ts +81 -9
  109. package/src/internal/parse.ts +6 -0
  110. package/src/resources/document.ts +17 -4
  111. package/src/resources/index.ts +21 -0
  112. package/src/resources/memory.ts +586 -134
  113. package/src/resources/messages/index.ts +11 -0
  114. package/src/resources/messages/messages.ts +193 -0
  115. package/src/resources/messages/sessions.ts +315 -0
  116. package/src/resources/messages.ts +3 -0
  117. package/src/resources/omo.ts +132 -0
  118. package/src/resources/schemas.ts +740 -111
  119. package/src/resources/shared.ts +752 -0
  120. package/src/resources/sync.ts +179 -0
  121. package/src/resources/user.ts +23 -0
  122. package/src/version.ts +1 -1
  123. package/version.d.mts +1 -1
  124. package/version.d.mts.map +1 -1
  125. package/version.d.ts +1 -1
  126. package/version.d.ts.map +1 -1
  127. package/version.js +1 -1
  128. package/version.js.map +1 -1
  129. package/version.mjs +1 -1
  130. package/version.mjs.map +1 -1
@@ -0,0 +1,54 @@
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.Messages = void 0;
5
+ const tslib_1 = require("../../internal/tslib.js");
6
+ const resource_1 = require("../../core/resource.js");
7
+ const SessionsAPI = tslib_1.__importStar(require("./sessions.js"));
8
+ const sessions_1 = require("./sessions.js");
9
+ class Messages extends resource_1.APIResource {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.sessions = new SessionsAPI.Sessions(this._client);
13
+ }
14
+ /**
15
+ * Store a chat message and queue it for AI analysis and memory creation.
16
+ *
17
+ * **Authentication Required**: Bearer token, API key, or session token
18
+ *
19
+ * **Processing Control**:
20
+ * - Set `process_messages: true` (default) to enable full AI analysis and memory creation
21
+ * - Set `process_messages: false` to store messages only without processing into memories
22
+ *
23
+ * **Processing Flow** (when process_messages=true):
24
+ * 1. Message is immediately stored in PostMessage class
25
+ * 2. Background processing analyzes the message for memory-worthiness
26
+ * 3. If worthy, creates a memory with appropriate role-based categorization
27
+ * 4. Links the message to the created memory
28
+ *
29
+ * **Role-Based Categories**:
30
+ * - **User messages**: preference, task, goal, facts, context
31
+ * - **Assistant messages**: skills, learning
32
+ *
33
+ * **Session Management**:
34
+ * - `sessionId` is required to group related messages
35
+ * - Use the same `sessionId` for an entire conversation
36
+ * - **Optional `title`**: Set a human-readable title for the conversation (e.g., "Q4 Planning Session")
37
+ * - Retrieve conversation history using GET /messages/sessions/{sessionId}
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const response = await client.messages.store({
42
+ * content: 'string',
43
+ * role: 'user',
44
+ * sessionId: 'sessionId',
45
+ * });
46
+ * ```
47
+ */
48
+ store(body, options) {
49
+ return this._client.post('/v1/messages', { body, ...options });
50
+ }
51
+ }
52
+ exports.Messages = Messages;
53
+ Messages.Sessions = sessions_1.Sessions;
54
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAGlD,mEAA0C;AAC1C,4CAOoB;AAIpB,MAAa,QAAS,SAAQ,sBAAW;IAAzC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuC1E,CAAC;IArCC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,IAAwB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AAxCD,4BAwCC;AA0HD,QAAQ,CAAC,QAAQ,GAAG,mBAAQ,CAAC"}
@@ -0,0 +1,49 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../core/resource.mjs";
3
+ import * as SessionsAPI from "./sessions.mjs";
4
+ import { Sessions, } from "./sessions.mjs";
5
+ export class Messages extends APIResource {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.sessions = new SessionsAPI.Sessions(this._client);
9
+ }
10
+ /**
11
+ * Store a chat message and queue it for AI analysis and memory creation.
12
+ *
13
+ * **Authentication Required**: Bearer token, API key, or session token
14
+ *
15
+ * **Processing Control**:
16
+ * - Set `process_messages: true` (default) to enable full AI analysis and memory creation
17
+ * - Set `process_messages: false` to store messages only without processing into memories
18
+ *
19
+ * **Processing Flow** (when process_messages=true):
20
+ * 1. Message is immediately stored in PostMessage class
21
+ * 2. Background processing analyzes the message for memory-worthiness
22
+ * 3. If worthy, creates a memory with appropriate role-based categorization
23
+ * 4. Links the message to the created memory
24
+ *
25
+ * **Role-Based Categories**:
26
+ * - **User messages**: preference, task, goal, facts, context
27
+ * - **Assistant messages**: skills, learning
28
+ *
29
+ * **Session Management**:
30
+ * - `sessionId` is required to group related messages
31
+ * - Use the same `sessionId` for an entire conversation
32
+ * - **Optional `title`**: Set a human-readable title for the conversation (e.g., "Q4 Planning Session")
33
+ * - Retrieve conversation history using GET /messages/sessions/{sessionId}
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const response = await client.messages.store({
38
+ * content: 'string',
39
+ * role: 'user',
40
+ * sessionId: 'sessionId',
41
+ * });
42
+ * ```
43
+ */
44
+ store(body, options) {
45
+ return this._client.post('/v1/messages', { body, ...options });
46
+ }
47
+ }
48
+ Messages.Sessions = Sessions;
49
+ //# sourceMappingURL=messages.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,KAAK,WAAW;OAChB,EAML,QAAQ,GACT;AAID,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuC1E,CAAC;IArCC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,IAAwB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AA0HD,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC"}
@@ -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,OAAO,CAAC;CAGjF;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,uBAAuB,CA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G;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,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,OAAO,CAAC;CAGjF;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IAC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