@acontext/acontext 0.0.20 → 0.0.21
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.
|
@@ -36,6 +36,17 @@ export declare class SessionsAPI {
|
|
|
36
36
|
cursor?: string | null;
|
|
37
37
|
timeDesc?: boolean | null;
|
|
38
38
|
}): Promise<GetTasksOutput>;
|
|
39
|
+
/**
|
|
40
|
+
* Get a summary of all tasks in a session as a formatted string.
|
|
41
|
+
*
|
|
42
|
+
* @param sessionId - The UUID of the session.
|
|
43
|
+
* @param options - Options for retrieving the summary.
|
|
44
|
+
* @param options.limit - Maximum number of tasks to include in the summary.
|
|
45
|
+
* @returns A formatted string containing the session summary with all task information.
|
|
46
|
+
*/
|
|
47
|
+
getSessionSummary(sessionId: string, options?: {
|
|
48
|
+
limit?: number | null;
|
|
49
|
+
}): Promise<string>;
|
|
39
50
|
storeMessage(sessionId: string, blob: MessageBlob, options?: {
|
|
40
51
|
format?: 'acontext' | 'openai' | 'anthropic' | 'gemini';
|
|
41
52
|
fileField?: string | null;
|
|
@@ -54,6 +65,7 @@ export declare class SessionsAPI {
|
|
|
54
65
|
* @param options.editStrategies - Optional list of edit strategies to apply before format conversion.
|
|
55
66
|
* Examples:
|
|
56
67
|
* - Remove tool results: [{ type: 'remove_tool_result', params: { keep_recent_n_tool_results: 3 } }]
|
|
68
|
+
* - Middle out: [{ type: 'middle_out', params: { token_reduce_to: 5000 } }]
|
|
57
69
|
* - Token limit: [{ type: 'token_limit', params: { limit_tokens: 20000 } }]
|
|
58
70
|
* @param options.pinEditingStrategiesAtMessage - Message ID to pin editing strategies at.
|
|
59
71
|
* When provided, strategies are only applied to messages up to and including this message ID,
|
|
@@ -79,6 +79,47 @@ class SessionsAPI {
|
|
|
79
79
|
});
|
|
80
80
|
return types_1.GetTasksOutputSchema.parse(data);
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a summary of all tasks in a session as a formatted string.
|
|
84
|
+
*
|
|
85
|
+
* @param sessionId - The UUID of the session.
|
|
86
|
+
* @param options - Options for retrieving the summary.
|
|
87
|
+
* @param options.limit - Maximum number of tasks to include in the summary.
|
|
88
|
+
* @returns A formatted string containing the session summary with all task information.
|
|
89
|
+
*/
|
|
90
|
+
async getSessionSummary(sessionId, options) {
|
|
91
|
+
const tasksOutput = await this.getTasks(sessionId, {
|
|
92
|
+
limit: options?.limit,
|
|
93
|
+
timeDesc: false,
|
|
94
|
+
});
|
|
95
|
+
const tasks = tasksOutput.items;
|
|
96
|
+
if (tasks.length === 0) {
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
const parts = [];
|
|
100
|
+
for (const task of tasks) {
|
|
101
|
+
const taskLines = [
|
|
102
|
+
`<task id="${task.order}" description="${task.data.task_description}">`
|
|
103
|
+
];
|
|
104
|
+
if (task.data.progresses && task.data.progresses.length > 0) {
|
|
105
|
+
taskLines.push('<progress>');
|
|
106
|
+
task.data.progresses.forEach((p, i) => {
|
|
107
|
+
taskLines.push(`${i + 1}. ${p}`);
|
|
108
|
+
});
|
|
109
|
+
taskLines.push('</progress>');
|
|
110
|
+
}
|
|
111
|
+
if (task.data.user_preferences && task.data.user_preferences.length > 0) {
|
|
112
|
+
taskLines.push('<user_preference>');
|
|
113
|
+
task.data.user_preferences.forEach((pref, i) => {
|
|
114
|
+
taskLines.push(`${i + 1}. ${pref}`);
|
|
115
|
+
});
|
|
116
|
+
taskLines.push('</user_preference>');
|
|
117
|
+
}
|
|
118
|
+
taskLines.push('</task>');
|
|
119
|
+
parts.push(taskLines.join('\n'));
|
|
120
|
+
}
|
|
121
|
+
return parts.join('\n');
|
|
122
|
+
}
|
|
82
123
|
async storeMessage(sessionId, blob, options) {
|
|
83
124
|
const format = options?.format ?? 'openai';
|
|
84
125
|
if (!['acontext', 'openai', 'anthropic', 'gemini'].includes(format)) {
|
|
@@ -137,6 +178,7 @@ class SessionsAPI {
|
|
|
137
178
|
* @param options.editStrategies - Optional list of edit strategies to apply before format conversion.
|
|
138
179
|
* Examples:
|
|
139
180
|
* - Remove tool results: [{ type: 'remove_tool_result', params: { keep_recent_n_tool_results: 3 } }]
|
|
181
|
+
* - Middle out: [{ type: 'middle_out', params: { token_reduce_to: 5000 } }]
|
|
140
182
|
* - Token limit: [{ type: 'token_limit', params: { limit_tokens: 20000 } }]
|
|
141
183
|
* @param options.pinEditingStrategiesAtMessage - Message ID to pin editing strategies at.
|
|
142
184
|
* When provided, strategies are only applied to messages up to and including this message ID,
|
|
@@ -23,7 +23,7 @@ export declare class SkillsAPI {
|
|
|
23
23
|
* @returns ListSkillsOutput containing skills with name and description for the current page,
|
|
24
24
|
* along with pagination information (next_cursor and has_more)
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
listCatalog(options?: {
|
|
27
27
|
user?: string | null;
|
|
28
28
|
limit?: number | null;
|
|
29
29
|
cursor?: string | null;
|
package/dist/resources/skills.js
CHANGED
|
@@ -40,7 +40,7 @@ class SkillsAPI {
|
|
|
40
40
|
* @returns ListSkillsOutput containing skills with name and description for the current page,
|
|
41
41
|
* along with pagination information (next_cursor and has_more)
|
|
42
42
|
*/
|
|
43
|
-
async
|
|
43
|
+
async listCatalog(options) {
|
|
44
44
|
// Use 100 as default for catalog listing (only name and description, lightweight)
|
|
45
45
|
const effectiveLimit = options?.limit ?? 100;
|
|
46
46
|
const params = (0, utils_1.buildParams)({
|
package/dist/types/session.d.ts
CHANGED
|
@@ -235,6 +235,25 @@ export declare const TokenLimitStrategySchema: z.ZodObject<{
|
|
|
235
235
|
}, z.core.$strip>;
|
|
236
236
|
}, z.core.$strip>;
|
|
237
237
|
export type TokenLimitStrategy = z.infer<typeof TokenLimitStrategySchema>;
|
|
238
|
+
/**
|
|
239
|
+
* Parameters for the middle_out edit strategy.
|
|
240
|
+
*/
|
|
241
|
+
export declare const MiddleOutParamsSchema: z.ZodObject<{
|
|
242
|
+
token_reduce_to: z.ZodNumber;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
export type MiddleOutParams = z.infer<typeof MiddleOutParamsSchema>;
|
|
245
|
+
/**
|
|
246
|
+
* Edit strategy to reduce prompt size by removing middle messages.
|
|
247
|
+
*
|
|
248
|
+
* Example: { type: 'middle_out', params: { token_reduce_to: 5000 } }
|
|
249
|
+
*/
|
|
250
|
+
export declare const MiddleOutStrategySchema: z.ZodObject<{
|
|
251
|
+
type: z.ZodLiteral<"middle_out">;
|
|
252
|
+
params: z.ZodObject<{
|
|
253
|
+
token_reduce_to: z.ZodNumber;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
}, z.core.$strip>;
|
|
256
|
+
export type MiddleOutStrategy = z.infer<typeof MiddleOutStrategySchema>;
|
|
238
257
|
/**
|
|
239
258
|
* Union schema for all edit strategies.
|
|
240
259
|
* When adding new strategies, extend this union: z.union([RemoveToolResultStrategySchema, OtherStrategySchema, ...])
|
|
@@ -257,5 +276,10 @@ export declare const EditStrategySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
257
276
|
params: z.ZodObject<{
|
|
258
277
|
limit_tokens: z.ZodNumber;
|
|
259
278
|
}, z.core.$strip>;
|
|
279
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
280
|
+
type: z.ZodLiteral<"middle_out">;
|
|
281
|
+
params: z.ZodObject<{
|
|
282
|
+
token_reduce_to: z.ZodNumber;
|
|
283
|
+
}, z.core.$strip>;
|
|
260
284
|
}, z.core.$strip>]>;
|
|
261
285
|
export type EditStrategy = z.infer<typeof EditStrategySchema>;
|
package/dist/types/session.js
CHANGED
|
@@ -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.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;
|
|
6
|
+
exports.EditStrategySchema = exports.MiddleOutStrategySchema = exports.MiddleOutParamsSchema = 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(),
|
|
@@ -190,6 +190,21 @@ exports.TokenLimitStrategySchema = zod_1.z.object({
|
|
|
190
190
|
type: zod_1.z.literal('token_limit'),
|
|
191
191
|
params: exports.TokenLimitParamsSchema,
|
|
192
192
|
});
|
|
193
|
+
/**
|
|
194
|
+
* Parameters for the middle_out edit strategy.
|
|
195
|
+
*/
|
|
196
|
+
exports.MiddleOutParamsSchema = zod_1.z.object({
|
|
197
|
+
token_reduce_to: zod_1.z.number(),
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* Edit strategy to reduce prompt size by removing middle messages.
|
|
201
|
+
*
|
|
202
|
+
* Example: { type: 'middle_out', params: { token_reduce_to: 5000 } }
|
|
203
|
+
*/
|
|
204
|
+
exports.MiddleOutStrategySchema = zod_1.z.object({
|
|
205
|
+
type: zod_1.z.literal('middle_out'),
|
|
206
|
+
params: exports.MiddleOutParamsSchema,
|
|
207
|
+
});
|
|
193
208
|
/**
|
|
194
209
|
* Union schema for all edit strategies.
|
|
195
210
|
* When adding new strategies, extend this union: z.union([RemoveToolResultStrategySchema, OtherStrategySchema, ...])
|
|
@@ -198,4 +213,5 @@ exports.EditStrategySchema = zod_1.z.union([
|
|
|
198
213
|
exports.RemoveToolResultStrategySchema,
|
|
199
214
|
exports.RemoveToolCallParamsStrategySchema,
|
|
200
215
|
exports.TokenLimitStrategySchema,
|
|
216
|
+
exports.MiddleOutStrategySchema,
|
|
201
217
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acontext/acontext",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "TypeScript SDK for the Acontext API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"dev": "tsc --watch",
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"lint": "eslint src",
|
|
12
|
+
"e2e": "tsx examples/basic-usage.ts",
|
|
12
13
|
"prepublishOnly": "npm run build"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"eslint": "^9.39.1",
|
|
36
37
|
"jest": "^30.2.0",
|
|
37
38
|
"ts-jest": "^29.4.5",
|
|
39
|
+
"tsx": "^4.19.0",
|
|
38
40
|
"typescript": "^5.9.3"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|