@acontext/acontext 0.0.10 → 0.0.12
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/README.md +2 -291
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/sessions.js +1 -1
- package/dist/types/session.d.ts +53 -2
- package/dist/types/session.js +38 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,295 +8,6 @@ TypeScript SDK for interacting with the Acontext REST API.
|
|
|
8
8
|
npm install @acontext/acontext
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { AcontextClient, MessagePart } from '@acontext/acontext';
|
|
15
|
-
|
|
16
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
17
|
-
|
|
18
|
-
// List spaces for the authenticated project
|
|
19
|
-
const spaces = await client.spaces.list();
|
|
20
|
-
|
|
21
|
-
// Create a session bound to the first space
|
|
22
|
-
const session = await client.sessions.create({ spaceId: spaces.items[0].id });
|
|
23
|
-
|
|
24
|
-
// Send a text message to the session
|
|
25
|
-
await client.sessions.sendMessage(
|
|
26
|
-
session.id,
|
|
27
|
-
{
|
|
28
|
-
role: 'user',
|
|
29
|
-
parts: [MessagePart.textPart('Hello from TypeScript!')],
|
|
30
|
-
},
|
|
31
|
-
{ format: 'acontext' }
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
// Flush session buffer when needed
|
|
35
|
-
await client.sessions.flush(session.id);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
See the inline documentation for the full list of helpers covering sessions, spaces, disks, and artifact uploads.
|
|
39
|
-
|
|
40
|
-
## Health Check
|
|
41
|
-
|
|
42
|
-
Test connectivity to the Acontext API server:
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { AcontextClient } from '@acontext/acontext';
|
|
46
|
-
|
|
47
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
48
|
-
|
|
49
|
-
// Ping the server
|
|
50
|
-
const pong = await client.ping();
|
|
51
|
-
console.log(`Server responded: ${pong}`); // Output: Server responded: pong
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This is useful for:
|
|
55
|
-
- Verifying API connectivity before performing operations
|
|
56
|
-
- Health checks in monitoring systems
|
|
57
|
-
- Debugging connection issues
|
|
58
|
-
|
|
59
|
-
## Managing disks and artifacts
|
|
60
|
-
|
|
61
|
-
Artifacts now live under project disks. Create a disk first, then upload files through the disk-scoped helper:
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { AcontextClient, FileUpload } from '@acontext/acontext';
|
|
65
|
-
|
|
66
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
67
|
-
|
|
68
|
-
const disk = await client.disks.create();
|
|
69
|
-
await client.disks.artifacts.upsert(
|
|
70
|
-
disk.id,
|
|
71
|
-
{
|
|
72
|
-
file: new FileUpload({
|
|
73
|
-
filename: 'retro_notes.md',
|
|
74
|
-
content: Buffer.from('# Retro Notes\nWe shipped file uploads successfully!\n'),
|
|
75
|
-
contentType: 'text/markdown',
|
|
76
|
-
}),
|
|
77
|
-
filePath: '/notes/',
|
|
78
|
-
meta: { source: 'readme-demo' },
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Working with blocks
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import { AcontextClient } from '@acontext/acontext';
|
|
87
|
-
|
|
88
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
89
|
-
|
|
90
|
-
const space = await client.spaces.create();
|
|
91
|
-
const page = await client.blocks.create(space.id, {
|
|
92
|
-
blockType: 'page',
|
|
93
|
-
title: 'Kick-off Notes',
|
|
94
|
-
});
|
|
95
|
-
await client.blocks.create(space.id, {
|
|
96
|
-
parentId: page.id,
|
|
97
|
-
blockType: 'text',
|
|
98
|
-
title: 'First block',
|
|
99
|
-
props: { text: 'Plan the sprint goals' },
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Managing sessions
|
|
104
|
-
|
|
105
|
-
### Flush session buffer
|
|
106
|
-
|
|
107
|
-
The `flush` method clears the session buffer, useful for managing session state:
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
const result = await client.sessions.flush('session-uuid');
|
|
111
|
-
console.log(result); // { status: 0, errmsg: '' }
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Working with tools
|
|
115
|
-
|
|
116
|
-
The SDK provides APIs to manage tool names within your project:
|
|
117
|
-
|
|
118
|
-
### Get tool names
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
const tools = await client.tools.getToolName();
|
|
122
|
-
for (const tool of tools) {
|
|
123
|
-
console.log(`${tool.name} (used in ${tool.sop_count} SOPs)`);
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Rename tool names
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
const result = await client.tools.renameToolName({
|
|
131
|
-
rename: [
|
|
132
|
-
{ oldName: 'calculate', newName: 'calculate_math' },
|
|
133
|
-
{ oldName: 'search', newName: 'search_web' },
|
|
134
|
-
],
|
|
135
|
-
});
|
|
136
|
-
console.log(result); // { status: 0, errmsg: '' }
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Agent Tools
|
|
140
|
-
|
|
141
|
-
The SDK provides agent tools that allow LLMs (OpenAI, Anthropic) to interact with Acontext disks through function calling. These tools can be converted to OpenAI or Anthropic tool schemas and executed when the LLM calls them.
|
|
142
|
-
|
|
143
|
-
### Pre-configured Disk Tools
|
|
144
|
-
|
|
145
|
-
The SDK includes a pre-configured `DISK_TOOLS` pool with four disk operation tools:
|
|
146
|
-
|
|
147
|
-
- **`write_file`**: Write text content to a file
|
|
148
|
-
- **`read_file`**: Read a text file with optional line offset and limit
|
|
149
|
-
- **`replace_string`**: Replace strings in a file
|
|
150
|
-
- **`list_artifacts`**: List files and directories in a path
|
|
151
|
-
|
|
152
|
-
### Getting Tool Schemas for LLM APIs
|
|
153
|
-
|
|
154
|
-
Convert tools to the appropriate format for your LLM provider:
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
157
|
-
import { AcontextClient, DISK_TOOLS } from '@acontext/acontext';
|
|
158
|
-
|
|
159
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
160
|
-
|
|
161
|
-
// Get OpenAI-compatible tool schemas
|
|
162
|
-
const openaiTools = DISK_TOOLS.toOpenAIToolSchema();
|
|
163
|
-
|
|
164
|
-
// Get Anthropic-compatible tool schemas
|
|
165
|
-
const anthropicTools = DISK_TOOLS.toAnthropicToolSchema();
|
|
166
|
-
|
|
167
|
-
// Use with OpenAI API
|
|
168
|
-
import OpenAI from 'openai';
|
|
169
|
-
const openai = new OpenAI({ apiKey: 'your-openai-key' });
|
|
170
|
-
const completion = await openai.chat.completions.create({
|
|
171
|
-
model: 'gpt-4',
|
|
172
|
-
messages: [{ role: 'user', content: 'Write a file called hello.txt with "Hello, World!"' }],
|
|
173
|
-
tools: openaiTools,
|
|
174
|
-
});
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Executing Tools
|
|
178
|
-
|
|
179
|
-
When an LLM calls a tool, execute it using the tool pool:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
import { AcontextClient, DISK_TOOLS } from '@acontext/acontext';
|
|
183
|
-
|
|
184
|
-
const client = new AcontextClient({ apiKey: 'sk-ac-your-root-api-bearer-token' });
|
|
185
|
-
|
|
186
|
-
// Create a disk for the tools to operate on
|
|
187
|
-
const disk = await client.disks.create();
|
|
188
|
-
|
|
189
|
-
// Create a context for the tools
|
|
190
|
-
const ctx = DISK_TOOLS.formatContext(client, disk.id);
|
|
191
|
-
|
|
192
|
-
// Execute a tool (e.g., after LLM returns a tool call)
|
|
193
|
-
const result = await DISK_TOOLS.executeTool(ctx, 'write_file', {
|
|
194
|
-
filename: 'hello.txt',
|
|
195
|
-
file_path: '/notes/',
|
|
196
|
-
content: 'Hello, World!',
|
|
197
|
-
});
|
|
198
|
-
console.log(result); // File 'hello.txt' written successfully to '/notes/hello.txt'
|
|
199
|
-
|
|
200
|
-
// Read the file
|
|
201
|
-
const readResult = await DISK_TOOLS.executeTool(ctx, 'read_file', {
|
|
202
|
-
filename: 'hello.txt',
|
|
203
|
-
file_path: '/notes/',
|
|
204
|
-
});
|
|
205
|
-
console.log(readResult);
|
|
206
|
-
|
|
207
|
-
// List files in a directory
|
|
208
|
-
const listResult = await DISK_TOOLS.executeTool(ctx, 'list_artifacts', {
|
|
209
|
-
file_path: '/notes/',
|
|
210
|
-
});
|
|
211
|
-
console.log(listResult);
|
|
212
|
-
|
|
213
|
-
// Replace a string in a file
|
|
214
|
-
const replaceResult = await DISK_TOOLS.executeTool(ctx, 'replace_string', {
|
|
215
|
-
filename: 'hello.txt',
|
|
216
|
-
file_path: '/notes/',
|
|
217
|
-
old_string: 'Hello',
|
|
218
|
-
new_string: 'Hi',
|
|
219
|
-
});
|
|
220
|
-
console.log(replaceResult);
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### Creating Custom Tools
|
|
224
|
-
|
|
225
|
-
You can create custom tools by extending `AbstractBaseTool`:
|
|
226
|
-
|
|
227
|
-
```typescript
|
|
228
|
-
import { AbstractBaseTool, BaseContext, BaseToolPool } from '@acontext/acontext';
|
|
229
|
-
|
|
230
|
-
interface MyContext extends BaseContext {
|
|
231
|
-
// Your context properties
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
class MyCustomTool extends AbstractBaseTool {
|
|
235
|
-
readonly name = 'my_custom_tool';
|
|
236
|
-
readonly description = 'A custom tool that does something';
|
|
237
|
-
readonly arguments = {
|
|
238
|
-
param1: {
|
|
239
|
-
type: 'string',
|
|
240
|
-
description: 'First parameter',
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
readonly requiredArguments = ['param1'];
|
|
244
|
-
|
|
245
|
-
async execute(ctx: MyContext, llmArguments: Record<string, unknown>): Promise<string> {
|
|
246
|
-
const param1 = llmArguments.param1 as string;
|
|
247
|
-
// Your custom logic here
|
|
248
|
-
return `Result: ${param1}`;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Create a custom tool pool
|
|
253
|
-
class MyToolPool extends BaseToolPool {
|
|
254
|
-
formatContext(...args: unknown[]): MyContext {
|
|
255
|
-
// Create and return your context
|
|
256
|
-
return {};
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const myPool = new MyToolPool();
|
|
261
|
-
myPool.addTool(new MyCustomTool());
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Semantic search within spaces
|
|
265
|
-
|
|
266
|
-
The SDK provides a powerful semantic search API for finding content within your spaces:
|
|
267
|
-
|
|
268
|
-
### 1. Experience Search (Advanced AI-powered search)
|
|
269
|
-
|
|
270
|
-
The most sophisticated search that can operate in two modes: **fast** (quick semantic search) or **agentic** (AI-powered iterative refinement).
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
import { AcontextClient } from '@acontext/acontext';
|
|
274
|
-
|
|
275
|
-
const client = new AcontextClient({ apiKey: 'sk_project_token' });
|
|
276
|
-
|
|
277
|
-
// Fast mode - quick semantic search
|
|
278
|
-
const result = await client.spaces.experienceSearch('space-uuid', {
|
|
279
|
-
query: 'How to implement authentication?',
|
|
280
|
-
limit: 10,
|
|
281
|
-
mode: 'fast',
|
|
282
|
-
semanticThreshold: 0.8,
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
// Agentic mode - AI-powered iterative search
|
|
286
|
-
const agenticResult = await client.spaces.experienceSearch('space-uuid', {
|
|
287
|
-
query: 'What are the best practices for API security?',
|
|
288
|
-
limit: 10,
|
|
289
|
-
mode: 'agentic',
|
|
290
|
-
maxIterations: 20,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
// Access results
|
|
294
|
-
for (const block of result.cited_blocks) {
|
|
295
|
-
console.log(`${block.title} (distance: ${block.distance})`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (result.final_answer) {
|
|
299
|
-
console.log(`AI Answer: ${result.final_answer}`);
|
|
300
|
-
}
|
|
301
|
-
```
|
|
11
|
+
# 🔍 Document
|
|
302
12
|
|
|
13
|
+
To understand more about this SDK, please view [our docs](https://docs.acontext.io/) and [api references](https://docs.acontext.io/api-reference/introduction)
|
|
@@ -34,7 +34,7 @@ export declare class SessionsAPI {
|
|
|
34
34
|
cursor?: string | null;
|
|
35
35
|
timeDesc?: boolean | null;
|
|
36
36
|
}): Promise<GetTasksOutput>;
|
|
37
|
-
|
|
37
|
+
storeMessage(sessionId: string, blob: MessageBlob, options?: {
|
|
38
38
|
format?: 'acontext' | 'openai' | 'anthropic';
|
|
39
39
|
fileField?: string | null;
|
|
40
40
|
file?: FileUpload | null;
|
|
@@ -73,7 +73,7 @@ class SessionsAPI {
|
|
|
73
73
|
});
|
|
74
74
|
return types_1.GetTasksOutputSchema.parse(data);
|
|
75
75
|
}
|
|
76
|
-
async
|
|
76
|
+
async storeMessage(sessionId, blob, options) {
|
|
77
77
|
const format = options?.format ?? 'openai';
|
|
78
78
|
if (!['acontext', 'openai', 'anthropic'].includes(format)) {
|
|
79
79
|
throw new Error("format must be one of {'acontext', 'openai', 'anthropic'}");
|
package/dist/types/session.d.ts
CHANGED
|
@@ -62,12 +62,29 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
62
62
|
updated_at: z.ZodString;
|
|
63
63
|
}, z.core.$strip>;
|
|
64
64
|
export type Session = z.infer<typeof SessionSchema>;
|
|
65
|
+
/**
|
|
66
|
+
* TaskData represents the structured data stored in a task.
|
|
67
|
+
* This schema matches the TaskData model in acontext_core/schema/session/task.py
|
|
68
|
+
* and the Go API TaskData struct.
|
|
69
|
+
*/
|
|
70
|
+
export declare const TaskDataSchema: z.ZodObject<{
|
|
71
|
+
task_description: z.ZodString;
|
|
72
|
+
progresses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
73
|
+
user_preferences: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
74
|
+
sop_thinking: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type TaskData = z.infer<typeof TaskDataSchema>;
|
|
65
77
|
export declare const TaskSchema: z.ZodObject<{
|
|
66
78
|
id: z.ZodString;
|
|
67
79
|
session_id: z.ZodString;
|
|
68
80
|
project_id: z.ZodString;
|
|
69
81
|
order: z.ZodNumber;
|
|
70
|
-
data: z.
|
|
82
|
+
data: z.ZodObject<{
|
|
83
|
+
task_description: z.ZodString;
|
|
84
|
+
progresses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
85
|
+
user_preferences: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
86
|
+
sop_thinking: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
87
|
+
}, z.core.$strip>;
|
|
71
88
|
status: z.ZodString;
|
|
72
89
|
is_planning: z.ZodBoolean;
|
|
73
90
|
space_digested: z.ZodBoolean;
|
|
@@ -96,6 +113,7 @@ export declare const PublicURLSchema: z.ZodObject<{
|
|
|
96
113
|
export type PublicURL = z.infer<typeof PublicURLSchema>;
|
|
97
114
|
export declare const GetMessagesOutputSchema: z.ZodObject<{
|
|
98
115
|
items: z.ZodArray<z.ZodUnknown>;
|
|
116
|
+
ids: z.ZodArray<z.ZodString>;
|
|
99
117
|
next_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
118
|
has_more: z.ZodBoolean;
|
|
101
119
|
public_urls: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -110,7 +128,12 @@ export declare const GetTasksOutputSchema: z.ZodObject<{
|
|
|
110
128
|
session_id: z.ZodString;
|
|
111
129
|
project_id: z.ZodString;
|
|
112
130
|
order: z.ZodNumber;
|
|
113
|
-
data: z.
|
|
131
|
+
data: z.ZodObject<{
|
|
132
|
+
task_description: z.ZodString;
|
|
133
|
+
progresses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
134
|
+
user_preferences: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
135
|
+
sop_thinking: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
114
137
|
status: z.ZodString;
|
|
115
138
|
is_planning: z.ZodBoolean;
|
|
116
139
|
space_digested: z.ZodBoolean;
|
|
@@ -138,6 +161,29 @@ export declare const RemoveToolResultParamsSchema: z.ZodObject<{
|
|
|
138
161
|
tool_result_placeholder: z.ZodOptional<z.ZodString>;
|
|
139
162
|
}, z.core.$strip>;
|
|
140
163
|
export type RemoveToolResultParams = z.infer<typeof RemoveToolResultParamsSchema>;
|
|
164
|
+
/**
|
|
165
|
+
* Parameters for the remove_tool_call_params edit strategy.
|
|
166
|
+
*/
|
|
167
|
+
export declare const RemoveToolCallParamsParamsSchema: z.ZodObject<{
|
|
168
|
+
keep_recent_n_tool_calls: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
export type RemoveToolCallParamsParams = z.infer<typeof RemoveToolCallParamsParamsSchema>;
|
|
171
|
+
/**
|
|
172
|
+
* Edit strategy to remove parameters from old tool-call parts.
|
|
173
|
+
*
|
|
174
|
+
* Keeps the most recent N tool calls with full parameters, replacing older
|
|
175
|
+
* tool call arguments with empty JSON "{}". The tool call ID and name remain
|
|
176
|
+
* intact so tool-results can still reference them.
|
|
177
|
+
*
|
|
178
|
+
* Example: { type: 'remove_tool_call_params', params: { keep_recent_n_tool_calls: 5 } }
|
|
179
|
+
*/
|
|
180
|
+
export declare const RemoveToolCallParamsStrategySchema: z.ZodObject<{
|
|
181
|
+
type: z.ZodLiteral<"remove_tool_call_params">;
|
|
182
|
+
params: z.ZodObject<{
|
|
183
|
+
keep_recent_n_tool_calls: z.ZodOptional<z.ZodNumber>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type RemoveToolCallParamsStrategy = z.infer<typeof RemoveToolCallParamsStrategySchema>;
|
|
141
187
|
/**
|
|
142
188
|
* Edit strategy to replace old tool results with placeholder text.
|
|
143
189
|
*
|
|
@@ -184,6 +230,11 @@ export declare const EditStrategySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
184
230
|
keep_recent_n_tool_results: z.ZodOptional<z.ZodNumber>;
|
|
185
231
|
tool_result_placeholder: z.ZodOptional<z.ZodString>;
|
|
186
232
|
}, z.core.$strip>;
|
|
233
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
234
|
+
type: z.ZodLiteral<"remove_tool_call_params">;
|
|
235
|
+
params: z.ZodObject<{
|
|
236
|
+
keep_recent_n_tool_calls: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
}, z.core.$strip>;
|
|
187
238
|
}, z.core.$strip>, z.ZodObject<{
|
|
188
239
|
type: z.ZodLiteral<"token_limit">;
|
|
189
240
|
params: z.ZodObject<{
|
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.RemoveToolResultParamsSchema = exports.TokenCountsSchema = exports.LearningStatusSchema = exports.GetTasksOutputSchema = exports.GetMessagesOutputSchema = exports.PublicURLSchema = exports.ListSessionsOutputSchema = exports.TaskSchema = 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.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(),
|
|
@@ -41,12 +41,23 @@ exports.SessionSchema = zod_1.z.object({
|
|
|
41
41
|
created_at: zod_1.z.string(),
|
|
42
42
|
updated_at: zod_1.z.string(),
|
|
43
43
|
});
|
|
44
|
+
/**
|
|
45
|
+
* TaskData represents the structured data stored in a task.
|
|
46
|
+
* This schema matches the TaskData model in acontext_core/schema/session/task.py
|
|
47
|
+
* and the Go API TaskData struct.
|
|
48
|
+
*/
|
|
49
|
+
exports.TaskDataSchema = zod_1.z.object({
|
|
50
|
+
task_description: zod_1.z.string(),
|
|
51
|
+
progresses: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
52
|
+
user_preferences: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
53
|
+
sop_thinking: zod_1.z.string().nullable().optional(),
|
|
54
|
+
});
|
|
44
55
|
exports.TaskSchema = zod_1.z.object({
|
|
45
56
|
id: zod_1.z.string(),
|
|
46
57
|
session_id: zod_1.z.string(),
|
|
47
58
|
project_id: zod_1.z.string(),
|
|
48
59
|
order: zod_1.z.number(),
|
|
49
|
-
data:
|
|
60
|
+
data: exports.TaskDataSchema,
|
|
50
61
|
status: zod_1.z.string(),
|
|
51
62
|
is_planning: zod_1.z.boolean(),
|
|
52
63
|
space_digested: zod_1.z.boolean(),
|
|
@@ -64,6 +75,7 @@ exports.PublicURLSchema = zod_1.z.object({
|
|
|
64
75
|
});
|
|
65
76
|
exports.GetMessagesOutputSchema = zod_1.z.object({
|
|
66
77
|
items: zod_1.z.array(zod_1.z.unknown()),
|
|
78
|
+
ids: zod_1.z.array(zod_1.z.string()),
|
|
67
79
|
next_cursor: zod_1.z.string().nullable().optional(),
|
|
68
80
|
has_more: zod_1.z.boolean(),
|
|
69
81
|
public_urls: zod_1.z.record(zod_1.z.string(), exports.PublicURLSchema).nullable().optional(),
|
|
@@ -95,6 +107,29 @@ exports.RemoveToolResultParamsSchema = zod_1.z.object({
|
|
|
95
107
|
*/
|
|
96
108
|
tool_result_placeholder: zod_1.z.string().optional(),
|
|
97
109
|
});
|
|
110
|
+
/**
|
|
111
|
+
* Parameters for the remove_tool_call_params edit strategy.
|
|
112
|
+
*/
|
|
113
|
+
exports.RemoveToolCallParamsParamsSchema = zod_1.z.object({
|
|
114
|
+
/**
|
|
115
|
+
* Number of most recent tool calls to keep with full parameters.
|
|
116
|
+
* @default 3
|
|
117
|
+
*/
|
|
118
|
+
keep_recent_n_tool_calls: zod_1.z.number().optional(),
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Edit strategy to remove parameters from old tool-call parts.
|
|
122
|
+
*
|
|
123
|
+
* Keeps the most recent N tool calls with full parameters, replacing older
|
|
124
|
+
* tool call arguments with empty JSON "{}". The tool call ID and name remain
|
|
125
|
+
* intact so tool-results can still reference them.
|
|
126
|
+
*
|
|
127
|
+
* Example: { type: 'remove_tool_call_params', params: { keep_recent_n_tool_calls: 5 } }
|
|
128
|
+
*/
|
|
129
|
+
exports.RemoveToolCallParamsStrategySchema = zod_1.z.object({
|
|
130
|
+
type: zod_1.z.literal('remove_tool_call_params'),
|
|
131
|
+
params: exports.RemoveToolCallParamsParamsSchema,
|
|
132
|
+
});
|
|
98
133
|
/**
|
|
99
134
|
* Edit strategy to replace old tool results with placeholder text.
|
|
100
135
|
*
|
|
@@ -134,5 +169,6 @@ exports.TokenLimitStrategySchema = zod_1.z.object({
|
|
|
134
169
|
*/
|
|
135
170
|
exports.EditStrategySchema = zod_1.z.union([
|
|
136
171
|
exports.RemoveToolResultStrategySchema,
|
|
172
|
+
exports.RemoveToolCallParamsStrategySchema,
|
|
137
173
|
exports.TokenLimitStrategySchema,
|
|
138
174
|
]);
|