@aigne/core 1.16.0 → 1.18.0
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/CHANGELOG.md +37 -16
- package/lib/cjs/agents/agent.d.ts +69 -37
- package/lib/cjs/agents/agent.js +93 -65
- package/lib/cjs/agents/ai-agent.d.ts +4 -7
- package/lib/cjs/agents/ai-agent.js +10 -19
- package/lib/cjs/agents/chat-model.d.ts +7 -8
- package/lib/cjs/agents/chat-model.js +9 -9
- package/lib/cjs/agents/mcp-agent.d.ts +4 -5
- package/lib/cjs/agents/mcp-agent.js +7 -13
- package/lib/cjs/agents/team-agent.d.ts +7 -8
- package/lib/cjs/agents/team-agent.js +10 -10
- package/lib/cjs/agents/user-agent.d.ts +4 -5
- package/lib/cjs/agents/user-agent.js +11 -12
- package/lib/cjs/aigne/aigne.d.ts +10 -9
- package/lib/cjs/aigne/aigne.js +5 -4
- package/lib/cjs/aigne/context.d.ts +18 -9
- package/lib/cjs/aigne/context.js +23 -12
- package/lib/cjs/aigne/message-queue.d.ts +6 -2
- package/lib/cjs/aigne/message-queue.js +2 -2
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/loader/agent-js.d.ts +1 -1
- package/lib/cjs/loader/agent-yaml.d.ts +3 -2
- package/lib/cjs/loader/agent-yaml.js +3 -2
- package/lib/cjs/loader/index.d.ts +5 -1
- package/lib/cjs/loader/index.js +25 -16
- package/lib/cjs/memory/memory.d.ts +3 -2
- package/lib/cjs/memory/memory.js +1 -1
- package/lib/cjs/memory/retriever.d.ts +2 -2
- package/lib/cjs/prompt/prompt-builder.d.ts +9 -7
- package/lib/cjs/prompt/prompt-builder.js +14 -10
- package/lib/cjs/prompt/template.js +1 -3
- package/lib/cjs/utils/logger.js +3 -3
- package/lib/cjs/utils/nodejs.d.ts +8 -0
- package/lib/cjs/utils/nodejs.js +24 -0
- package/lib/cjs/utils/type-utils.d.ts +2 -2
- package/lib/dts/agents/agent.d.ts +69 -37
- package/lib/dts/agents/ai-agent.d.ts +4 -7
- package/lib/dts/agents/chat-model.d.ts +7 -8
- package/lib/dts/agents/mcp-agent.d.ts +4 -5
- package/lib/dts/agents/team-agent.d.ts +7 -8
- package/lib/dts/agents/user-agent.d.ts +4 -5
- package/lib/dts/aigne/aigne.d.ts +10 -9
- package/lib/dts/aigne/context.d.ts +18 -9
- package/lib/dts/aigne/message-queue.d.ts +6 -2
- package/lib/dts/index.d.ts +3 -1
- package/lib/dts/loader/agent-js.d.ts +1 -1
- package/lib/dts/loader/agent-yaml.d.ts +3 -2
- package/lib/dts/loader/index.d.ts +5 -1
- package/lib/dts/memory/memory.d.ts +3 -2
- package/lib/dts/memory/retriever.d.ts +2 -2
- package/lib/dts/prompt/prompt-builder.d.ts +9 -7
- package/lib/dts/utils/nodejs.d.ts +8 -0
- package/lib/dts/utils/type-utils.d.ts +2 -2
- package/lib/esm/agents/agent.d.ts +69 -37
- package/lib/esm/agents/agent.js +94 -66
- package/lib/esm/agents/ai-agent.d.ts +4 -7
- package/lib/esm/agents/ai-agent.js +10 -19
- package/lib/esm/agents/chat-model.d.ts +7 -8
- package/lib/esm/agents/chat-model.js +9 -9
- package/lib/esm/agents/mcp-agent.d.ts +4 -5
- package/lib/esm/agents/mcp-agent.js +7 -13
- package/lib/esm/agents/team-agent.d.ts +7 -8
- package/lib/esm/agents/team-agent.js +10 -10
- package/lib/esm/agents/user-agent.d.ts +4 -5
- package/lib/esm/agents/user-agent.js +10 -11
- package/lib/esm/aigne/aigne.d.ts +10 -9
- package/lib/esm/aigne/aigne.js +5 -4
- package/lib/esm/aigne/context.d.ts +18 -9
- package/lib/esm/aigne/context.js +24 -10
- package/lib/esm/aigne/message-queue.d.ts +6 -2
- package/lib/esm/aigne/message-queue.js +2 -2
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +3 -1
- package/lib/esm/loader/agent-js.d.ts +1 -1
- package/lib/esm/loader/agent-yaml.d.ts +3 -2
- package/lib/esm/loader/agent-yaml.js +3 -2
- package/lib/esm/loader/index.d.ts +5 -1
- package/lib/esm/loader/index.js +25 -16
- package/lib/esm/memory/memory.d.ts +3 -2
- package/lib/esm/memory/memory.js +2 -2
- package/lib/esm/memory/retriever.d.ts +2 -2
- package/lib/esm/prompt/prompt-builder.d.ts +9 -7
- package/lib/esm/prompt/prompt-builder.js +15 -11
- package/lib/esm/prompt/template.js +1 -3
- package/lib/esm/utils/logger.js +3 -3
- package/lib/esm/utils/nodejs.d.ts +8 -0
- package/lib/esm/utils/nodejs.js +21 -0
- package/lib/esm/utils/type-utils.d.ts +2 -2
- package/package.json +4 -3
- package/lib/cjs/memory/default-memory.d.ts +0 -16
- package/lib/cjs/memory/default-memory.js +0 -70
- package/lib/cjs/utils/fs.d.ts +0 -2
- package/lib/cjs/utils/fs.js +0 -25
- package/lib/dts/memory/default-memory.d.ts +0 -16
- package/lib/dts/utils/fs.d.ts +0 -2
- package/lib/esm/memory/default-memory.d.ts +0 -16
- package/lib/esm/memory/default-memory.js +0 -63
- package/lib/esm/utils/fs.d.ts +0 -2
- package/lib/esm/utils/fs.js +0 -21
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DefaultMemory = exports.DEFAULT_MAX_MEMORY_COUNT = void 0;
|
|
7
|
-
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
8
|
-
const memory_js_1 = require("./memory.js");
|
|
9
|
-
const recorder_js_1 = require("./recorder.js");
|
|
10
|
-
const retriever_js_1 = require("./retriever.js");
|
|
11
|
-
exports.DEFAULT_MAX_MEMORY_COUNT = 10;
|
|
12
|
-
class DefaultMemory extends memory_js_1.MemoryAgent {
|
|
13
|
-
constructor(options = {}) {
|
|
14
|
-
super({
|
|
15
|
-
...options,
|
|
16
|
-
autoUpdate: options.autoUpdate ?? true,
|
|
17
|
-
});
|
|
18
|
-
if (!this.recorder)
|
|
19
|
-
this.recorder = new DefaultMemoryRecorder(this);
|
|
20
|
-
if (!this.retriever)
|
|
21
|
-
this.retriever = new DefaultMemoryRetriever(this);
|
|
22
|
-
}
|
|
23
|
-
storage = [];
|
|
24
|
-
async search(options = {}) {
|
|
25
|
-
const { limit = exports.DEFAULT_MAX_MEMORY_COUNT } = options;
|
|
26
|
-
const result = limit < 0 ? this.storage.slice(limit) : this.storage.slice(0, limit);
|
|
27
|
-
return { result };
|
|
28
|
-
}
|
|
29
|
-
async create(memory) {
|
|
30
|
-
const m = {
|
|
31
|
-
...memory,
|
|
32
|
-
id: (0, memory_js_1.newMemoryId)(),
|
|
33
|
-
createdAt: new Date().toISOString(),
|
|
34
|
-
};
|
|
35
|
-
this.storage.push(m);
|
|
36
|
-
return { result: m };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.DefaultMemory = DefaultMemory;
|
|
40
|
-
class DefaultMemoryRetriever extends retriever_js_1.MemoryRetriever {
|
|
41
|
-
memory;
|
|
42
|
-
constructor(memory) {
|
|
43
|
-
super({});
|
|
44
|
-
this.memory = memory;
|
|
45
|
-
}
|
|
46
|
-
async process(input) {
|
|
47
|
-
const { result } = await this.memory.search(input);
|
|
48
|
-
return { memories: result };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
class DefaultMemoryRecorder extends recorder_js_1.MemoryRecorder {
|
|
52
|
-
memory;
|
|
53
|
-
constructor(memory) {
|
|
54
|
-
super({});
|
|
55
|
-
this.memory = memory;
|
|
56
|
-
}
|
|
57
|
-
async process(input) {
|
|
58
|
-
const newMemories = [];
|
|
59
|
-
for (const content of input.content) {
|
|
60
|
-
const { result: [last], } = await this.memory.search({ limit: -1 });
|
|
61
|
-
if (!(0, fast_deep_equal_1.default)(last?.content, content)) {
|
|
62
|
-
const { result } = await this.memory.create({ content });
|
|
63
|
-
newMemories.push(result);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
memories: newMemories,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
package/lib/cjs/utils/fs.d.ts
DELETED
package/lib/cjs/utils/fs.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exists = exists;
|
|
4
|
-
exports.expandHome = expandHome;
|
|
5
|
-
const promises_1 = require("node:fs/promises");
|
|
6
|
-
const node_os_1 = require("node:os");
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
async function exists(path) {
|
|
9
|
-
try {
|
|
10
|
-
await (0, promises_1.stat)(path);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
if (e.code === "ENOENT") {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
throw e;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function expandHome(filepath) {
|
|
21
|
-
if (filepath.startsWith("~/") || filepath === "~") {
|
|
22
|
-
return (0, node_path_1.join)((0, node_os_1.homedir)(), filepath.slice(1));
|
|
23
|
-
}
|
|
24
|
-
return filepath;
|
|
25
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type Memory, MemoryAgent, type MemoryAgentOptions } from "./memory.js";
|
|
2
|
-
export declare const DEFAULT_MAX_MEMORY_COUNT = 10;
|
|
3
|
-
export interface DefaultMemoryOptions extends Partial<MemoryAgentOptions> {
|
|
4
|
-
}
|
|
5
|
-
export declare class DefaultMemory extends MemoryAgent {
|
|
6
|
-
constructor(options?: DefaultMemoryOptions);
|
|
7
|
-
storage: Memory[];
|
|
8
|
-
search(options?: {
|
|
9
|
-
limit?: number;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
result: Memory[];
|
|
12
|
-
}>;
|
|
13
|
-
create(memory: Pick<Memory, "content">): Promise<{
|
|
14
|
-
result: Memory;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
package/lib/dts/utils/fs.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type Memory, MemoryAgent, type MemoryAgentOptions } from "./memory.js";
|
|
2
|
-
export declare const DEFAULT_MAX_MEMORY_COUNT = 10;
|
|
3
|
-
export interface DefaultMemoryOptions extends Partial<MemoryAgentOptions> {
|
|
4
|
-
}
|
|
5
|
-
export declare class DefaultMemory extends MemoryAgent {
|
|
6
|
-
constructor(options?: DefaultMemoryOptions);
|
|
7
|
-
storage: Memory[];
|
|
8
|
-
search(options?: {
|
|
9
|
-
limit?: number;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
result: Memory[];
|
|
12
|
-
}>;
|
|
13
|
-
create(memory: Pick<Memory, "content">): Promise<{
|
|
14
|
-
result: Memory;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import equal from "fast-deep-equal";
|
|
2
|
-
import { MemoryAgent, newMemoryId } from "./memory.js";
|
|
3
|
-
import { MemoryRecorder } from "./recorder.js";
|
|
4
|
-
import { MemoryRetriever, } from "./retriever.js";
|
|
5
|
-
export const DEFAULT_MAX_MEMORY_COUNT = 10;
|
|
6
|
-
export class DefaultMemory extends MemoryAgent {
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
super({
|
|
9
|
-
...options,
|
|
10
|
-
autoUpdate: options.autoUpdate ?? true,
|
|
11
|
-
});
|
|
12
|
-
if (!this.recorder)
|
|
13
|
-
this.recorder = new DefaultMemoryRecorder(this);
|
|
14
|
-
if (!this.retriever)
|
|
15
|
-
this.retriever = new DefaultMemoryRetriever(this);
|
|
16
|
-
}
|
|
17
|
-
storage = [];
|
|
18
|
-
async search(options = {}) {
|
|
19
|
-
const { limit = DEFAULT_MAX_MEMORY_COUNT } = options;
|
|
20
|
-
const result = limit < 0 ? this.storage.slice(limit) : this.storage.slice(0, limit);
|
|
21
|
-
return { result };
|
|
22
|
-
}
|
|
23
|
-
async create(memory) {
|
|
24
|
-
const m = {
|
|
25
|
-
...memory,
|
|
26
|
-
id: newMemoryId(),
|
|
27
|
-
createdAt: new Date().toISOString(),
|
|
28
|
-
};
|
|
29
|
-
this.storage.push(m);
|
|
30
|
-
return { result: m };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
class DefaultMemoryRetriever extends MemoryRetriever {
|
|
34
|
-
memory;
|
|
35
|
-
constructor(memory) {
|
|
36
|
-
super({});
|
|
37
|
-
this.memory = memory;
|
|
38
|
-
}
|
|
39
|
-
async process(input) {
|
|
40
|
-
const { result } = await this.memory.search(input);
|
|
41
|
-
return { memories: result };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class DefaultMemoryRecorder extends MemoryRecorder {
|
|
45
|
-
memory;
|
|
46
|
-
constructor(memory) {
|
|
47
|
-
super({});
|
|
48
|
-
this.memory = memory;
|
|
49
|
-
}
|
|
50
|
-
async process(input) {
|
|
51
|
-
const newMemories = [];
|
|
52
|
-
for (const content of input.content) {
|
|
53
|
-
const { result: [last], } = await this.memory.search({ limit: -1 });
|
|
54
|
-
if (!equal(last?.content, content)) {
|
|
55
|
-
const { result } = await this.memory.create({ content });
|
|
56
|
-
newMemories.push(result);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
memories: newMemories,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
package/lib/esm/utils/fs.d.ts
DELETED
package/lib/esm/utils/fs.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { stat } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
export async function exists(path) {
|
|
5
|
-
try {
|
|
6
|
-
await stat(path);
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
catch (e) {
|
|
10
|
-
if (e.code === "ENOENT") {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
throw e;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function expandHome(filepath) {
|
|
17
|
-
if (filepath.startsWith("~/") || filepath === "~") {
|
|
18
|
-
return join(homedir(), filepath.slice(1));
|
|
19
|
-
}
|
|
20
|
-
return filepath;
|
|
21
|
-
}
|