@acontext/acontext 0.0.18 → 0.0.20

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.
@@ -107,6 +107,38 @@ export declare class DownloadFileTool extends AbstractBaseTool {
107
107
  readonly requiredArguments: string[];
108
108
  execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
109
109
  }
110
+ export declare class GrepArtifactsTool extends AbstractBaseTool {
111
+ readonly name = "grep_artifacts";
112
+ readonly description = "Search for text patterns within file contents using regex. Only searches text-based files (code, markdown, json, csv, etc.). Use this to find specific code patterns, TODO comments, function definitions, or any text content.";
113
+ readonly arguments: {
114
+ query: {
115
+ type: string;
116
+ description: string;
117
+ };
118
+ limit: {
119
+ type: string;
120
+ description: string;
121
+ };
122
+ };
123
+ readonly requiredArguments: string[];
124
+ execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
125
+ }
126
+ export declare class GlobArtifactsTool extends AbstractBaseTool {
127
+ readonly name = "glob_artifacts";
128
+ readonly description = "Find files by path pattern using glob syntax. Use * for any characters, ? for single character, ** for recursive directories. Perfect for finding files by extension or location.";
129
+ readonly arguments: {
130
+ query: {
131
+ type: string;
132
+ description: string;
133
+ };
134
+ limit: {
135
+ type: string;
136
+ description: string;
137
+ };
138
+ };
139
+ readonly requiredArguments: string[];
140
+ execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
141
+ }
110
142
  export declare class DiskToolPool extends BaseToolPool {
111
143
  formatContext(client: AcontextClient, diskId: string): DiskContext;
112
144
  }
@@ -3,7 +3,7 @@
3
3
  * Disk tools for agent operations.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DISK_TOOLS = exports.DiskToolPool = exports.DownloadFileTool = exports.ListTool = exports.ReplaceStringTool = exports.ReadFileTool = exports.WriteFileTool = void 0;
6
+ exports.DISK_TOOLS = exports.DiskToolPool = exports.GlobArtifactsTool = exports.GrepArtifactsTool = exports.DownloadFileTool = exports.ListTool = exports.ReplaceStringTool = exports.ReadFileTool = exports.WriteFileTool = void 0;
7
7
  const uploads_1 = require("../uploads");
8
8
  const base_1 = require("./base");
9
9
  function normalizePath(path) {
@@ -262,6 +262,76 @@ class DownloadFileTool extends base_1.AbstractBaseTool {
262
262
  }
263
263
  }
264
264
  exports.DownloadFileTool = DownloadFileTool;
265
+ class GrepArtifactsTool extends base_1.AbstractBaseTool {
266
+ constructor() {
267
+ super(...arguments);
268
+ this.name = 'grep_artifacts';
269
+ this.description = 'Search for text patterns within file contents using regex. Only searches text-based files (code, markdown, json, csv, etc.). Use this to find specific code patterns, TODO comments, function definitions, or any text content.';
270
+ this.arguments = {
271
+ query: {
272
+ type: 'string',
273
+ description: "Regex pattern to search for (e.g., 'TODO.*', 'function.*calculate', 'import.*pandas')",
274
+ },
275
+ limit: {
276
+ type: 'integer',
277
+ description: 'Maximum number of results to return (default 100)',
278
+ },
279
+ };
280
+ this.requiredArguments = ['query'];
281
+ }
282
+ async execute(ctx, llmArguments) {
283
+ const query = llmArguments.query;
284
+ const limit = llmArguments.limit || 100;
285
+ if (!query) {
286
+ throw new Error('query is required');
287
+ }
288
+ const results = await ctx.client.disks.artifacts.grepArtifacts(ctx.diskId, {
289
+ query,
290
+ limit,
291
+ });
292
+ if (results.length === 0) {
293
+ return `No matches found for pattern '${query}'`;
294
+ }
295
+ const matches = results.map((artifact) => `${artifact.path}${artifact.filename}`);
296
+ return `Found ${matches.length} file(s) matching '${query}':\n` + matches.join('\n');
297
+ }
298
+ }
299
+ exports.GrepArtifactsTool = GrepArtifactsTool;
300
+ class GlobArtifactsTool extends base_1.AbstractBaseTool {
301
+ constructor() {
302
+ super(...arguments);
303
+ this.name = 'glob_artifacts';
304
+ this.description = 'Find files by path pattern using glob syntax. Use * for any characters, ? for single character, ** for recursive directories. Perfect for finding files by extension or location.';
305
+ this.arguments = {
306
+ query: {
307
+ type: 'string',
308
+ description: "Glob pattern (e.g., '**/*.py' for all Python files, '*.txt' for text files in root, '/docs/**/*.md' for markdown in docs)",
309
+ },
310
+ limit: {
311
+ type: 'integer',
312
+ description: 'Maximum number of results to return (default 100)',
313
+ },
314
+ };
315
+ this.requiredArguments = ['query'];
316
+ }
317
+ async execute(ctx, llmArguments) {
318
+ const query = llmArguments.query;
319
+ const limit = llmArguments.limit || 100;
320
+ if (!query) {
321
+ throw new Error('query is required');
322
+ }
323
+ const results = await ctx.client.disks.artifacts.globArtifacts(ctx.diskId, {
324
+ query,
325
+ limit,
326
+ });
327
+ if (results.length === 0) {
328
+ return `No files found matching pattern '${query}'`;
329
+ }
330
+ const matches = results.map((artifact) => `${artifact.path}${artifact.filename}`);
331
+ return `Found ${matches.length} file(s) matching '${query}':\n` + matches.join('\n');
332
+ }
333
+ }
334
+ exports.GlobArtifactsTool = GlobArtifactsTool;
265
335
  class DiskToolPool extends base_1.BaseToolPool {
266
336
  formatContext(client, diskId) {
267
337
  return {
@@ -276,4 +346,6 @@ exports.DISK_TOOLS.addTool(new WriteFileTool());
276
346
  exports.DISK_TOOLS.addTool(new ReadFileTool());
277
347
  exports.DISK_TOOLS.addTool(new ReplaceStringTool());
278
348
  exports.DISK_TOOLS.addTool(new ListTool());
349
+ exports.DISK_TOOLS.addTool(new GrepArtifactsTool());
350
+ exports.DISK_TOOLS.addTool(new GlobArtifactsTool());
279
351
  exports.DISK_TOOLS.addTool(new DownloadFileTool());
@@ -2,15 +2,49 @@
2
2
  * Skill tools for agent operations.
3
3
  */
4
4
  import { AcontextClient } from '../client';
5
+ import { Skill } from '../types';
5
6
  import { AbstractBaseTool, BaseContext, BaseToolPool } from './base';
7
+ /**
8
+ * Context for skill tools with preloaded skill name mapping.
9
+ */
6
10
  export interface SkillContext extends BaseContext {
7
11
  client: AcontextClient;
12
+ skills: Map<string, Skill>;
13
+ }
14
+ /**
15
+ * Create a SkillContext by preloading skills from a list of skill IDs.
16
+ *
17
+ * @param client - The Acontext client instance.
18
+ * @param skillIds - List of skill UUIDs to preload.
19
+ * @returns SkillContext with preloaded skills mapped by name.
20
+ * @throws Error if duplicate skill names are found.
21
+ */
22
+ export declare function createSkillContext(client: AcontextClient, skillIds: string[]): Promise<SkillContext>;
23
+ /**
24
+ * Get a skill by name from the preloaded skills.
25
+ *
26
+ * @param ctx - The skill context.
27
+ * @param skillName - The name of the skill.
28
+ * @returns The Skill object.
29
+ * @throws Error if the skill is not found in the context.
30
+ */
31
+ export declare function getSkillFromContext(ctx: SkillContext, skillName: string): Skill;
32
+ /**
33
+ * Return list of available skill names in this context.
34
+ */
35
+ export declare function listSkillNamesFromContext(ctx: SkillContext): string[];
36
+ export declare class ListSkillsTool extends AbstractBaseTool {
37
+ readonly name = "list_skills";
38
+ readonly description = "List all available skills in the current context with their names and descriptions.";
39
+ readonly arguments: {};
40
+ readonly requiredArguments: string[];
41
+ execute(ctx: SkillContext, _llmArguments: Record<string, unknown>): Promise<string>;
8
42
  }
9
43
  export declare class GetSkillTool extends AbstractBaseTool {
10
44
  readonly name = "get_skill";
11
- readonly description = "Get a skill by its name. Return the skill information including the relative paths of the files and their mime type categories";
45
+ readonly description = "Get a skill by its name. Returns the skill information including the relative paths of the files and their mime type categories.";
12
46
  readonly arguments: {
13
- name: {
47
+ skill_name: {
14
48
  type: string;
15
49
  description: string;
16
50
  };
@@ -20,7 +54,7 @@ export declare class GetSkillTool extends AbstractBaseTool {
20
54
  }
21
55
  export declare class GetSkillFileTool extends AbstractBaseTool {
22
56
  readonly name = "get_skill_file";
23
- readonly description = "Get a file from a skill by name. The file_path should be a relative path within the skill (e.g., 'scripts/extract_text.json'). ";
57
+ readonly description: string;
24
58
  readonly arguments: {
25
59
  skill_name: {
26
60
  type: string;
@@ -39,6 +73,13 @@ export declare class GetSkillFileTool extends AbstractBaseTool {
39
73
  execute(ctx: SkillContext, llmArguments: Record<string, unknown>): Promise<string>;
40
74
  }
41
75
  export declare class SkillToolPool extends BaseToolPool {
42
- formatContext(client: AcontextClient): SkillContext;
76
+ /**
77
+ * Create a SkillContext by preloading skills from a list of skill IDs.
78
+ *
79
+ * @param client - The Acontext client instance.
80
+ * @param skillIds - List of skill UUIDs to preload.
81
+ * @returns Promise resolving to SkillContext with preloaded skills mapped by name.
82
+ */
83
+ formatContext(client: AcontextClient, skillIds: string[]): Promise<SkillContext>;
43
84
  }
44
85
  export declare const SKILL_TOOLS: SkillToolPool;
@@ -3,27 +3,95 @@
3
3
  * Skill tools for agent operations.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SKILL_TOOLS = exports.SkillToolPool = exports.GetSkillFileTool = exports.GetSkillTool = void 0;
6
+ exports.SKILL_TOOLS = exports.SkillToolPool = exports.GetSkillFileTool = exports.GetSkillTool = exports.ListSkillsTool = void 0;
7
+ exports.createSkillContext = createSkillContext;
8
+ exports.getSkillFromContext = getSkillFromContext;
9
+ exports.listSkillNamesFromContext = listSkillNamesFromContext;
7
10
  const base_1 = require("./base");
11
+ /**
12
+ * Create a SkillContext by preloading skills from a list of skill IDs.
13
+ *
14
+ * @param client - The Acontext client instance.
15
+ * @param skillIds - List of skill UUIDs to preload.
16
+ * @returns SkillContext with preloaded skills mapped by name.
17
+ * @throws Error if duplicate skill names are found.
18
+ */
19
+ async function createSkillContext(client, skillIds) {
20
+ const skills = new Map();
21
+ for (const skillId of skillIds) {
22
+ const skill = await client.skills.get(skillId);
23
+ if (skills.has(skill.name)) {
24
+ const existingSkill = skills.get(skill.name);
25
+ throw new Error(`Duplicate skill name '${skill.name}' found. ` +
26
+ `Existing ID: ${existingSkill.id}, New ID: ${skill.id}`);
27
+ }
28
+ skills.set(skill.name, skill);
29
+ }
30
+ return { client, skills };
31
+ }
32
+ /**
33
+ * Get a skill by name from the preloaded skills.
34
+ *
35
+ * @param ctx - The skill context.
36
+ * @param skillName - The name of the skill.
37
+ * @returns The Skill object.
38
+ * @throws Error if the skill is not found in the context.
39
+ */
40
+ function getSkillFromContext(ctx, skillName) {
41
+ const skill = ctx.skills.get(skillName);
42
+ if (!skill) {
43
+ const available = ctx.skills.size > 0 ? Array.from(ctx.skills.keys()).join(', ') : '[none]';
44
+ throw new Error(`Skill '${skillName}' not found in context. Available skills: ${available}`);
45
+ }
46
+ return skill;
47
+ }
48
+ /**
49
+ * Return list of available skill names in this context.
50
+ */
51
+ function listSkillNamesFromContext(ctx) {
52
+ return Array.from(ctx.skills.keys());
53
+ }
54
+ class ListSkillsTool extends base_1.AbstractBaseTool {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.name = 'list_skills';
58
+ this.description = 'List all available skills in the current context with their names and descriptions.';
59
+ this.arguments = {};
60
+ this.requiredArguments = [];
61
+ }
62
+ async execute(ctx,
63
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
+ _llmArguments) {
65
+ if (ctx.skills.size === 0) {
66
+ return 'No skills available in the current context.';
67
+ }
68
+ const skillList = [];
69
+ for (const [skillName, skill] of ctx.skills.entries()) {
70
+ skillList.push(`- ${skillName}: ${skill.description}`);
71
+ }
72
+ return `Available skills (${ctx.skills.size}):\n${skillList.join('\n')}`;
73
+ }
74
+ }
75
+ exports.ListSkillsTool = ListSkillsTool;
8
76
  class GetSkillTool extends base_1.AbstractBaseTool {
9
77
  constructor() {
10
78
  super(...arguments);
11
79
  this.name = 'get_skill';
12
- this.description = 'Get a skill by its name. Return the skill information including the relative paths of the files and their mime type categories';
80
+ this.description = 'Get a skill by its name. Returns the skill information including the relative paths of the files and their mime type categories.';
13
81
  this.arguments = {
14
- name: {
82
+ skill_name: {
15
83
  type: 'string',
16
- description: 'The name of the skill (unique within project).',
84
+ description: 'The name of the skill.',
17
85
  },
18
86
  };
19
- this.requiredArguments = ['name'];
87
+ this.requiredArguments = ['skill_name'];
20
88
  }
21
89
  async execute(ctx, llmArguments) {
22
- const name = llmArguments.name;
23
- if (!name) {
24
- throw new Error('name is required');
90
+ const skillName = llmArguments.skill_name;
91
+ if (!skillName) {
92
+ throw new Error('skill_name is required');
25
93
  }
26
- const skill = await ctx.client.skills.getByName(name);
94
+ const skill = getSkillFromContext(ctx, skillName);
27
95
  const fileCount = skill.file_index.length;
28
96
  // Format all files with path and MIME type
29
97
  let fileList;
@@ -38,9 +106,7 @@ class GetSkillTool extends base_1.AbstractBaseTool {
38
106
  return (`Skill: ${skill.name} (ID: ${skill.id})\n` +
39
107
  `Description: ${skill.description}\n` +
40
108
  `Files: ${fileCount} file(s)\n` +
41
- `${fileList}\n` +
42
- `Created: ${skill.created_at}\n` +
43
- `Updated: ${skill.updated_at}`);
109
+ `${fileList}`);
44
110
  }
45
111
  }
46
112
  exports.GetSkillTool = GetSkillTool;
@@ -48,7 +114,8 @@ class GetSkillFileTool extends base_1.AbstractBaseTool {
48
114
  constructor() {
49
115
  super(...arguments);
50
116
  this.name = 'get_skill_file';
51
- this.description = "Get a file from a skill by name. The file_path should be a relative path within the skill (e.g., 'scripts/extract_text.json'). ";
117
+ this.description = "Get a file from a skill by name. The file_path should be a relative path within the skill (e.g., 'scripts/extract_text.json')." +
118
+ 'Tips: SKILL.md is the first file you should read to understand the full picture of this skill\'s content.';
52
119
  this.arguments = {
53
120
  skill_name: {
54
121
  type: 'string',
@@ -69,14 +136,15 @@ class GetSkillFileTool extends base_1.AbstractBaseTool {
69
136
  const skillName = llmArguments.skill_name;
70
137
  const filePath = llmArguments.file_path;
71
138
  const expire = llmArguments.expire;
72
- if (!filePath) {
73
- throw new Error('file_path is required');
74
- }
75
139
  if (!skillName) {
76
140
  throw new Error('skill_name is required');
77
141
  }
78
- const result = await ctx.client.skills.getFileByName({
79
- skillName,
142
+ if (!filePath) {
143
+ throw new Error('file_path is required');
144
+ }
145
+ const skill = getSkillFromContext(ctx, skillName);
146
+ const result = await ctx.client.skills.getFile({
147
+ skillId: skill.id,
80
148
  filePath,
81
149
  expire: expire || null,
82
150
  });
@@ -100,13 +168,19 @@ class GetSkillFileTool extends base_1.AbstractBaseTool {
100
168
  }
101
169
  exports.GetSkillFileTool = GetSkillFileTool;
102
170
  class SkillToolPool extends base_1.BaseToolPool {
103
- formatContext(client) {
104
- return {
105
- client,
106
- };
171
+ /**
172
+ * Create a SkillContext by preloading skills from a list of skill IDs.
173
+ *
174
+ * @param client - The Acontext client instance.
175
+ * @param skillIds - List of skill UUIDs to preload.
176
+ * @returns Promise resolving to SkillContext with preloaded skills mapped by name.
177
+ */
178
+ async formatContext(client, skillIds) {
179
+ return createSkillContext(client, skillIds);
107
180
  }
108
181
  }
109
182
  exports.SkillToolPool = SkillToolPool;
110
183
  exports.SKILL_TOOLS = new SkillToolPool();
184
+ exports.SKILL_TOOLS.addTool(new ListSkillsTool());
111
185
  exports.SKILL_TOOLS.addTool(new GetSkillTool());
112
186
  exports.SKILL_TOOLS.addTool(new GetSkillFileTool());
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { RequesterProtocol } from '../client-types';
5
5
  import { FileUpload } from '../uploads';
6
- import { Artifact, Disk, GetArtifactResp, ListArtifactsResp, ListDisksOutput, UpdateArtifactResp } from '../types';
6
+ import { Artifact, Artifacts, Disk, GetArtifactResp, ListArtifactsResp, ListDisksOutput, UpdateArtifactResp } from '../types';
7
7
  export declare class DisksAPI {
8
8
  artifacts: DiskArtifactsAPI;
9
9
  private requester;
@@ -46,4 +46,12 @@ export declare class DiskArtifactsAPI {
46
46
  list(diskId: string, options?: {
47
47
  path?: string | null;
48
48
  }): Promise<ListArtifactsResp>;
49
+ grepArtifacts(diskId: string, options: {
50
+ query: string;
51
+ limit?: number;
52
+ }): Promise<Artifacts>;
53
+ globArtifacts(diskId: string, options: {
54
+ query: string;
55
+ limit?: number;
56
+ }): Promise<Artifacts>;
49
57
  }
@@ -102,5 +102,25 @@ class DiskArtifactsAPI {
102
102
  });
103
103
  return types_1.ListArtifactsRespSchema.parse(data);
104
104
  }
105
+ async grepArtifacts(diskId, options) {
106
+ const params = (0, utils_1.buildParams)({
107
+ query: options.query,
108
+ limit: options.limit ?? 100,
109
+ });
110
+ const data = await this.requester.request('GET', `/disk/${diskId}/artifact/grep`, {
111
+ params,
112
+ });
113
+ return types_1.ArtifactsSchema.parse(data);
114
+ }
115
+ async globArtifacts(diskId, options) {
116
+ const params = (0, utils_1.buildParams)({
117
+ query: options.query,
118
+ limit: options.limit ?? 100,
119
+ });
120
+ const data = await this.requester.request('GET', `/disk/${diskId}/artifact/glob`, {
121
+ params,
122
+ });
123
+ return types_1.ArtifactsSchema.parse(data);
124
+ }
105
125
  }
106
126
  exports.DiskArtifactsAPI = DiskArtifactsAPI;
@@ -29,10 +29,28 @@ export declare class SkillsAPI {
29
29
  cursor?: string | null;
30
30
  timeDesc?: boolean | null;
31
31
  }): Promise<ListSkillsOutput>;
32
- getByName(name: string): Promise<Skill>;
32
+ /**
33
+ * Get a skill by its ID.
34
+ *
35
+ * @param skillId - The UUID of the skill
36
+ * @returns Skill containing the full skill information including file_index
37
+ */
38
+ get(skillId: string): Promise<Skill>;
33
39
  delete(skillId: string): Promise<void>;
34
- getFileByName(options: {
35
- skillName: string;
40
+ /**
41
+ * Get a file from a skill by skill ID.
42
+ *
43
+ * The backend automatically returns content for parseable text files, or a presigned URL
44
+ * for non-parseable files (binary, images, etc.).
45
+ *
46
+ * @param options - File retrieval options
47
+ * @param options.skillId - The UUID of the skill
48
+ * @param options.filePath - Relative path to the file within the skill (e.g., 'scripts/extract_text.json')
49
+ * @param options.expire - URL expiration time in seconds (defaults to 900 / 15 minutes)
50
+ * @returns GetSkillFileResp containing the file path, MIME type, and either content or URL
51
+ */
52
+ getFile(options: {
53
+ skillId: string;
36
54
  filePath: string;
37
55
  expire?: number | null;
38
56
  }): Promise<GetSkillFileResp>;
@@ -4,7 +4,6 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SkillsAPI = void 0;
7
- const zod_1 = require("zod");
8
7
  const uploads_1 = require("../uploads");
9
8
  const utils_1 = require("../utils");
10
9
  const types_1 = require("../types");
@@ -42,12 +41,6 @@ class SkillsAPI {
42
41
  * along with pagination information (next_cursor and has_more)
43
42
  */
44
43
  async list_catalog(options) {
45
- // Parse API response (contains full Skill objects)
46
- const apiResponseSchema = zod_1.z.object({
47
- items: zod_1.z.array(types_1.SkillSchema),
48
- next_cursor: zod_1.z.string().nullable().optional(),
49
- has_more: zod_1.z.boolean(),
50
- });
51
44
  // Use 100 as default for catalog listing (only name and description, lightweight)
52
45
  const effectiveLimit = options?.limit ?? 100;
53
46
  const params = (0, utils_1.buildParams)({
@@ -59,29 +52,36 @@ class SkillsAPI {
59
52
  const data = await this.requester.request('GET', '/agent_skills', {
60
53
  params: Object.keys(params).length > 0 ? params : undefined,
61
54
  });
62
- const apiResponse = apiResponseSchema.parse(data);
63
- // Convert to catalog format (name and description only)
64
- return types_1.ListSkillsOutputSchema.parse({
65
- items: apiResponse.items.map((skill) => ({
66
- name: skill.name,
67
- description: skill.description,
68
- })),
69
- next_cursor: apiResponse.next_cursor ?? null,
70
- has_more: apiResponse.has_more,
71
- });
55
+ // Zod strips unknown keys, so ListSkillsOutputSchema extracts only name/description
56
+ return types_1.ListSkillsOutputSchema.parse(data);
72
57
  }
73
- async getByName(name) {
74
- const params = { name };
75
- const data = await this.requester.request('GET', '/agent_skills/by_name', {
76
- params,
77
- });
58
+ /**
59
+ * Get a skill by its ID.
60
+ *
61
+ * @param skillId - The UUID of the skill
62
+ * @returns Skill containing the full skill information including file_index
63
+ */
64
+ async get(skillId) {
65
+ const data = await this.requester.request('GET', `/agent_skills/${skillId}`);
78
66
  return types_1.SkillSchema.parse(data);
79
67
  }
80
68
  async delete(skillId) {
81
69
  await this.requester.request('DELETE', `/agent_skills/${skillId}`);
82
70
  }
83
- async getFileByName(options) {
84
- const endpoint = `/agent_skills/by_name/${options.skillName}/file`;
71
+ /**
72
+ * Get a file from a skill by skill ID.
73
+ *
74
+ * The backend automatically returns content for parseable text files, or a presigned URL
75
+ * for non-parseable files (binary, images, etc.).
76
+ *
77
+ * @param options - File retrieval options
78
+ * @param options.skillId - The UUID of the skill
79
+ * @param options.filePath - Relative path to the file within the skill (e.g., 'scripts/extract_text.json')
80
+ * @param options.expire - URL expiration time in seconds (defaults to 900 / 15 minutes)
81
+ * @returns GetSkillFileResp containing the file path, MIME type, and either content or URL
82
+ */
83
+ async getFile(options) {
84
+ const endpoint = `/agent_skills/${options.skillId}/file`;
85
85
  const params = {
86
86
  file_path: options.filePath,
87
87
  };
@@ -2,9 +2,31 @@
2
2
  * User management endpoints.
3
3
  */
4
4
  import { RequesterProtocol } from '../client-types';
5
+ import { GetUserResourcesOutput, ListUsersOutput } from '../types';
5
6
  export declare class UsersAPI {
6
7
  private requester;
7
8
  constructor(requester: RequesterProtocol);
9
+ /**
10
+ * List all users in the project.
11
+ *
12
+ * @param options - Optional parameters for listing users
13
+ * @param options.limit - Maximum number of users to return. If not provided or 0, all users will be returned.
14
+ * @param options.cursor - Cursor for pagination
15
+ * @param options.timeDesc - Order by created_at descending if true, ascending if false
16
+ * @returns ListUsersOutput containing the list of users and pagination information
17
+ */
18
+ list(options?: {
19
+ limit?: number | null;
20
+ cursor?: string | null;
21
+ timeDesc?: boolean | null;
22
+ }): Promise<ListUsersOutput>;
23
+ /**
24
+ * Get resource counts for a user.
25
+ *
26
+ * @param identifier - The user identifier string
27
+ * @returns GetUserResourcesOutput containing counts for Spaces, Sessions, Disks, and Skills
28
+ */
29
+ getResources(identifier: string): Promise<GetUserResourcesOutput>;
8
30
  /**
9
31
  * Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
10
32
  *
@@ -4,10 +4,42 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.UsersAPI = void 0;
7
+ const utils_1 = require("../utils");
8
+ const types_1 = require("../types");
7
9
  class UsersAPI {
8
10
  constructor(requester) {
9
11
  this.requester = requester;
10
12
  }
13
+ /**
14
+ * List all users in the project.
15
+ *
16
+ * @param options - Optional parameters for listing users
17
+ * @param options.limit - Maximum number of users to return. If not provided or 0, all users will be returned.
18
+ * @param options.cursor - Cursor for pagination
19
+ * @param options.timeDesc - Order by created_at descending if true, ascending if false
20
+ * @returns ListUsersOutput containing the list of users and pagination information
21
+ */
22
+ async list(options) {
23
+ const params = (0, utils_1.buildParams)({
24
+ limit: options?.limit ?? null,
25
+ cursor: options?.cursor ?? null,
26
+ time_desc: options?.timeDesc ?? null,
27
+ });
28
+ const data = await this.requester.request('GET', '/user/ls', {
29
+ params: Object.keys(params).length > 0 ? params : undefined,
30
+ });
31
+ return types_1.ListUsersOutputSchema.parse(data);
32
+ }
33
+ /**
34
+ * Get resource counts for a user.
35
+ *
36
+ * @param identifier - The user identifier string
37
+ * @returns GetUserResourcesOutput containing counts for Spaces, Sessions, Disks, and Skills
38
+ */
39
+ async getResources(identifier) {
40
+ const data = await this.requester.request('GET', `/user/${encodeURIComponent(identifier)}/resources`);
41
+ return types_1.GetUserResourcesOutputSchema.parse(data);
42
+ }
11
43
  /**
12
44
  * Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
13
45
  *
@@ -31,6 +31,15 @@ export declare const ArtifactSchema: z.ZodObject<{
31
31
  updated_at: z.ZodString;
32
32
  }, z.core.$strip>;
33
33
  export type Artifact = z.infer<typeof ArtifactSchema>;
34
+ export declare const ArtifactsSchema: z.ZodArray<z.ZodObject<{
35
+ disk_id: z.ZodString;
36
+ path: z.ZodString;
37
+ filename: z.ZodString;
38
+ meta: z.ZodRecord<z.ZodString, z.ZodUnknown>;
39
+ created_at: z.ZodString;
40
+ updated_at: z.ZodString;
41
+ }, z.core.$strip>>;
42
+ export type Artifacts = z.infer<typeof ArtifactsSchema>;
34
43
  export declare const GetArtifactRespSchema: z.ZodObject<{
35
44
  artifact: z.ZodObject<{
36
45
  disk_id: z.ZodString;
@@ -3,7 +3,7 @@
3
3
  * Type definitions for disk and artifact resources.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UpdateArtifactRespSchema = exports.ListArtifactsRespSchema = exports.GetArtifactRespSchema = exports.ArtifactSchema = exports.ListDisksOutputSchema = exports.DiskSchema = void 0;
6
+ exports.UpdateArtifactRespSchema = exports.ListArtifactsRespSchema = exports.GetArtifactRespSchema = exports.ArtifactsSchema = exports.ArtifactSchema = exports.ListDisksOutputSchema = exports.DiskSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  const common_1 = require("./common");
9
9
  exports.DiskSchema = zod_1.z.object({
@@ -26,13 +26,14 @@ exports.ArtifactSchema = zod_1.z.object({
26
26
  created_at: zod_1.z.string(),
27
27
  updated_at: zod_1.z.string(),
28
28
  });
29
+ exports.ArtifactsSchema = zod_1.z.array(exports.ArtifactSchema);
29
30
  exports.GetArtifactRespSchema = zod_1.z.object({
30
31
  artifact: exports.ArtifactSchema,
31
32
  public_url: zod_1.z.string().nullable().optional(),
32
33
  content: common_1.FileContentSchema.nullable().optional(),
33
34
  });
34
35
  exports.ListArtifactsRespSchema = zod_1.z.object({
35
- artifacts: zod_1.z.array(exports.ArtifactSchema),
36
+ artifacts: exports.ArtifactsSchema,
36
37
  directories: zod_1.z.array(zod_1.z.string()),
37
38
  });
38
39
  exports.UpdateArtifactRespSchema = zod_1.z.object({
@@ -8,3 +8,4 @@ export * from './disk';
8
8
  export * from './block';
9
9
  export * from './tool';
10
10
  export * from './skill';
11
+ export * from './user';
@@ -24,3 +24,4 @@ __exportStar(require("./disk"), exports);
24
24
  __exportStar(require("./block"), exports);
25
25
  __exportStar(require("./tool"), exports);
26
26
  __exportStar(require("./skill"), exports);
27
+ __exportStar(require("./user"), exports);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Type definitions for user resources.
3
+ */
4
+ import { z } from 'zod';
5
+ export declare const UserSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ project_id: z.ZodString;
8
+ identifier: z.ZodString;
9
+ created_at: z.ZodString;
10
+ updated_at: z.ZodString;
11
+ }, z.core.$strip>;
12
+ export type User = z.infer<typeof UserSchema>;
13
+ export declare const ListUsersOutputSchema: z.ZodObject<{
14
+ items: z.ZodArray<z.ZodObject<{
15
+ id: z.ZodString;
16
+ project_id: z.ZodString;
17
+ identifier: z.ZodString;
18
+ created_at: z.ZodString;
19
+ updated_at: z.ZodString;
20
+ }, z.core.$strip>>;
21
+ next_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ has_more: z.ZodBoolean;
23
+ }, z.core.$strip>;
24
+ export type ListUsersOutput = z.infer<typeof ListUsersOutputSchema>;
25
+ export declare const UserResourceCountsSchema: z.ZodObject<{
26
+ spaces_count: z.ZodNumber;
27
+ sessions_count: z.ZodNumber;
28
+ disks_count: z.ZodNumber;
29
+ skills_count: z.ZodNumber;
30
+ }, z.core.$strip>;
31
+ export type UserResourceCounts = z.infer<typeof UserResourceCountsSchema>;
32
+ export declare const GetUserResourcesOutputSchema: z.ZodObject<{
33
+ counts: z.ZodObject<{
34
+ spaces_count: z.ZodNumber;
35
+ sessions_count: z.ZodNumber;
36
+ disks_count: z.ZodNumber;
37
+ skills_count: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>;
40
+ export type GetUserResourcesOutput = z.infer<typeof GetUserResourcesOutputSchema>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for user resources.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GetUserResourcesOutputSchema = exports.UserResourceCountsSchema = exports.ListUsersOutputSchema = exports.UserSchema = void 0;
7
+ const zod_1 = require("zod");
8
+ exports.UserSchema = zod_1.z.object({
9
+ id: zod_1.z.string(),
10
+ project_id: zod_1.z.string(),
11
+ identifier: zod_1.z.string(),
12
+ created_at: zod_1.z.string(),
13
+ updated_at: zod_1.z.string(),
14
+ });
15
+ exports.ListUsersOutputSchema = zod_1.z.object({
16
+ items: zod_1.z.array(exports.UserSchema),
17
+ next_cursor: zod_1.z.string().nullable().optional(),
18
+ has_more: zod_1.z.boolean(),
19
+ });
20
+ exports.UserResourceCountsSchema = zod_1.z.object({
21
+ spaces_count: zod_1.z.number(),
22
+ sessions_count: zod_1.z.number(),
23
+ disks_count: zod_1.z.number(),
24
+ skills_count: zod_1.z.number(),
25
+ });
26
+ exports.GetUserResourcesOutputSchema = zod_1.z.object({
27
+ counts: exports.UserResourceCountsSchema,
28
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acontext/acontext",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "TypeScript SDK for the Acontext API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",