@aigne/core 1.23.0 → 1.23.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.
- package/CHANGELOG.md +7 -0
- package/lib/cjs/agents/agent.js +1 -7
- package/lib/cjs/memory/memory.js +1 -1
- package/lib/cjs/memory/recorder.d.ts +2 -6
- package/lib/cjs/memory/recorder.js +2 -2
- package/lib/cjs/memory/retriever.d.ts +4 -4
- package/lib/cjs/memory/retriever.js +1 -1
- package/lib/cjs/utils/type-utils.d.ts +1 -0
- package/lib/cjs/utils/type-utils.js +5 -0
- package/lib/dts/memory/recorder.d.ts +2 -6
- package/lib/dts/memory/retriever.d.ts +4 -4
- package/lib/dts/utils/type-utils.d.ts +1 -0
- package/lib/esm/agents/agent.js +1 -7
- package/lib/esm/memory/memory.js +1 -1
- package/lib/esm/memory/recorder.d.ts +2 -6
- package/lib/esm/memory/recorder.js +2 -2
- package/lib/esm/memory/retriever.d.ts +4 -4
- package/lib/esm/memory/retriever.js +1 -1
- package/lib/esm/utils/type-utils.d.ts +1 -0
- package/lib/esm/utils/type-utils.js +4 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* dependencies
|
|
13
13
|
* @aigne/observability bumped to 0.1.0
|
|
14
14
|
|
|
15
|
+
## [1.23.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.23.0...core-v1.23.1) (2025-06-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **core:** pass input/output to MemoryAgent directily ([#178](https://github.com/AIGNE-io/aigne-framework/issues/178)) ([3b20e33](https://github.com/AIGNE-io/aigne-framework/commit/3b20e33f1eefc81ac1e009b1afff14fca46644b1))
|
|
21
|
+
|
|
15
22
|
## [1.23.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.22.0...core-v1.23.0) (2025-06-25)
|
|
16
23
|
|
|
17
24
|
|
package/lib/cjs/agents/agent.js
CHANGED
|
@@ -317,7 +317,6 @@ class Agent {
|
|
|
317
317
|
for (const memory of this.memories) {
|
|
318
318
|
const ms = (await memory.retrieve({
|
|
319
319
|
...input,
|
|
320
|
-
search: typeof input.search === "string" ? input.search : JSON.stringify(input.search),
|
|
321
320
|
limit: input.limit ?? this.maxRetrieveMemoryCount,
|
|
322
321
|
}, options.context)).memories;
|
|
323
322
|
memories.push(...ms);
|
|
@@ -521,12 +520,7 @@ class Agent {
|
|
|
521
520
|
async postprocess(input, output, options) {
|
|
522
521
|
this.checkContextStatus(options);
|
|
523
522
|
this.publishToTopics(output, options);
|
|
524
|
-
await this.recordMemories({
|
|
525
|
-
content: [
|
|
526
|
-
{ role: "user", content: input },
|
|
527
|
-
{ role: "agent", content: (0, types_js_1.replaceTransferAgentToName)(output), source: this.name },
|
|
528
|
-
],
|
|
529
|
-
}, options);
|
|
523
|
+
await this.recordMemories({ content: [{ input, output: (0, types_js_1.replaceTransferAgentToName)(output), source: this.name }] }, options);
|
|
530
524
|
}
|
|
531
525
|
async publishToTopics(output, options) {
|
|
532
526
|
const publishTopics = typeof this.publishTopic === "function" ? await this.publishTopic(output) : this.publishTopic;
|
package/lib/cjs/memory/memory.js
CHANGED
|
@@ -134,7 +134,7 @@ class MemoryAgent extends agent_js_1.Agent {
|
|
|
134
134
|
return context.invoke(this.recorder, input);
|
|
135
135
|
}
|
|
136
136
|
async onMessage({ role, source, message, context }) {
|
|
137
|
-
this.record({ content: [{
|
|
137
|
+
this.record({ content: [role === "user" ? { input: message } : { output: message, source }] }, context);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
exports.MemoryAgent = MemoryAgent;
|
|
@@ -10,13 +10,9 @@ import type { Memory } from "./memory.js";
|
|
|
10
10
|
* should be stored as memories.
|
|
11
11
|
*/
|
|
12
12
|
export interface MemoryRecorderInput extends Message {
|
|
13
|
-
/**
|
|
14
|
-
* Array of content items to record as memories.
|
|
15
|
-
* Each item in this array will typically be converted into a separate memory entry.
|
|
16
|
-
*/
|
|
17
13
|
content: {
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
input?: Message;
|
|
15
|
+
output?: Message;
|
|
20
16
|
source?: string;
|
|
21
17
|
}[];
|
|
22
18
|
}
|
|
@@ -8,8 +8,8 @@ const agent_js_1 = require("../agents/agent.js");
|
|
|
8
8
|
*/
|
|
9
9
|
exports.memoryRecorderInputSchema = zod_1.z.object({
|
|
10
10
|
content: zod_1.z.array(zod_1.z.object({
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
input: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
12
|
+
output: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
13
13
|
source: zod_1.z.string().optional(),
|
|
14
14
|
})),
|
|
15
15
|
});
|
|
@@ -18,7 +18,7 @@ export interface MemoryRetrieverInput extends Message {
|
|
|
18
18
|
* Search term to filter memories by.
|
|
19
19
|
* How the search is implemented depends on the specific retriever implementation.
|
|
20
20
|
*/
|
|
21
|
-
search?: string;
|
|
21
|
+
search?: string | Message;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Output from memory retrieval operations.
|
|
@@ -38,12 +38,12 @@ export interface MemoryRetrieverOutput extends Message {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const memoryRetrieverInputSchema: z.ZodObject<{
|
|
40
40
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
search: z.ZodOptional<z.ZodString
|
|
41
|
+
search: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
search?: string | undefined;
|
|
43
|
+
search?: string | Record<string, unknown> | undefined;
|
|
44
44
|
limit?: number | undefined;
|
|
45
45
|
}, {
|
|
46
|
-
search?: string | undefined;
|
|
46
|
+
search?: string | Record<string, unknown> | undefined;
|
|
47
47
|
limit?: number | undefined;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
@@ -8,7 +8,7 @@ const agent_js_1 = require("../agents/agent.js");
|
|
|
8
8
|
*/
|
|
9
9
|
exports.memoryRetrieverInputSchema = zod_1.z.object({
|
|
10
10
|
limit: zod_1.z.number().optional(),
|
|
11
|
-
search: zod_1.z.string().optional(),
|
|
11
|
+
search: zod_1.z.union([zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())]).optional(),
|
|
12
12
|
});
|
|
13
13
|
/**
|
|
14
14
|
* @hidden
|
|
@@ -15,6 +15,7 @@ export declare function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
|
|
|
15
15
|
export declare function duplicates<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
16
16
|
export declare function remove<T>(arr: T[], remove: T[] | ((item: T) => boolean)): T[];
|
|
17
17
|
export declare function unique<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
18
|
+
export declare function pick<T extends Record<string, unknown>, K extends keyof T | string>(obj: T, ...keys: (K | K[])[]): Pick<T, Extract<K, keyof T>> & Partial<Record<Exclude<K, keyof T>, unknown>>;
|
|
18
19
|
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, ...keys: (K | K[])[]): Omit<T, K>;
|
|
19
20
|
export declare function omitDeep<T, K>(obj: T, ...keys: (K | K[])[]): unknown;
|
|
20
21
|
export declare function omitBy<T extends Record<string, unknown>, K extends keyof T>(obj: T, predicate: (value: T[K], key: K) => boolean): Partial<T>;
|
|
@@ -8,6 +8,7 @@ exports.isNotEmpty = isNotEmpty;
|
|
|
8
8
|
exports.duplicates = duplicates;
|
|
9
9
|
exports.remove = remove;
|
|
10
10
|
exports.unique = unique;
|
|
11
|
+
exports.pick = pick;
|
|
11
12
|
exports.omit = omit;
|
|
12
13
|
exports.omitDeep = omitDeep;
|
|
13
14
|
exports.omitBy = omitBy;
|
|
@@ -75,6 +76,10 @@ function unique(arr, key = (item) => item) {
|
|
|
75
76
|
return true;
|
|
76
77
|
});
|
|
77
78
|
}
|
|
79
|
+
function pick(obj, ...keys) {
|
|
80
|
+
const flattenedKeys = new Set(keys.flat());
|
|
81
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => flattenedKeys.has(key)));
|
|
82
|
+
}
|
|
78
83
|
function omit(obj, ...keys) {
|
|
79
84
|
const flattenedKeys = new Set(keys.flat());
|
|
80
85
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => !flattenedKeys.has(key)));
|
|
@@ -10,13 +10,9 @@ import type { Memory } from "./memory.js";
|
|
|
10
10
|
* should be stored as memories.
|
|
11
11
|
*/
|
|
12
12
|
export interface MemoryRecorderInput extends Message {
|
|
13
|
-
/**
|
|
14
|
-
* Array of content items to record as memories.
|
|
15
|
-
* Each item in this array will typically be converted into a separate memory entry.
|
|
16
|
-
*/
|
|
17
13
|
content: {
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
input?: Message;
|
|
15
|
+
output?: Message;
|
|
20
16
|
source?: string;
|
|
21
17
|
}[];
|
|
22
18
|
}
|
|
@@ -18,7 +18,7 @@ export interface MemoryRetrieverInput extends Message {
|
|
|
18
18
|
* Search term to filter memories by.
|
|
19
19
|
* How the search is implemented depends on the specific retriever implementation.
|
|
20
20
|
*/
|
|
21
|
-
search?: string;
|
|
21
|
+
search?: string | Message;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Output from memory retrieval operations.
|
|
@@ -38,12 +38,12 @@ export interface MemoryRetrieverOutput extends Message {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const memoryRetrieverInputSchema: z.ZodObject<{
|
|
40
40
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
search: z.ZodOptional<z.ZodString
|
|
41
|
+
search: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
search?: string | undefined;
|
|
43
|
+
search?: string | Record<string, unknown> | undefined;
|
|
44
44
|
limit?: number | undefined;
|
|
45
45
|
}, {
|
|
46
|
-
search?: string | undefined;
|
|
46
|
+
search?: string | Record<string, unknown> | undefined;
|
|
47
47
|
limit?: number | undefined;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
@@ -15,6 +15,7 @@ export declare function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
|
|
|
15
15
|
export declare function duplicates<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
16
16
|
export declare function remove<T>(arr: T[], remove: T[] | ((item: T) => boolean)): T[];
|
|
17
17
|
export declare function unique<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
18
|
+
export declare function pick<T extends Record<string, unknown>, K extends keyof T | string>(obj: T, ...keys: (K | K[])[]): Pick<T, Extract<K, keyof T>> & Partial<Record<Exclude<K, keyof T>, unknown>>;
|
|
18
19
|
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, ...keys: (K | K[])[]): Omit<T, K>;
|
|
19
20
|
export declare function omitDeep<T, K>(obj: T, ...keys: (K | K[])[]): unknown;
|
|
20
21
|
export declare function omitBy<T extends Record<string, unknown>, K extends keyof T>(obj: T, predicate: (value: T[K], key: K) => boolean): Partial<T>;
|
package/lib/esm/agents/agent.js
CHANGED
|
@@ -273,7 +273,6 @@ export class Agent {
|
|
|
273
273
|
for (const memory of this.memories) {
|
|
274
274
|
const ms = (await memory.retrieve({
|
|
275
275
|
...input,
|
|
276
|
-
search: typeof input.search === "string" ? input.search : JSON.stringify(input.search),
|
|
277
276
|
limit: input.limit ?? this.maxRetrieveMemoryCount,
|
|
278
277
|
}, options.context)).memories;
|
|
279
278
|
memories.push(...ms);
|
|
@@ -477,12 +476,7 @@ export class Agent {
|
|
|
477
476
|
async postprocess(input, output, options) {
|
|
478
477
|
this.checkContextStatus(options);
|
|
479
478
|
this.publishToTopics(output, options);
|
|
480
|
-
await this.recordMemories({
|
|
481
|
-
content: [
|
|
482
|
-
{ role: "user", content: input },
|
|
483
|
-
{ role: "agent", content: replaceTransferAgentToName(output), source: this.name },
|
|
484
|
-
],
|
|
485
|
-
}, options);
|
|
479
|
+
await this.recordMemories({ content: [{ input, output: replaceTransferAgentToName(output), source: this.name }] }, options);
|
|
486
480
|
}
|
|
487
481
|
async publishToTopics(output, options) {
|
|
488
482
|
const publishTopics = typeof this.publishTopic === "function" ? await this.publishTopic(output) : this.publishTopic;
|
package/lib/esm/memory/memory.js
CHANGED
|
@@ -130,7 +130,7 @@ export class MemoryAgent extends Agent {
|
|
|
130
130
|
return context.invoke(this.recorder, input);
|
|
131
131
|
}
|
|
132
132
|
async onMessage({ role, source, message, context }) {
|
|
133
|
-
this.record({ content: [{
|
|
133
|
+
this.record({ content: [role === "user" ? { input: message } : { output: message, source }] }, context);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const memoryAgentOptionsSchema = z.object({
|
|
@@ -10,13 +10,9 @@ import type { Memory } from "./memory.js";
|
|
|
10
10
|
* should be stored as memories.
|
|
11
11
|
*/
|
|
12
12
|
export interface MemoryRecorderInput extends Message {
|
|
13
|
-
/**
|
|
14
|
-
* Array of content items to record as memories.
|
|
15
|
-
* Each item in this array will typically be converted into a separate memory entry.
|
|
16
|
-
*/
|
|
17
13
|
content: {
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
input?: Message;
|
|
15
|
+
output?: Message;
|
|
20
16
|
source?: string;
|
|
21
17
|
}[];
|
|
22
18
|
}
|
|
@@ -5,8 +5,8 @@ import { Agent, } from "../agents/agent.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export const memoryRecorderInputSchema = z.object({
|
|
7
7
|
content: z.array(z.object({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
input: z.record(z.string(), z.unknown()).optional(),
|
|
9
|
+
output: z.record(z.string(), z.unknown()).optional(),
|
|
10
10
|
source: z.string().optional(),
|
|
11
11
|
})),
|
|
12
12
|
});
|
|
@@ -18,7 +18,7 @@ export interface MemoryRetrieverInput extends Message {
|
|
|
18
18
|
* Search term to filter memories by.
|
|
19
19
|
* How the search is implemented depends on the specific retriever implementation.
|
|
20
20
|
*/
|
|
21
|
-
search?: string;
|
|
21
|
+
search?: string | Message;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Output from memory retrieval operations.
|
|
@@ -38,12 +38,12 @@ export interface MemoryRetrieverOutput extends Message {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const memoryRetrieverInputSchema: z.ZodObject<{
|
|
40
40
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
search: z.ZodOptional<z.ZodString
|
|
41
|
+
search: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
search?: string | undefined;
|
|
43
|
+
search?: string | Record<string, unknown> | undefined;
|
|
44
44
|
limit?: number | undefined;
|
|
45
45
|
}, {
|
|
46
|
-
search?: string | undefined;
|
|
46
|
+
search?: string | Record<string, unknown> | undefined;
|
|
47
47
|
limit?: number | undefined;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
@@ -5,7 +5,7 @@ import { Agent, } from "../agents/agent.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export const memoryRetrieverInputSchema = z.object({
|
|
7
7
|
limit: z.number().optional(),
|
|
8
|
-
search: z.string().optional(),
|
|
8
|
+
search: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
|
|
9
9
|
});
|
|
10
10
|
/**
|
|
11
11
|
* @hidden
|
|
@@ -15,6 +15,7 @@ export declare function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
|
|
|
15
15
|
export declare function duplicates<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
16
16
|
export declare function remove<T>(arr: T[], remove: T[] | ((item: T) => boolean)): T[];
|
|
17
17
|
export declare function unique<T>(arr: T[], key?: (item: T) => unknown): T[];
|
|
18
|
+
export declare function pick<T extends Record<string, unknown>, K extends keyof T | string>(obj: T, ...keys: (K | K[])[]): Pick<T, Extract<K, keyof T>> & Partial<Record<Exclude<K, keyof T>, unknown>>;
|
|
18
19
|
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, ...keys: (K | K[])[]): Omit<T, K>;
|
|
19
20
|
export declare function omitDeep<T, K>(obj: T, ...keys: (K | K[])[]): unknown;
|
|
20
21
|
export declare function omitBy<T extends Record<string, unknown>, K extends keyof T>(obj: T, predicate: (value: T[K], key: K) => boolean): Partial<T>;
|
|
@@ -58,6 +58,10 @@ export function unique(arr, key = (item) => item) {
|
|
|
58
58
|
return true;
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
export function pick(obj, ...keys) {
|
|
62
|
+
const flattenedKeys = new Set(keys.flat());
|
|
63
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => flattenedKeys.has(key)));
|
|
64
|
+
}
|
|
61
65
|
export function omit(obj, ...keys) {
|
|
62
66
|
const flattenedKeys = new Set(keys.flat());
|
|
63
67
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => !flattenedKeys.has(key)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/core",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.1",
|
|
4
4
|
"description": "AIGNE core library for building AI-powered applications",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"yaml": "^2.7.1",
|
|
82
82
|
"zod": "^3.24.4",
|
|
83
83
|
"zod-to-json-schema": "^3.24.5",
|
|
84
|
-
"@aigne/
|
|
85
|
-
"@aigne/
|
|
84
|
+
"@aigne/observability": "^0.1.1",
|
|
85
|
+
"@aigne/platform-helpers": "^0.1.2"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/bun": "^1.2.12",
|