@acontext/acontext 0.1.5 → 0.1.6

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.
@@ -68,8 +68,23 @@ export declare class SessionsAPI {
68
68
  getSessionSummary(sessionId: string, options?: {
69
69
  limit?: number | null;
70
70
  }): Promise<string>;
71
+ /**
72
+ * Store a message to a session.
73
+ *
74
+ * @param sessionId - The UUID of the session.
75
+ * @param blob - The message blob in Acontext, OpenAI, Anthropic, or Gemini format.
76
+ * @param options - Options for storing the message.
77
+ * @param options.format - The format of the message blob ('acontext', 'openai', 'anthropic', or 'gemini').
78
+ * @param options.meta - Optional user-provided metadata for the message. This metadata is stored
79
+ * separately from the message content and can be retrieved via getMessages().metas
80
+ * or updated via patchMessageMeta(). Works with all formats.
81
+ * @param options.fileField - The field name for file upload. Only used when format is 'acontext'.
82
+ * @param options.file - Optional file upload. Only used when format is 'acontext'.
83
+ * @returns The created Message object. The msg.meta field contains only user-provided metadata.
84
+ */
71
85
  storeMessage(sessionId: string, blob: MessageBlob, options?: {
72
86
  format?: 'acontext' | 'openai' | 'anthropic' | 'gemini';
87
+ meta?: Record<string, unknown> | null;
73
88
  fileField?: string | null;
74
89
  file?: FileUpload | null;
75
90
  }): Promise<Message>;
@@ -126,4 +141,55 @@ export declare class SessionsAPI {
126
141
  * pending counts and updated_at timestamp.
127
142
  */
128
143
  messagesObservingStatus(sessionId: string): Promise<MessageObservingStatus>;
144
+ /**
145
+ * Update message metadata using patch semantics.
146
+ *
147
+ * Only updates keys present in the meta object. Existing keys not in the request
148
+ * are preserved. To delete a key, pass null as its value.
149
+ *
150
+ * @param sessionId - The UUID of the session.
151
+ * @param messageId - The UUID of the message.
152
+ * @param meta - Object of metadata keys to add, update, or delete. Pass null as a value to delete that key.
153
+ * @returns The complete user metadata after the patch operation.
154
+ *
155
+ * @example
156
+ * // Add/update keys
157
+ * const updated = await client.sessions.patchMessageMeta(
158
+ * sessionId, messageId,
159
+ * { status: 'processed', score: 0.95 }
160
+ * );
161
+ *
162
+ * @example
163
+ * // Delete a key
164
+ * const updated = await client.sessions.patchMessageMeta(
165
+ * sessionId, messageId,
166
+ * { old_key: null } // Deletes "old_key"
167
+ * );
168
+ */
169
+ patchMessageMeta(sessionId: string, messageId: string, meta: Record<string, unknown>): Promise<Record<string, unknown>>;
170
+ /**
171
+ * Update session configs using patch semantics.
172
+ *
173
+ * Only updates keys present in the configs object. Existing keys not in the request
174
+ * are preserved. To delete a key, pass null as its value.
175
+ *
176
+ * @param sessionId - The UUID of the session.
177
+ * @param configs - Object of config keys to add, update, or delete. Pass null as a value to delete that key.
178
+ * @returns The complete configs after the patch operation.
179
+ *
180
+ * @example
181
+ * // Add/update keys
182
+ * const updated = await client.sessions.patchConfigs(
183
+ * sessionId,
184
+ * { agent: 'bot2', temperature: 0.8 }
185
+ * );
186
+ *
187
+ * @example
188
+ * // Delete a key
189
+ * const updated = await client.sessions.patchConfigs(
190
+ * sessionId,
191
+ * { old_key: null } // Deletes "old_key"
192
+ * );
193
+ */
194
+ patchConfigs(sessionId: string, configs: Record<string, unknown>): Promise<Record<string, unknown>>;
129
195
  }
@@ -139,6 +139,20 @@ class SessionsAPI {
139
139
  }
140
140
  return parts.join('\n');
141
141
  }
142
+ /**
143
+ * Store a message to a session.
144
+ *
145
+ * @param sessionId - The UUID of the session.
146
+ * @param blob - The message blob in Acontext, OpenAI, Anthropic, or Gemini format.
147
+ * @param options - Options for storing the message.
148
+ * @param options.format - The format of the message blob ('acontext', 'openai', 'anthropic', or 'gemini').
149
+ * @param options.meta - Optional user-provided metadata for the message. This metadata is stored
150
+ * separately from the message content and can be retrieved via getMessages().metas
151
+ * or updated via patchMessageMeta(). Works with all formats.
152
+ * @param options.fileField - The field name for file upload. Only used when format is 'acontext'.
153
+ * @param options.file - Optional file upload. Only used when format is 'acontext'.
154
+ * @returns The created Message object. The msg.meta field contains only user-provided metadata.
155
+ */
142
156
  async storeMessage(sessionId, blob, options) {
143
157
  const format = options?.format ?? 'openai';
144
158
  if (!['acontext', 'openai', 'anthropic', 'gemini'].includes(format)) {
@@ -150,6 +164,9 @@ class SessionsAPI {
150
164
  const payload = {
151
165
  format,
152
166
  };
167
+ if (options?.meta !== undefined && options?.meta !== null) {
168
+ payload.meta = options.meta;
169
+ }
153
170
  if (format === 'acontext') {
154
171
  if (blob instanceof messages_1.AcontextMessage) {
155
172
  payload.blob = blob.toJSON();
@@ -256,5 +273,68 @@ class SessionsAPI {
256
273
  const data = await this.requester.request('GET', `/session/${sessionId}/observing_status`);
257
274
  return types_1.MessageObservingStatusSchema.parse(data);
258
275
  }
276
+ /**
277
+ * Update message metadata using patch semantics.
278
+ *
279
+ * Only updates keys present in the meta object. Existing keys not in the request
280
+ * are preserved. To delete a key, pass null as its value.
281
+ *
282
+ * @param sessionId - The UUID of the session.
283
+ * @param messageId - The UUID of the message.
284
+ * @param meta - Object of metadata keys to add, update, or delete. Pass null as a value to delete that key.
285
+ * @returns The complete user metadata after the patch operation.
286
+ *
287
+ * @example
288
+ * // Add/update keys
289
+ * const updated = await client.sessions.patchMessageMeta(
290
+ * sessionId, messageId,
291
+ * { status: 'processed', score: 0.95 }
292
+ * );
293
+ *
294
+ * @example
295
+ * // Delete a key
296
+ * const updated = await client.sessions.patchMessageMeta(
297
+ * sessionId, messageId,
298
+ * { old_key: null } // Deletes "old_key"
299
+ * );
300
+ */
301
+ async patchMessageMeta(sessionId, messageId, meta) {
302
+ const payload = { meta };
303
+ const data = await this.requester.request('PATCH', `/session/${sessionId}/messages/${messageId}/meta`, {
304
+ jsonData: payload,
305
+ });
306
+ return data.meta ?? {};
307
+ }
308
+ /**
309
+ * Update session configs using patch semantics.
310
+ *
311
+ * Only updates keys present in the configs object. Existing keys not in the request
312
+ * are preserved. To delete a key, pass null as its value.
313
+ *
314
+ * @param sessionId - The UUID of the session.
315
+ * @param configs - Object of config keys to add, update, or delete. Pass null as a value to delete that key.
316
+ * @returns The complete configs after the patch operation.
317
+ *
318
+ * @example
319
+ * // Add/update keys
320
+ * const updated = await client.sessions.patchConfigs(
321
+ * sessionId,
322
+ * { agent: 'bot2', temperature: 0.8 }
323
+ * );
324
+ *
325
+ * @example
326
+ * // Delete a key
327
+ * const updated = await client.sessions.patchConfigs(
328
+ * sessionId,
329
+ * { old_key: null } // Deletes "old_key"
330
+ * );
331
+ */
332
+ async patchConfigs(sessionId, configs) {
333
+ const payload = { configs };
334
+ const data = await this.requester.request('PATCH', `/session/${sessionId}/configs`, {
335
+ jsonData: payload,
336
+ });
337
+ return data.configs ?? {};
338
+ }
259
339
  }
260
340
  exports.SessionsAPI = SessionsAPI;
@@ -111,6 +111,7 @@ export type PublicURL = z.infer<typeof PublicURLSchema>;
111
111
  export declare const GetMessagesOutputSchema: z.ZodObject<{
112
112
  items: z.ZodArray<z.ZodUnknown>;
113
113
  ids: z.ZodArray<z.ZodString>;
114
+ metas: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
114
115
  next_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
115
116
  has_more: z.ZodBoolean;
116
117
  this_time_tokens: z.ZodNumber;
@@ -74,6 +74,8 @@ exports.PublicURLSchema = zod_1.z.object({
74
74
  exports.GetMessagesOutputSchema = zod_1.z.object({
75
75
  items: zod_1.z.array(zod_1.z.unknown()),
76
76
  ids: zod_1.z.array(zod_1.z.string()),
77
+ /** User-provided metadata for each message (same order as items/ids) */
78
+ metas: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).default([]),
77
79
  next_cursor: zod_1.z.string().nullable().optional(),
78
80
  has_more: zod_1.z.boolean(),
79
81
  /** Total token count of the returned messages */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acontext/acontext",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "TypeScript SDK for the Acontext API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",