@aigne/core 1.71.0 → 1.72.0-beta.1

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/cjs/agents/agent.d.ts +5 -18
  3. package/lib/cjs/agents/agent.js +3 -3
  4. package/lib/cjs/loader/agent-yaml.d.ts +22 -1
  5. package/lib/cjs/loader/agent-yaml.js +18 -0
  6. package/lib/cjs/loader/index.js +26 -1
  7. package/lib/cjs/prompt/context/afs/history.d.ts +5 -0
  8. package/lib/cjs/prompt/context/afs/history.js +32 -0
  9. package/lib/cjs/prompt/context/afs/index.d.ts +20 -0
  10. package/lib/cjs/prompt/context/afs/index.js +48 -0
  11. package/lib/cjs/prompt/context/index.d.ts +31 -0
  12. package/lib/cjs/prompt/context/index.js +18 -0
  13. package/lib/cjs/prompt/prompt-builder.js +10 -39
  14. package/lib/cjs/prompt/skills/afs/edit.d.ts +1 -1
  15. package/lib/cjs/prompt/skills/afs/edit.js +4 -4
  16. package/lib/cjs/prompt/skills/afs/exec.d.ts +1 -1
  17. package/lib/cjs/prompt/skills/afs/exec.js +4 -2
  18. package/lib/cjs/prompt/skills/afs/list.d.ts +1 -2
  19. package/lib/cjs/prompt/skills/afs/list.js +19 -45
  20. package/lib/cjs/prompt/skills/afs/read.d.ts +1 -1
  21. package/lib/cjs/prompt/skills/afs/read.js +4 -4
  22. package/lib/cjs/prompt/skills/afs/search.d.ts +1 -1
  23. package/lib/cjs/prompt/skills/afs/search.js +1 -1
  24. package/lib/dts/agents/agent.d.ts +5 -18
  25. package/lib/dts/loader/agent-yaml.d.ts +22 -1
  26. package/lib/dts/prompt/context/afs/history.d.ts +5 -0
  27. package/lib/dts/prompt/context/afs/index.d.ts +20 -0
  28. package/lib/dts/prompt/context/index.d.ts +31 -0
  29. package/lib/dts/prompt/skills/afs/edit.d.ts +1 -1
  30. package/lib/dts/prompt/skills/afs/exec.d.ts +1 -1
  31. package/lib/dts/prompt/skills/afs/list.d.ts +1 -2
  32. package/lib/dts/prompt/skills/afs/read.d.ts +1 -1
  33. package/lib/dts/prompt/skills/afs/search.d.ts +1 -1
  34. package/lib/esm/agents/agent.d.ts +5 -18
  35. package/lib/esm/agents/agent.js +3 -3
  36. package/lib/esm/loader/agent-yaml.d.ts +22 -1
  37. package/lib/esm/loader/agent-yaml.js +18 -0
  38. package/lib/esm/loader/index.js +26 -1
  39. package/lib/esm/prompt/context/afs/history.d.ts +5 -0
  40. package/lib/esm/prompt/context/afs/history.js +29 -0
  41. package/lib/esm/prompt/context/afs/index.d.ts +20 -0
  42. package/lib/esm/prompt/context/afs/index.js +45 -0
  43. package/lib/esm/prompt/context/index.d.ts +31 -0
  44. package/lib/esm/prompt/context/index.js +15 -0
  45. package/lib/esm/prompt/prompt-builder.js +10 -39
  46. package/lib/esm/prompt/skills/afs/edit.d.ts +1 -1
  47. package/lib/esm/prompt/skills/afs/edit.js +4 -4
  48. package/lib/esm/prompt/skills/afs/exec.d.ts +1 -1
  49. package/lib/esm/prompt/skills/afs/exec.js +4 -2
  50. package/lib/esm/prompt/skills/afs/list.d.ts +1 -2
  51. package/lib/esm/prompt/skills/afs/list.js +19 -45
  52. package/lib/esm/prompt/skills/afs/read.d.ts +1 -1
  53. package/lib/esm/prompt/skills/afs/read.js +4 -4
  54. package/lib/esm/prompt/skills/afs/search.d.ts +1 -1
  55. package/lib/esm/prompt/skills/afs/search.js +1 -1
  56. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.72.0-beta.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.72.0-beta...core-v1.72.0-beta.1) (2025-12-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * bump version ([70d217c](https://github.com/AIGNE-io/aigne-framework/commit/70d217c8360dd0dda7f5f17011c4e92ec836e801))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/afs bumped to 1.4.0-beta.1
16
+ * @aigne/afs-history bumped to 1.2.0-beta.1
17
+ * @aigne/observability-api bumped to 0.11.14-beta
18
+ * @aigne/platform-helpers bumped to 0.6.7-beta
19
+
20
+ ## [1.72.0-beta](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.71.0...core-v1.72.0-beta) (2025-12-17)
21
+
22
+
23
+ ### Features
24
+
25
+ * **afs:** support expand context into prompt template by call `$afs.xxx` ([#830](https://github.com/AIGNE-io/aigne-framework/issues/830)) ([5616acd](https://github.com/AIGNE-io/aigne-framework/commit/5616acd6ea257c91aa0b766608f45c5ce17f0345))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @aigne/afs bumped to 1.4.0-beta
33
+ * @aigne/afs-history bumped to 1.2.0-beta
34
+
3
35
  ## [1.71.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.71.0-beta.6...core-v1.71.0) (2025-12-12)
4
36
 
5
37
 
@@ -1,4 +1,4 @@
1
- import { AFS, type AFSEntry, type AFSListOptions, type AFSModule, type AFSOptions, type AFSSearchOptions } from "@aigne/afs";
1
+ import { AFS, type AFSExecOptions, type AFSExecResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSOptions, type AFSReadResult, type AFSSearchOptions } from "@aigne/afs";
2
2
  import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
3
3
  import type * as prompts from "@inquirer/prompts";
4
4
  import { type ZodObject, type ZodType } from "zod";
@@ -573,23 +573,10 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
573
573
  /** For AFSModule interface **/
574
574
  private agentToAFSEntry;
575
575
  private findAgentByAFSPath;
576
- list(_path: string, _options?: AFSListOptions): Promise<{
577
- list: AFSEntry[];
578
- message?: string;
579
- }>;
580
- read(path: string): Promise<{
581
- result?: AFSEntry;
582
- message?: string;
583
- }>;
584
- search(path: string, _query: string, options?: AFSSearchOptions): Promise<{
585
- list: AFSEntry[];
586
- message?: string;
587
- }>;
588
- exec(path: string, args: Record<string, any>, options: {
589
- context: Context;
590
- }): Promise<{
591
- result: Record<string, any>;
592
- }>;
576
+ list(_path: string, _options?: AFSListOptions): Promise<AFSListResult>;
577
+ read(path: string): Promise<AFSReadResult>;
578
+ search(path: string, _query: string, options?: AFSSearchOptions): Promise<AFSListResult>;
579
+ exec(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
593
580
  }
594
581
  export type AgentInput<T extends Agent> = T extends Agent<infer I, any> ? I : never;
595
582
  export type AgentOutput<T extends Agent> = T extends Agent<any, infer O> ? O : never;
@@ -781,7 +781,7 @@ class Agent {
781
781
  // TODO: support list skills inside agent path, and use options to filter skills
782
782
  async list(_path, _options) {
783
783
  const agents = [this, ...this.skills];
784
- return { list: agents.map((agent) => this.agentToAFSEntry(agent)) };
784
+ return { data: agents.map((agent) => this.agentToAFSEntry(agent)) };
785
785
  }
786
786
  async read(path) {
787
787
  const agent = this.findAgentByAFSPath(path);
@@ -789,7 +789,7 @@ class Agent {
789
789
  return { message: `Agent not found at path: ${path}` };
790
790
  }
791
791
  return {
792
- result: this.agentToAFSEntry(agent),
792
+ data: this.agentToAFSEntry(agent),
793
793
  };
794
794
  }
795
795
  // TODO: implement search inside agent skills
@@ -800,7 +800,7 @@ class Agent {
800
800
  const agent = this.findAgentByAFSPath(path);
801
801
  if (!agent)
802
802
  throw new Error(`Agent not found at path: ${path}`);
803
- return { result: await options.context.invoke(agent, args) };
803
+ return { data: await options.context.invoke(agent, args) };
804
804
  }
805
805
  }
806
806
  exports.Agent = Agent;
@@ -25,6 +25,26 @@ export type AFSModuleSchema = string | {
25
25
  module: string;
26
26
  options?: Record<string, any>;
27
27
  };
28
+ export interface AFSContextPresetSchema {
29
+ view?: string;
30
+ select?: {
31
+ agent: NestAgentSchema;
32
+ };
33
+ per?: {
34
+ agent: NestAgentSchema;
35
+ };
36
+ dedupe?: {
37
+ agent: NestAgentSchema;
38
+ };
39
+ }
40
+ export interface AFSContextSchema {
41
+ search?: {
42
+ presets?: Record<string, AFSContextPresetSchema>;
43
+ };
44
+ list?: {
45
+ presets?: Record<string, AFSContextPresetSchema>;
46
+ };
47
+ }
28
48
  export interface BaseAgentSchema {
29
49
  name?: string;
30
50
  description?: string;
@@ -42,8 +62,9 @@ export interface BaseAgentSchema {
42
62
  provider: string;
43
63
  subscribeTopic?: string[];
44
64
  };
45
- afs?: boolean | (Omit<AFSOptions, "modules"> & {
65
+ afs?: boolean | (Omit<AFSOptions, "modules" | "context"> & {
46
66
  modules?: AFSModuleSchema[];
67
+ context?: AFSContextSchema;
47
68
  });
48
69
  shareAFS?: boolean;
49
70
  }
@@ -86,6 +86,20 @@ const getAgentSchema = ({ filepath, options, }) => {
86
86
  onSkillEnd: (0, schema_js_1.optionalize)(nestAgentSchema),
87
87
  onHandoff: (0, schema_js_1.optionalize)(nestAgentSchema),
88
88
  }));
89
+ const afsContextPresetsSchema = zod_1.z.object({
90
+ presets: (0, schema_js_1.optionalize)(zod_1.z.record(zod_1.z.string(), zod_1.z.object({
91
+ view: (0, schema_js_1.optionalize)(zod_1.z.string()),
92
+ select: (0, schema_js_1.optionalize)(zod_1.z.object({
93
+ agent: nestAgentSchema,
94
+ })),
95
+ per: (0, schema_js_1.optionalize)(zod_1.z.object({
96
+ agent: nestAgentSchema,
97
+ })),
98
+ dedupe: (0, schema_js_1.optionalize)(zod_1.z.object({
99
+ agent: nestAgentSchema,
100
+ })),
101
+ }))),
102
+ });
89
103
  const baseAgentSchema = zod_1.z.object({
90
104
  name: (0, schema_js_1.optionalize)(zod_1.z.string()),
91
105
  alias: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
@@ -117,6 +131,10 @@ const getAgentSchema = ({ filepath, options, }) => {
117
131
  options: (0, schema_js_1.optionalize)(zod_1.z.record(zod_1.z.any())),
118
132
  })),
119
133
  ]))),
134
+ context: (0, schema_js_1.optionalize)(zod_1.z.object({
135
+ search: (0, schema_js_1.optionalize)(afsContextPresetsSchema),
136
+ list: (0, schema_js_1.optionalize)(afsContextPresetsSchema),
137
+ })),
120
138
  })),
121
139
  ])),
122
140
  shareAFS: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
@@ -132,7 +132,32 @@ async function parseAgent(path, agent, options, agentOptions) {
132
132
  afs = new afs_1.AFS();
133
133
  }
134
134
  else if (agent.afs) {
135
- afs = new afs_1.AFS();
135
+ afs = new afs_1.AFS({});
136
+ const loadAFSContextPresets = async (presets) => {
137
+ return Object.fromEntries(await Promise.all(Object.entries(presets).map(async ([key, value]) => {
138
+ const [select, per, dedupe] = await Promise.all([value.select, value.per, value.dedupe].map(async (item) => {
139
+ if (!item?.agent)
140
+ return undefined;
141
+ const agent = await loadNestAgent(path, item.agent, options, { afs });
142
+ return {
143
+ invoke: (input, options) => options.context.invoke(agent, input, {
144
+ ...options,
145
+ streaming: false,
146
+ }),
147
+ };
148
+ }));
149
+ return [key, { ...value, select, per, dedupe }];
150
+ })));
151
+ };
152
+ const context = {
153
+ search: {
154
+ presets: await loadAFSContextPresets(agent.afs.context?.search?.presets || {}),
155
+ },
156
+ list: {
157
+ presets: await loadAFSContextPresets(agent.afs.context?.list?.presets || {}),
158
+ },
159
+ };
160
+ afs.options.context = context;
136
161
  for (const m of agent.afs.modules || []) {
137
162
  const moduleName = typeof m === "string" ? m : m.module;
138
163
  const mod = options?.afs?.availableModules?.find((mod) => mod.module === moduleName || mod.alias?.includes(moduleName));
@@ -0,0 +1,5 @@
1
+ import type { Agent } from "../../../agents/agent.js";
2
+ export declare function getHistories(agent: Agent): Promise<{
3
+ role: "user" | "agent";
4
+ content: unknown;
5
+ }[]>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHistories = getHistories;
4
+ const afs_history_1 = require("@aigne/afs-history");
5
+ const type_utils_js_1 = require("../../../utils/type-utils.js");
6
+ async function getHistories(agent) {
7
+ const afs = agent?.afs;
8
+ if (!afs)
9
+ return [];
10
+ const historyModule = (await afs.listModules()).find((m) => m.module instanceof afs_history_1.AFSHistory);
11
+ if (!historyModule)
12
+ return [];
13
+ const history = (await afs.list(historyModule.path, {
14
+ limit: agent.historyConfig?.maxItems || 10,
15
+ orderBy: [["createdAt", "desc"]],
16
+ })).data;
17
+ return history
18
+ .reverse()
19
+ .map((i) => {
20
+ if (!i.content)
21
+ return;
22
+ const { input, output } = i.content;
23
+ if (!input || !output)
24
+ return;
25
+ return [
26
+ { role: "user", content: input },
27
+ { role: "agent", content: output },
28
+ ];
29
+ })
30
+ .filter(type_utils_js_1.isNonNullable)
31
+ .flat();
32
+ }
@@ -0,0 +1,20 @@
1
+ import type { AFSRootListOptions, AFSRootSearchOptions } from "@aigne/afs";
2
+ import type { Agent, AgentInvokeOptions } from "../../../agents/agent.js";
3
+ export declare function createAFSContext(agent?: Agent<any, any>, context?: AgentInvokeOptions["context"]): {
4
+ readonly enabled: boolean;
5
+ description: string;
6
+ readonly modules: Promise<Pick<{
7
+ name: string;
8
+ path: string;
9
+ description?: string;
10
+ module: import("@aigne/afs").AFSModule;
11
+ }, "path" | "name" | "description">[]> | undefined;
12
+ readonly histories: Promise<{
13
+ role: "user" | "agent";
14
+ content: unknown;
15
+ }[]>;
16
+ readonly skills: never[] | Promise<Pick<Agent<any, any>, "name" | "description">[]>;
17
+ list(path: string, options?: AFSRootListOptions): Promise<any>;
18
+ read(path: string): Promise<import("@aigne/afs").AFSEntry<any> | undefined>;
19
+ search(path: string, query: string, options?: AFSRootSearchOptions): Promise<any>;
20
+ };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAFSContext = createAFSContext;
4
+ const type_utils_js_1 = require("../../../utils/type-utils.js");
5
+ const afs_builtin_prompt_js_1 = require("../../prompts/afs-builtin-prompt.js");
6
+ const index_js_1 = require("../../skills/afs/index.js");
7
+ const history_js_1 = require("./history.js");
8
+ function createAFSContext(agent, context) {
9
+ const afs = agent?.afs;
10
+ return {
11
+ get enabled() {
12
+ return !!afs;
13
+ },
14
+ description: afs_builtin_prompt_js_1.AFS_DESCRIPTION_PROMPT_TEMPLATE,
15
+ get modules() {
16
+ return afs
17
+ ?.listModules()
18
+ .then((list) => list.map((i) => (0, type_utils_js_1.pick)(i, ["name", "path", "description"])));
19
+ },
20
+ get histories() {
21
+ if (!agent)
22
+ return Promise.resolve([]);
23
+ return (0, history_js_1.getHistories)(agent);
24
+ },
25
+ get skills() {
26
+ const afs = agent?.afs;
27
+ if (!afs)
28
+ return [];
29
+ return (0, index_js_1.getAFSSkills)(afs).then((skills) => skills.map((s) => (0, type_utils_js_1.pick)(s, ["name", "description"])));
30
+ },
31
+ async list(path, options) {
32
+ if (!afs)
33
+ throw new Error("AFS is not configured for this agent.");
34
+ return (await afs.list(path, { ...options, context, format: options?.format || "tree" }))
35
+ .data;
36
+ },
37
+ async read(path) {
38
+ if (!afs)
39
+ throw new Error("AFS is not configured for this agent.");
40
+ return (await afs.read(path)).data;
41
+ },
42
+ async search(path, query, options = {}) {
43
+ if (!afs)
44
+ throw new Error("AFS is not configured for this agent.");
45
+ return (await afs.search(path, query, { ...options, context })).data;
46
+ },
47
+ };
48
+ }
@@ -0,0 +1,31 @@
1
+ import type { PromptBuildOptions } from "../prompt-builder.js";
2
+ export declare function createPromptBuilderContext(options: PromptBuildOptions): {
3
+ $afs: {
4
+ readonly enabled: boolean;
5
+ description: string;
6
+ readonly modules: Promise<Pick<{
7
+ name: string;
8
+ path: string;
9
+ description?: string;
10
+ module: import("@aigne/afs/.").AFSModule;
11
+ }, "path" | "name" | "description">[]> | undefined;
12
+ readonly histories: Promise<{
13
+ role: "user" | "agent";
14
+ content: unknown;
15
+ }[]>;
16
+ readonly skills: never[] | Promise<Pick<import("../../index.js").Agent<any, any>, "name" | "description">[]>;
17
+ list(path: string, options?: import("@aigne/afs/.").AFSRootListOptions): Promise<any>;
18
+ read(path: string): Promise<import("@aigne/afs/.").AFSEntry<any> | undefined>;
19
+ search(path: string, query: string, options?: import("@aigne/afs/.").AFSRootSearchOptions): Promise<any>;
20
+ };
21
+ $agent: {
22
+ readonly skills: Pick<import("../../index.js").Agent<any, any>, "name" | "description">[] | undefined;
23
+ };
24
+ $meta?: {
25
+ usage?: import("../../index.js").ContextUsage;
26
+ [key: string]: unknown;
27
+ };
28
+ userId?: string;
29
+ sessionId?: string;
30
+ userContext: import("../../index.js").UserContext | undefined;
31
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPromptBuilderContext = createPromptBuilderContext;
4
+ const type_utils_js_1 = require("../../utils/type-utils.js");
5
+ const index_js_1 = require("./afs/index.js");
6
+ function createPromptBuilderContext(options) {
7
+ return {
8
+ userContext: options.context?.userContext,
9
+ ...options.context?.userContext,
10
+ ...options.input,
11
+ $afs: (0, index_js_1.createAFSContext)(options.agent, options.context),
12
+ $agent: {
13
+ get skills() {
14
+ return options.agent?.skills.map((s) => (0, type_utils_js_1.pick)(s, ["name", "description"]));
15
+ },
16
+ },
17
+ };
18
+ }
@@ -12,10 +12,11 @@ const model_js_1 = require("../agents/model.js");
12
12
  const schema_js_1 = require("../loader/schema.js");
13
13
  const json_schema_js_1 = require("../utils/json-schema.js");
14
14
  const type_utils_js_1 = require("../utils/type-utils.js");
15
+ const index_js_2 = require("./context/index.js");
15
16
  const afs_builtin_prompt_js_1 = require("./prompts/afs-builtin-prompt.js");
16
17
  const memory_message_template_js_1 = require("./prompts/memory-message-template.js");
17
18
  const structured_stream_instructions_js_1 = require("./prompts/structured-stream-instructions.js");
18
- const index_js_2 = require("./skills/afs/index.js");
19
+ const index_js_3 = require("./skills/afs/index.js");
19
20
  const template_js_1 = require("./template.js");
20
21
  class PromptBuilder {
21
22
  static from(instructions, { workingDir } = {}) {
@@ -95,37 +96,7 @@ class PromptBuilder {
95
96
  };
96
97
  }
97
98
  getTemplateVariables(options) {
98
- const self = this;
99
- return {
100
- userContext: options.context?.userContext,
101
- ...options.context?.userContext,
102
- ...options.input,
103
- $afs: {
104
- get enabled() {
105
- return !!options.agent?.afs;
106
- },
107
- description: afs_builtin_prompt_js_1.AFS_DESCRIPTION_PROMPT_TEMPLATE,
108
- get modules() {
109
- return options.agent?.afs
110
- ?.listModules()
111
- .then((list) => list.map((i) => (0, type_utils_js_1.pick)(i, ["name", "path", "description"])));
112
- },
113
- get histories() {
114
- return self.getHistories(options);
115
- },
116
- get skills() {
117
- const afs = options.agent?.afs;
118
- if (!afs)
119
- return [];
120
- return (0, index_js_2.getAFSSkills)(afs).then((skills) => skills.map((s) => (0, type_utils_js_1.pick)(s, ["name", "description"])));
121
- },
122
- },
123
- $agent: {
124
- get skills() {
125
- return options.agent?.skills.map((s) => (0, type_utils_js_1.pick)(s, ["name", "description"]));
126
- },
127
- },
128
- };
99
+ return (0, index_js_2.createPromptBuilderContext)(options);
129
100
  }
130
101
  async buildMessages(options) {
131
102
  const { input } = options;
@@ -154,12 +125,12 @@ class PromptBuilder {
154
125
  limit: options.agent?.maxRetrieveMemoryCount || 10,
155
126
  orderBy: [["createdAt", "desc"]],
156
127
  });
157
- memories.push(...history.list
128
+ memories.push(...history.data
158
129
  .reverse()
159
130
  .filter((i) => (0, type_utils_js_1.isNonNullable)(i.content)));
160
131
  if (message) {
161
- const result = await afs.search("/", message);
162
- const ms = result.list
132
+ const result = (await afs.search("/", message)).data;
133
+ const ms = result
163
134
  .map((entry) => {
164
135
  if (entry.metadata?.execute)
165
136
  return null;
@@ -173,7 +144,7 @@ class PromptBuilder {
173
144
  })
174
145
  .filter(type_utils_js_1.isNonNullable);
175
146
  memories.push(...ms);
176
- const executable = result.list.filter((i) => !!i.metadata?.execute);
147
+ const executable = result.filter((i) => !!i.metadata?.execute);
177
148
  if (executable.length) {
178
149
  messages.push({
179
150
  role: "system",
@@ -232,10 +203,10 @@ class PromptBuilder {
232
203
  const historyModule = (await afs.listModules()).find((m) => m.module instanceof afs_history_1.AFSHistory);
233
204
  if (!historyModule)
234
205
  return [];
235
- const { list: history } = await afs.list(historyModule.path, {
206
+ const history = (await afs.list(historyModule.path, {
236
207
  limit: agent.historyConfig?.maxItems || 10,
237
208
  orderBy: [["createdAt", "desc"]],
238
- });
209
+ })).data;
239
210
  return history
240
211
  .reverse()
241
212
  .map((i) => {
@@ -364,7 +335,7 @@ class PromptBuilder {
364
335
  .concat(options.agent?.memoryAgentsAsTools ? options.agent.memories : [])
365
336
  .flatMap((i) => (i.isInvokable ? i : i.skills)), (i) => i.name);
366
337
  if (options.agent?.afs) {
367
- toolAgents.push(...(await (0, index_js_2.getAFSSkills)(options.agent.afs)));
338
+ toolAgents.push(...(await (0, index_js_3.getAFSSkills)(options.agent.afs)));
368
339
  }
369
340
  const tools = toolAgents.map((i) => ({
370
341
  type: "function",
@@ -14,7 +14,7 @@ export interface AFSEditOutput extends Message {
14
14
  tool: string;
15
15
  path: string;
16
16
  message: string;
17
- content: string;
17
+ data: string;
18
18
  }
19
19
  export interface AFSEditAgentOptions extends AgentOptions<AFSEditInput, AFSEditOutput> {
20
20
  afs: NonNullable<AgentOptions<AFSEditInput, AFSEditOutput>["afs"]>;
@@ -26,7 +26,7 @@ class AFSEditAgent extends agent_js_1.Agent {
26
26
  tool: zod_1.z.string(),
27
27
  path: zod_1.z.string(),
28
28
  message: zod_1.z.string(),
29
- content: zod_1.z.string(),
29
+ data: zod_1.z.string(),
30
30
  }),
31
31
  });
32
32
  }
@@ -37,10 +37,10 @@ class AFSEditAgent extends agent_js_1.Agent {
37
37
  throw new Error("No patches provided for afs_edit.");
38
38
  }
39
39
  const readResult = await this.afs.read(input.path);
40
- if (!readResult.result?.content || typeof readResult.result.content !== "string") {
40
+ if (!readResult.data?.content || typeof readResult.data.content !== "string") {
41
41
  throw new Error(`Cannot read file content from: ${input.path}`);
42
42
  }
43
- const originalContent = readResult.result.content;
43
+ const originalContent = readResult.data.content;
44
44
  const updatedContent = this.applyCustomPatches(originalContent, input.patches);
45
45
  await this.afs.write(input.path, {
46
46
  content: updatedContent,
@@ -50,7 +50,7 @@ class AFSEditAgent extends agent_js_1.Agent {
50
50
  tool: "afs_edit",
51
51
  path: input.path,
52
52
  message: `Applied ${input.patches.length} patches to ${input.path}`,
53
- content: updatedContent,
53
+ data: updatedContent,
54
54
  };
55
55
  }
56
56
  applyCustomPatches(text, patches) {
@@ -4,7 +4,7 @@ export interface AFSExecInput extends Message {
4
4
  args: string;
5
5
  }
6
6
  export interface AFSExecOutput extends Message {
7
- result: Record<string, any>;
7
+ data: Record<string, any>;
8
8
  }
9
9
  export interface AFSExecAgentOptions extends AgentOptions<AFSExecInput, AFSExecOutput> {
10
10
  afs: NonNullable<AgentOptions<AFSExecInput, AFSExecOutput>["afs"]>;
@@ -14,14 +14,16 @@ class AFSExecAgent extends agent_js_1.Agent {
14
14
  args: zod_1.z.string().describe("JSON string of arguments matching the function's input schema"),
15
15
  }),
16
16
  outputSchema: zod_1.z.object({
17
- result: zod_1.z.record(zod_1.z.any()),
17
+ data: zod_1.z.record(zod_1.z.any()),
18
18
  }),
19
19
  });
20
20
  }
21
21
  async process(input, options) {
22
22
  if (!this.afs)
23
23
  throw new Error("AFS is not configured for this agent.");
24
- return await this.afs.exec(input.path, JSON.parse(input.args), options);
24
+ return {
25
+ ...(await this.afs.exec(input.path, JSON.parse(input.args), options)),
26
+ };
25
27
  }
26
28
  }
27
29
  exports.AFSExecAgent = AFSExecAgent;
@@ -10,7 +10,7 @@ export interface AFSListOutput extends Message {
10
10
  path: string;
11
11
  options?: AFSListOptions;
12
12
  message?: string;
13
- result: string;
13
+ data?: unknown;
14
14
  }
15
15
  export interface AFSListAgentOptions extends AgentOptions<AFSListInput, AFSListOutput> {
16
16
  afs: NonNullable<AgentOptions<AFSListInput, AFSListOutput>["afs"]>;
@@ -18,5 +18,4 @@ export interface AFSListAgentOptions extends AgentOptions<AFSListInput, AFSListO
18
18
  export declare class AFSListAgent extends Agent<AFSListInput, AFSListOutput> {
19
19
  constructor(options: AFSListAgentOptions);
20
20
  process(input: AFSListInput, _options: AgentInvokeOptions): Promise<AFSListOutput>;
21
- private buildTreeView;
22
21
  }
@@ -14,6 +14,19 @@ class AFSListAgent extends agent_js_1.Agent {
14
14
  options: zod_1.z
15
15
  .object({
16
16
  maxDepth: zod_1.z.number().optional().describe("Tree depth limit (default: 1)"),
17
+ disableGitignore: zod_1.z
18
+ .boolean()
19
+ .optional()
20
+ .describe("Disable .gitignore filtering, default is enabled"),
21
+ maxChildren: zod_1.z
22
+ .number()
23
+ .optional()
24
+ .describe("Maximum number of children to list per directory"),
25
+ format: zod_1.z
26
+ .union([zod_1.z.literal("tree"), zod_1.z.literal("list")])
27
+ .optional()
28
+ .default("tree")
29
+ .describe("Output format, either 'tree' or 'list' (default: 'tree')"),
17
30
  })
18
31
  .optional(),
19
32
  }),
@@ -24,67 +37,28 @@ class AFSListAgent extends agent_js_1.Agent {
24
37
  options: zod_1.z
25
38
  .object({
26
39
  maxDepth: zod_1.z.number().optional(),
40
+ disableGitignore: zod_1.z.boolean().optional(),
41
+ maxChildren: zod_1.z.number().optional(),
42
+ format: zod_1.z.union([zod_1.z.literal("tree"), zod_1.z.literal("list")]).optional(),
27
43
  })
28
44
  .optional(),
29
45
  message: zod_1.z.string().optional(),
30
- result: zod_1.z.string(),
46
+ data: zod_1.z.unknown(),
31
47
  }),
32
48
  });
33
49
  }
34
50
  async process(input, _options) {
35
51
  if (!this.afs)
36
52
  throw new Error("AFS is not configured for this agent.");
37
- const { list, message } = await this.afs.list(input.path, input.options);
38
- const result = this.buildTreeView(list);
53
+ const { data, message } = await this.afs.list(input.path, input.options);
39
54
  return {
40
55
  status: "success",
41
56
  tool: "afs_list",
42
57
  path: input.path,
43
58
  options: input.options,
44
59
  message,
45
- result,
60
+ data,
46
61
  };
47
62
  }
48
- buildTreeView(entries) {
49
- const tree = {};
50
- const entryMap = new Map();
51
- for (const entry of entries) {
52
- entryMap.set(entry.path, entry);
53
- const parts = entry.path.split("/").filter(Boolean);
54
- let current = tree;
55
- for (const part of parts) {
56
- if (!current[part]) {
57
- current[part] = {};
58
- }
59
- current = current[part];
60
- }
61
- }
62
- const renderTree = (node, prefix = "", currentPath = "") => {
63
- let result = "";
64
- const keys = Object.keys(node);
65
- keys.forEach((key, index) => {
66
- const isLast = index === keys.length - 1;
67
- const fullPath = currentPath ? `${currentPath}/${key}` : `/${key}`;
68
- const entry = entryMap.get(fullPath);
69
- // Build metadata suffix
70
- const metadataParts = [];
71
- // Children count
72
- const childrenCount = entry?.metadata?.childrenCount;
73
- if (childrenCount !== undefined && childrenCount > 0) {
74
- metadataParts.push(`${childrenCount} items`);
75
- }
76
- // Executable
77
- if (entry?.metadata?.execute) {
78
- metadataParts.push("executable");
79
- }
80
- const metadataSuffix = metadataParts.length > 0 ? ` [${metadataParts.join(", ")}]` : "";
81
- result += `${prefix}${isLast ? "└── " : "├── "}${key}${metadataSuffix}`;
82
- result += `\n`;
83
- result += renderTree(node[key], `${prefix}${isLast ? " " : "│ "}`, fullPath);
84
- });
85
- return result;
86
- };
87
- return renderTree(tree);
88
- }
89
63
  }
90
64
  exports.AFSListAgent = AFSListAgent;
@@ -9,7 +9,7 @@ export interface AFSReadOutput extends Message {
9
9
  tool: string;
10
10
  path: string;
11
11
  withLineNumbers?: boolean;
12
- result?: AFSEntry;
12
+ data?: AFSEntry;
13
13
  message?: string;
14
14
  }
15
15
  export interface AFSReadAgentOptions extends AgentOptions<AFSReadInput, AFSReadOutput> {