@acontext/acontext 0.0.12 → 0.0.14

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.
@@ -6,6 +6,7 @@ export interface BaseContext {
6
6
  export interface BaseConverter {
7
7
  toOpenAIToolSchema(): Record<string, unknown>;
8
8
  toAnthropicToolSchema(): Record<string, unknown>;
9
+ toGeminiToolSchema(): Record<string, unknown>;
9
10
  }
10
11
  export interface BaseTool extends BaseConverter {
11
12
  readonly name: string;
@@ -22,6 +23,7 @@ export declare abstract class AbstractBaseTool implements BaseTool {
22
23
  abstract execute(ctx: BaseContext, llmArguments: Record<string, unknown>): Promise<string>;
23
24
  toOpenAIToolSchema(): Record<string, unknown>;
24
25
  toAnthropicToolSchema(): Record<string, unknown>;
26
+ toGeminiToolSchema(): Record<string, unknown>;
25
27
  }
26
28
  export declare abstract class BaseToolPool {
27
29
  protected tools: Map<string, BaseTool>;
@@ -32,5 +34,6 @@ export declare abstract class BaseToolPool {
32
34
  toolExists(toolName: string): boolean;
33
35
  toOpenAIToolSchema(): Record<string, unknown>[];
34
36
  toAnthropicToolSchema(): Record<string, unknown>[];
37
+ toGeminiToolSchema(): Record<string, unknown>[];
35
38
  abstract formatContext(...args: unknown[]): BaseContext;
36
39
  }
@@ -30,6 +30,17 @@ class AbstractBaseTool {
30
30
  },
31
31
  };
32
32
  }
33
+ toGeminiToolSchema() {
34
+ return {
35
+ name: this.name,
36
+ description: this.description,
37
+ parameters: {
38
+ type: 'object',
39
+ properties: this.arguments,
40
+ required: this.requiredArguments,
41
+ },
42
+ };
43
+ }
33
44
  }
34
45
  exports.AbstractBaseTool = AbstractBaseTool;
35
46
  class BaseToolPool {
@@ -64,5 +75,8 @@ class BaseToolPool {
64
75
  toAnthropicToolSchema() {
65
76
  return Array.from(this.tools.values()).map((tool) => tool.toAnthropicToolSchema());
66
77
  }
78
+ toGeminiToolSchema() {
79
+ return Array.from(this.tools.values()).map((tool) => tool.toGeminiToolSchema());
80
+ }
67
81
  }
68
82
  exports.BaseToolPool = BaseToolPool;
@@ -4,7 +4,7 @@
4
4
  import { RequesterProtocol } from '../client-types';
5
5
  import { AcontextMessage } from '../messages';
6
6
  import { FileUpload } from '../uploads';
7
- import { EditStrategy, GetMessagesOutput, GetTasksOutput, LearningStatus, ListSessionsOutput, Message, Session, TokenCounts } from '../types';
7
+ import { EditStrategy, GetMessagesOutput, GetTasksOutput, LearningStatus, ListSessionsOutput, Message, MessageObservingStatus, Session, TokenCounts } from '../types';
8
8
  export type MessageBlob = AcontextMessage | Record<string, unknown>;
9
9
  export declare class SessionsAPI {
10
10
  private requester;
@@ -35,7 +35,7 @@ export declare class SessionsAPI {
35
35
  timeDesc?: boolean | null;
36
36
  }): Promise<GetTasksOutput>;
37
37
  storeMessage(sessionId: string, blob: MessageBlob, options?: {
38
- format?: 'acontext' | 'openai' | 'anthropic';
38
+ format?: 'acontext' | 'openai' | 'anthropic' | 'gemini';
39
39
  fileField?: string | null;
40
40
  file?: FileUpload | null;
41
41
  }): Promise<Message>;
@@ -47,7 +47,7 @@ export declare class SessionsAPI {
47
47
  * @param options.limit - Maximum number of messages to return.
48
48
  * @param options.cursor - Cursor for pagination.
49
49
  * @param options.withAssetPublicUrl - Whether to include presigned URLs for assets.
50
- * @param options.format - The format of the messages ('acontext', 'openai', or 'anthropic').
50
+ * @param options.format - The format of the messages ('acontext', 'openai', 'anthropic', or 'gemini').
51
51
  * @param options.timeDesc - Order by created_at descending if true, ascending if false.
52
52
  * @param options.editStrategies - Optional list of edit strategies to apply before format conversion.
53
53
  * Examples:
@@ -59,7 +59,7 @@ export declare class SessionsAPI {
59
59
  limit?: number | null;
60
60
  cursor?: string | null;
61
61
  withAssetPublicUrl?: boolean | null;
62
- format?: 'acontext' | 'openai' | 'anthropic';
62
+ format?: 'acontext' | 'openai' | 'anthropic' | 'gemini';
63
63
  timeDesc?: boolean | null;
64
64
  editStrategies?: Array<EditStrategy> | null;
65
65
  }): Promise<GetMessagesOutput>;
@@ -84,4 +84,15 @@ export declare class SessionsAPI {
84
84
  * @returns TokenCounts object containing total_tokens.
85
85
  */
86
86
  getTokenCounts(sessionId: string): Promise<TokenCounts>;
87
+ /**
88
+ * Get message observing status counts for a session.
89
+ *
90
+ * Returns the count of messages by their observing status:
91
+ * observed, in_process, and pending.
92
+ *
93
+ * @param sessionId - The UUID of the session.
94
+ * @returns MessageObservingStatus object containing observed, in_process,
95
+ * pending counts and updated_at timestamp.
96
+ */
97
+ messagesObservingStatus(sessionId: string): Promise<MessageObservingStatus>;
87
98
  }
@@ -75,8 +75,8 @@ class SessionsAPI {
75
75
  }
76
76
  async storeMessage(sessionId, blob, options) {
77
77
  const format = options?.format ?? 'openai';
78
- if (!['acontext', 'openai', 'anthropic'].includes(format)) {
79
- throw new Error("format must be one of {'acontext', 'openai', 'anthropic'}");
78
+ if (!['acontext', 'openai', 'anthropic', 'gemini'].includes(format)) {
79
+ throw new Error("format must be one of {'acontext', 'openai', 'anthropic', 'gemini'}");
80
80
  }
81
81
  if (options?.file && !options?.fileField) {
82
82
  throw new Error('fileField is required when file is provided');
@@ -126,7 +126,7 @@ class SessionsAPI {
126
126
  * @param options.limit - Maximum number of messages to return.
127
127
  * @param options.cursor - Cursor for pagination.
128
128
  * @param options.withAssetPublicUrl - Whether to include presigned URLs for assets.
129
- * @param options.format - The format of the messages ('acontext', 'openai', or 'anthropic').
129
+ * @param options.format - The format of the messages ('acontext', 'openai', 'anthropic', or 'gemini').
130
130
  * @param options.timeDesc - Order by created_at descending if true, ascending if false.
131
131
  * @param options.editStrategies - Optional list of edit strategies to apply before format conversion.
132
132
  * Examples:
@@ -180,5 +180,19 @@ class SessionsAPI {
180
180
  const data = await this.requester.request('GET', `/session/${sessionId}/token_counts`);
181
181
  return types_1.TokenCountsSchema.parse(data);
182
182
  }
183
+ /**
184
+ * Get message observing status counts for a session.
185
+ *
186
+ * Returns the count of messages by their observing status:
187
+ * observed, in_process, and pending.
188
+ *
189
+ * @param sessionId - The UUID of the session.
190
+ * @returns MessageObservingStatus object containing observed, in_process,
191
+ * pending counts and updated_at timestamp.
192
+ */
193
+ async messagesObservingStatus(sessionId) {
194
+ const data = await this.requester.request('GET', `/session/${sessionId}/observing_status`);
195
+ return types_1.MessageObservingStatusSchema.parse(data);
196
+ }
183
197
  }
184
198
  exports.SessionsAPI = SessionsAPI;
@@ -153,6 +153,13 @@ export declare const TokenCountsSchema: z.ZodObject<{
153
153
  total_tokens: z.ZodNumber;
154
154
  }, z.core.$strip>;
155
155
  export type TokenCounts = z.infer<typeof TokenCountsSchema>;
156
+ export declare const MessageObservingStatusSchema: z.ZodObject<{
157
+ observed: z.ZodNumber;
158
+ in_process: z.ZodNumber;
159
+ pending: z.ZodNumber;
160
+ updated_at: z.ZodString;
161
+ }, z.core.$strip>;
162
+ export type MessageObservingStatus = z.infer<typeof MessageObservingStatusSchema>;
156
163
  /**
157
164
  * Parameters for the remove_tool_result edit strategy.
158
165
  */
@@ -3,7 +3,7 @@
3
3
  * Type definitions for session, message, and task resources.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EditStrategySchema = exports.TokenLimitStrategySchema = exports.TokenLimitParamsSchema = exports.RemoveToolResultStrategySchema = exports.RemoveToolCallParamsStrategySchema = exports.RemoveToolCallParamsParamsSchema = exports.RemoveToolResultParamsSchema = exports.TokenCountsSchema = exports.LearningStatusSchema = exports.GetTasksOutputSchema = exports.GetMessagesOutputSchema = exports.PublicURLSchema = exports.ListSessionsOutputSchema = exports.TaskSchema = exports.TaskDataSchema = exports.SessionSchema = exports.MessageSchema = exports.PartSchema = exports.AssetSchema = void 0;
6
+ exports.EditStrategySchema = exports.TokenLimitStrategySchema = exports.TokenLimitParamsSchema = exports.RemoveToolResultStrategySchema = exports.RemoveToolCallParamsStrategySchema = exports.RemoveToolCallParamsParamsSchema = exports.RemoveToolResultParamsSchema = exports.MessageObservingStatusSchema = exports.TokenCountsSchema = exports.LearningStatusSchema = exports.GetTasksOutputSchema = exports.GetMessagesOutputSchema = exports.PublicURLSchema = exports.ListSessionsOutputSchema = exports.TaskSchema = exports.TaskDataSchema = exports.SessionSchema = exports.MessageSchema = exports.PartSchema = exports.AssetSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  exports.AssetSchema = zod_1.z.object({
9
9
  bucket: zod_1.z.string(),
@@ -92,6 +92,12 @@ exports.LearningStatusSchema = zod_1.z.object({
92
92
  exports.TokenCountsSchema = zod_1.z.object({
93
93
  total_tokens: zod_1.z.number(),
94
94
  });
95
+ exports.MessageObservingStatusSchema = zod_1.z.object({
96
+ observed: zod_1.z.number(),
97
+ in_process: zod_1.z.number(),
98
+ pending: zod_1.z.number(),
99
+ updated_at: zod_1.z.string(),
100
+ });
95
101
  /**
96
102
  * Parameters for the remove_tool_result edit strategy.
97
103
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acontext/acontext",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "TypeScript SDK for the Acontext API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",