@acontext/acontext 0.0.18 → 0.0.19

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());
@@ -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;
@@ -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.19",
4
4
  "description": "TypeScript SDK for the Acontext API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",