@acontext/acontext 0.1.4 → 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.
package/dist/client.d.ts CHANGED
@@ -4,7 +4,6 @@
4
4
  import { DisksAPI } from './resources/disks';
5
5
  import { SandboxesAPI } from './resources/sandboxes';
6
6
  import { SessionsAPI } from './resources/sessions';
7
- import { ToolsAPI } from './resources/tools';
8
7
  import { SkillsAPI } from './resources/skills';
9
8
  import { UsersAPI } from './resources/users';
10
9
  import { RequesterProtocol } from './client-types';
@@ -22,7 +21,6 @@ export declare class AcontextClient implements RequesterProtocol {
22
21
  sessions: SessionsAPI;
23
22
  disks: DisksAPI;
24
23
  artifacts: DisksAPI['artifacts'];
25
- tools: ToolsAPI;
26
24
  skills: SkillsAPI;
27
25
  users: UsersAPI;
28
26
  sandboxes: SandboxesAPI;
package/dist/client.js CHANGED
@@ -41,7 +41,6 @@ const errors_1 = require("./errors");
41
41
  const disks_1 = require("./resources/disks");
42
42
  const sandboxes_1 = require("./resources/sandboxes");
43
43
  const sessions_1 = require("./resources/sessions");
44
- const tools_1 = require("./resources/tools");
45
44
  const skills_1 = require("./resources/skills");
46
45
  const users_1 = require("./resources/users");
47
46
  const constants_1 = require("./constants");
@@ -75,7 +74,6 @@ class AcontextClient {
75
74
  this.sessions = new sessions_1.SessionsAPI(this);
76
75
  this.disks = new disks_1.DisksAPI(this);
77
76
  this.artifacts = this.disks.artifacts;
78
- this.tools = new tools_1.ToolsAPI(this);
79
77
  this.skills = new skills_1.SkillsAPI(this);
80
78
  this.users = new users_1.UsersAPI(this);
81
79
  this.sandboxes = new sandboxes_1.SandboxesAPI(this);
@@ -3,7 +3,6 @@
3
3
  */
4
4
  export * from './sessions';
5
5
  export * from './disks';
6
- export * from './tools';
7
6
  export * from './skills';
8
7
  export * from './sandboxes';
9
8
  export * from './users';
@@ -19,7 +19,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./sessions"), exports);
21
21
  __exportStar(require("./disks"), exports);
22
- __exportStar(require("./tools"), exports);
23
22
  __exportStar(require("./skills"), exports);
24
23
  __exportStar(require("./sandboxes"), exports);
25
24
  __exportStar(require("./users"), exports);
@@ -30,10 +30,22 @@ export declare class SessionsAPI {
30
30
  timeDesc?: boolean | null;
31
31
  filterByConfigs?: Record<string, unknown> | null;
32
32
  }): Promise<ListSessionsOutput>;
33
+ /**
34
+ * Create a new session.
35
+ *
36
+ * @param options - Options for creating a session.
37
+ * @param options.user - Optional user identifier string.
38
+ * @param options.disableTaskTracking - Whether to disable task tracking for this session.
39
+ * @param options.configs - Optional session configuration dictionary.
40
+ * @param options.useUuid - Optional UUID string to use as the session ID. If not provided, a UUID will be auto-generated.
41
+ * If a session with this UUID already exists, a 409 Conflict error will be raised.
42
+ * @returns The created Session object.
43
+ */
33
44
  create(options?: {
34
45
  user?: string | null;
35
46
  disableTaskTracking?: boolean | null;
36
47
  configs?: Record<string, unknown>;
48
+ useUuid?: string | null;
37
49
  }): Promise<Session>;
38
50
  delete(sessionId: string): Promise<void>;
39
51
  updateConfigs(sessionId: string, options: {
@@ -56,8 +68,23 @@ export declare class SessionsAPI {
56
68
  getSessionSummary(sessionId: string, options?: {
57
69
  limit?: number | null;
58
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
+ */
59
85
  storeMessage(sessionId: string, blob: MessageBlob, options?: {
60
86
  format?: 'acontext' | 'openai' | 'anthropic' | 'gemini';
87
+ meta?: Record<string, unknown> | null;
61
88
  fileField?: string | null;
62
89
  file?: FileUpload | null;
63
90
  }): Promise<Message>;
@@ -114,4 +141,55 @@ export declare class SessionsAPI {
114
141
  * pending counts and updated_at timestamp.
115
142
  */
116
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>>;
117
195
  }
@@ -44,6 +44,17 @@ class SessionsAPI {
44
44
  });
45
45
  return types_1.ListSessionsOutputSchema.parse(data);
46
46
  }
47
+ /**
48
+ * Create a new session.
49
+ *
50
+ * @param options - Options for creating a session.
51
+ * @param options.user - Optional user identifier string.
52
+ * @param options.disableTaskTracking - Whether to disable task tracking for this session.
53
+ * @param options.configs - Optional session configuration dictionary.
54
+ * @param options.useUuid - Optional UUID string to use as the session ID. If not provided, a UUID will be auto-generated.
55
+ * If a session with this UUID already exists, a 409 Conflict error will be raised.
56
+ * @returns The created Session object.
57
+ */
47
58
  async create(options) {
48
59
  const payload = {};
49
60
  if (options?.user !== undefined && options?.user !== null) {
@@ -55,6 +66,9 @@ class SessionsAPI {
55
66
  if (options?.configs !== undefined) {
56
67
  payload.configs = options.configs;
57
68
  }
69
+ if (options?.useUuid !== undefined && options?.useUuid !== null) {
70
+ payload.use_uuid = options.useUuid;
71
+ }
58
72
  const data = await this.requester.request('POST', '/session', {
59
73
  jsonData: Object.keys(payload).length > 0 ? payload : undefined,
60
74
  });
@@ -125,6 +139,20 @@ class SessionsAPI {
125
139
  }
126
140
  return parts.join('\n');
127
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
+ */
128
156
  async storeMessage(sessionId, blob, options) {
129
157
  const format = options?.format ?? 'openai';
130
158
  if (!['acontext', 'openai', 'anthropic', 'gemini'].includes(format)) {
@@ -136,6 +164,9 @@ class SessionsAPI {
136
164
  const payload = {
137
165
  format,
138
166
  };
167
+ if (options?.meta !== undefined && options?.meta !== null) {
168
+ payload.meta = options.meta;
169
+ }
139
170
  if (format === 'acontext') {
140
171
  if (blob instanceof messages_1.AcontextMessage) {
141
172
  payload.blob = blob.toJSON();
@@ -242,5 +273,68 @@ class SessionsAPI {
242
273
  const data = await this.requester.request('GET', `/session/${sessionId}/observing_status`);
243
274
  return types_1.MessageObservingStatusSchema.parse(data);
244
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
+ }
245
339
  }
246
340
  exports.SessionsAPI = SessionsAPI;
@@ -7,3 +7,8 @@ export declare const FileContentSchema: z.ZodObject<{
7
7
  raw: z.ZodString;
8
8
  }, z.core.$strip>;
9
9
  export type FileContent = z.infer<typeof FileContentSchema>;
10
+ export declare const FlagResponseSchema: z.ZodObject<{
11
+ status: z.ZodNumber;
12
+ errmsg: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export type FlagResponse = z.infer<typeof FlagResponseSchema>;
@@ -3,9 +3,13 @@
3
3
  * Common type definitions shared across modules.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FileContentSchema = void 0;
6
+ exports.FlagResponseSchema = exports.FileContentSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  exports.FileContentSchema = zod_1.z.object({
9
9
  type: zod_1.z.string(),
10
10
  raw: zod_1.z.string(),
11
11
  });
12
+ exports.FlagResponseSchema = zod_1.z.object({
13
+ status: zod_1.z.number(),
14
+ errmsg: zod_1.z.string(),
15
+ });
@@ -4,7 +4,6 @@
4
4
  export * from './common';
5
5
  export * from './session';
6
6
  export * from './disk';
7
- export * from './tool';
8
7
  export * from './skill';
9
8
  export * from './sandbox';
10
9
  export * from './user';
@@ -20,7 +20,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./common"), exports);
21
21
  __exportStar(require("./session"), exports);
22
22
  __exportStar(require("./disk"), exports);
23
- __exportStar(require("./tool"), exports);
24
23
  __exportStar(require("./skill"), exports);
25
24
  __exportStar(require("./sandbox"), exports);
26
25
  __exportStar(require("./user"), exports);
@@ -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.4",
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",
@@ -1,13 +0,0 @@
1
- /**
2
- * Tool endpoints.
3
- */
4
- import { RequesterProtocol } from '../client-types';
5
- import { ToolRenameItem, ToolReferenceData, FlagResponse } from '../types/tool';
6
- export declare class ToolsAPI {
7
- private requester;
8
- constructor(requester: RequesterProtocol);
9
- renameToolName(options: {
10
- rename: ToolRenameItem[];
11
- }): Promise<FlagResponse>;
12
- getToolName(): Promise<ToolReferenceData[]>;
13
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tool endpoints.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ToolsAPI = void 0;
7
- const tool_1 = require("../types/tool");
8
- class ToolsAPI {
9
- constructor(requester) {
10
- this.requester = requester;
11
- }
12
- async renameToolName(options) {
13
- const payload = { rename: options.rename };
14
- const data = await this.requester.request('PUT', '/tool/name', {
15
- jsonData: payload,
16
- });
17
- return tool_1.FlagResponseSchema.parse(data);
18
- }
19
- async getToolName() {
20
- const data = await this.requester.request('GET', '/tool/name');
21
- return Array.isArray(data)
22
- ? data.map((item) => tool_1.ToolReferenceDataSchema.parse(item))
23
- : [];
24
- }
25
- }
26
- exports.ToolsAPI = ToolsAPI;
@@ -1,19 +0,0 @@
1
- /**
2
- * Type definitions for tool resources.
3
- */
4
- import { z } from 'zod';
5
- export declare const ToolRenameItemSchema: z.ZodObject<{
6
- oldName: z.ZodString;
7
- newName: z.ZodString;
8
- }, z.core.$strip>;
9
- export type ToolRenameItem = z.infer<typeof ToolRenameItemSchema>;
10
- export declare const ToolReferenceDataSchema: z.ZodObject<{
11
- name: z.ZodString;
12
- sop_count: z.ZodNumber;
13
- }, z.core.$strip>;
14
- export type ToolReferenceData = z.infer<typeof ToolReferenceDataSchema>;
15
- export declare const FlagResponseSchema: z.ZodObject<{
16
- status: z.ZodNumber;
17
- errmsg: z.ZodString;
18
- }, z.core.$strip>;
19
- export type FlagResponse = z.infer<typeof FlagResponseSchema>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /**
3
- * Type definitions for tool resources.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FlagResponseSchema = exports.ToolReferenceDataSchema = exports.ToolRenameItemSchema = void 0;
7
- const zod_1 = require("zod");
8
- exports.ToolRenameItemSchema = zod_1.z.object({
9
- oldName: zod_1.z.string(),
10
- newName: zod_1.z.string(),
11
- });
12
- exports.ToolReferenceDataSchema = zod_1.z.object({
13
- name: zod_1.z.string(),
14
- sop_count: zod_1.z.number(),
15
- });
16
- exports.FlagResponseSchema = zod_1.z.object({
17
- status: zod_1.z.number(),
18
- errmsg: zod_1.z.string(),
19
- });