@aigne/core 1.0.12-beta.18 → 1.0.12-beta.2
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/lib/cjs/agent.d.ts +0 -1
- package/lib/cjs/agent.js +0 -9
- package/lib/cjs/context.d.ts +0 -6
- package/lib/cjs/memorable.d.ts +3 -10
- package/lib/cjs/memorable.js +1 -2
- package/lib/cjs/runtime.d.ts +0 -9
- package/lib/cjs/runtime.js +0 -3
- package/lib/dts/agent.d.ts +0 -1
- package/lib/dts/context.d.ts +0 -6
- package/lib/dts/memorable.d.ts +3 -10
- package/lib/dts/runtime.d.ts +0 -9
- package/lib/esm/agent.d.ts +0 -1
- package/lib/esm/agent.js +0 -9
- package/lib/esm/context.d.ts +0 -6
- package/lib/esm/memorable.d.ts +3 -10
- package/lib/esm/memorable.js +1 -2
- package/lib/esm/runtime.d.ts +0 -9
- package/lib/esm/runtime.js +0 -3
- package/package.json +1 -1
package/lib/cjs/agent.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare abstract class Agent<I extends RunnableInput = RunnableInput, O e
|
|
|
32
32
|
run(input: I, options?: RunOptions & {
|
|
33
33
|
stream?: false;
|
|
34
34
|
}): Promise<O>;
|
|
35
|
-
private addHistory;
|
|
36
35
|
/**
|
|
37
36
|
* Hook that is called before the agent result is returned.
|
|
38
37
|
* @param _result The agent result.
|
package/lib/cjs/agent.js
CHANGED
|
@@ -118,7 +118,6 @@ class Agent extends runnable_1.Runnable {
|
|
|
118
118
|
logger_1.logger.debug(`AIGNE core: run agent ${this.name || this.id} success`, {
|
|
119
119
|
result,
|
|
120
120
|
});
|
|
121
|
-
await this.addHistory({ input, output: result });
|
|
122
121
|
await this.onResult(result);
|
|
123
122
|
});
|
|
124
123
|
}
|
|
@@ -131,17 +130,9 @@ class Agent extends runnable_1.Runnable {
|
|
|
131
130
|
result,
|
|
132
131
|
});
|
|
133
132
|
// TODO: validate result against outputs schema
|
|
134
|
-
await this.addHistory({ input, output: result });
|
|
135
133
|
await this.onResult(result);
|
|
136
134
|
return result;
|
|
137
135
|
}
|
|
138
|
-
async addHistory({ input, output }) {
|
|
139
|
-
await this.context?.historyManager?.create({ input, output }, {
|
|
140
|
-
userId: this.context?.state.userId,
|
|
141
|
-
sessionId: this.context?.state.sessionId,
|
|
142
|
-
agentId: this.id,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
136
|
/**
|
|
146
137
|
* Hook that is called before the agent result is returned.
|
|
147
138
|
* @param _result The agent result.
|
package/lib/cjs/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LLMModelConfiguration } from "./llm-model";
|
|
2
|
-
import type { Memorable } from "./memorable";
|
|
3
2
|
import type { Runnable, RunnableDefinition } from "./runnable";
|
|
4
3
|
export interface ContextState {
|
|
5
4
|
userId?: string;
|
|
@@ -10,13 +9,8 @@ export interface ContextConfig {
|
|
|
10
9
|
llmModel?: LLMModelConfiguration;
|
|
11
10
|
}
|
|
12
11
|
export interface Context<State extends ContextState = ContextState, Config extends ContextConfig = ContextConfig> {
|
|
13
|
-
id: string;
|
|
14
12
|
state: State;
|
|
15
13
|
config: Config;
|
|
16
|
-
historyManager?: Memorable<{
|
|
17
|
-
input: object;
|
|
18
|
-
output: object;
|
|
19
|
-
}>;
|
|
20
14
|
resolve<T extends Runnable>(id: string | RunnableDefinition | T): Promise<T>;
|
|
21
15
|
register<R extends Array<RunnableDefinition | Runnable> = []>(...definition: R): void;
|
|
22
16
|
resolveDependency<T>(token: string | symbol): T;
|
package/lib/cjs/memorable.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Agent } from "./agent";
|
|
2
1
|
import type { Context } from "./context";
|
|
3
2
|
import type { LLMModelInputMessage } from "./llm-model";
|
|
4
3
|
import { Runnable } from "./runnable";
|
|
@@ -26,7 +25,6 @@ export interface MemoryItem<T> {
|
|
|
26
25
|
id: string;
|
|
27
26
|
userId?: string;
|
|
28
27
|
sessionId?: string;
|
|
29
|
-
agentId?: string;
|
|
30
28
|
createdAt: string;
|
|
31
29
|
updatedAt: string;
|
|
32
30
|
memory: T;
|
|
@@ -43,7 +41,6 @@ export type MemoryActions<T> = {
|
|
|
43
41
|
options?: {
|
|
44
42
|
userId?: string;
|
|
45
43
|
sessionId?: string;
|
|
46
|
-
agentId?: string;
|
|
47
44
|
metadata?: MemoryMetadata;
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -58,7 +55,6 @@ export type MemoryActions<T> = {
|
|
|
58
55
|
k?: number;
|
|
59
56
|
userId?: string;
|
|
60
57
|
sessionId?: string;
|
|
61
|
-
agentId?: string;
|
|
62
58
|
filter?: MemoryMetadata;
|
|
63
59
|
sort?: MemorySortOptions;
|
|
64
60
|
};
|
|
@@ -73,7 +69,6 @@ export type MemoryActions<T> = {
|
|
|
73
69
|
k?: number;
|
|
74
70
|
userId?: string;
|
|
75
71
|
sessionId?: string;
|
|
76
|
-
agentId?: string;
|
|
77
72
|
filter?: MemoryMetadata;
|
|
78
73
|
sort?: MemorySortOptions;
|
|
79
74
|
};
|
|
@@ -96,7 +91,6 @@ export type MemoryActions<T> = {
|
|
|
96
91
|
options?: {
|
|
97
92
|
userId?: string;
|
|
98
93
|
sessionId?: string;
|
|
99
|
-
agentId?: string;
|
|
100
94
|
metadata?: MemoryMetadata;
|
|
101
95
|
};
|
|
102
96
|
};
|
|
@@ -134,7 +128,7 @@ export interface SortItem {
|
|
|
134
128
|
direction: "asc" | "desc";
|
|
135
129
|
}
|
|
136
130
|
export type MemorySortOptions = SortItem | SortItem[];
|
|
137
|
-
export declare abstract class Memorable<T, C
|
|
131
|
+
export declare abstract class Memorable<T, C = undefined> extends Runnable<MemoryActions<T>, MemoryActions<T>["outputs"]> {
|
|
138
132
|
constructor(context?: Context);
|
|
139
133
|
abstract runner?: MemoryRunner<T, C>;
|
|
140
134
|
abstract add(messages: Extract<MemoryActions<T>, {
|
|
@@ -180,11 +174,10 @@ export declare abstract class Memorable<T, C extends Record<string, any> = Recor
|
|
|
180
174
|
}>["outputs"]>;
|
|
181
175
|
abstract reset(): Promise<void>;
|
|
182
176
|
}
|
|
183
|
-
export type MemoryRunnerInput<C
|
|
177
|
+
export type MemoryRunnerInput<C = undefined> = {
|
|
184
178
|
messages: MemoryMessage[];
|
|
185
179
|
userId?: string;
|
|
186
180
|
sessionId?: string;
|
|
187
|
-
agentId?: string;
|
|
188
181
|
metadata?: MemoryMetadata;
|
|
189
182
|
filter?: MemoryMetadata;
|
|
190
183
|
customData: C;
|
|
@@ -192,7 +185,7 @@ export type MemoryRunnerInput<C extends Record<string, any> = Record<string, any
|
|
|
192
185
|
export type MemoryRunnerOutput<T> = {
|
|
193
186
|
actions: MemoryActionItem<T>[];
|
|
194
187
|
};
|
|
195
|
-
export declare abstract class MemoryRunner<T, C
|
|
188
|
+
export declare abstract class MemoryRunner<T, C = undefined> extends Runnable<MemoryRunnerInput<C>, MemoryRunnerOutput<T>> {
|
|
196
189
|
constructor(name: string);
|
|
197
190
|
}
|
|
198
191
|
export type MemorableSearchOutput<T extends Memorable<unknown>> = Awaited<ReturnType<T["search"]>>["results"];
|
package/lib/cjs/memorable.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MemoryRunner = exports.Memorable = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const agent_1 = require("./agent");
|
|
6
5
|
const runnable_1 = require("./runnable");
|
|
7
6
|
const utils_1 = require("./utils");
|
|
8
7
|
class Memorable extends runnable_1.Runnable {
|
|
@@ -17,7 +16,7 @@ class Memorable extends runnable_1.Runnable {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
exports.Memorable = Memorable;
|
|
20
|
-
class MemoryRunner extends
|
|
19
|
+
class MemoryRunner extends runnable_1.Runnable {
|
|
21
20
|
constructor(name) {
|
|
22
21
|
const id = `${(0, lodash_1.camelCase)(name)}_runner`;
|
|
23
22
|
super({
|
package/lib/cjs/runtime.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { type DependencyContainer } from "tsyringe";
|
|
|
2
2
|
import type { constructor as Constructor } from "tsyringe/dist/typings/types";
|
|
3
3
|
import type { Context, ContextState } from "./context";
|
|
4
4
|
import type { LLMModel, LLMModelConfiguration } from "./llm-model";
|
|
5
|
-
import type { Memorable } from "./memorable";
|
|
6
5
|
import { Runnable, type RunnableDefinition } from "./runnable";
|
|
7
6
|
import type { SandboxFunctionRunner } from "./sandbox-function-runner";
|
|
8
7
|
import { OrderedRecord } from "./utils/ordered-map";
|
|
@@ -18,10 +17,6 @@ export interface RuntimeOptions<Agents extends {
|
|
|
18
17
|
config?: RuntimeConfiguration;
|
|
19
18
|
state?: State;
|
|
20
19
|
agents?: Agents;
|
|
21
|
-
historyManager?: Memorable<{
|
|
22
|
-
input: object;
|
|
23
|
-
output: object;
|
|
24
|
-
}>;
|
|
25
20
|
llmModel?: LLMModel | Constructor<LLMModel>;
|
|
26
21
|
sandboxFunctionRunner?: SandboxFunctionRunner | Constructor<SandboxFunctionRunner>;
|
|
27
22
|
}
|
|
@@ -33,10 +28,6 @@ export declare class Runtime<Agents extends {
|
|
|
33
28
|
get options(): RuntimeOptions<Agents, State>;
|
|
34
29
|
get id(): string;
|
|
35
30
|
get name(): string | undefined;
|
|
36
|
-
get historyManager(): Memorable<{
|
|
37
|
-
input: object;
|
|
38
|
-
output: object;
|
|
39
|
-
}, Record<string, any>> | undefined;
|
|
40
31
|
config: RuntimeConfiguration;
|
|
41
32
|
state: State;
|
|
42
33
|
agents: Agents;
|
package/lib/cjs/runtime.js
CHANGED
|
@@ -47,9 +47,6 @@ let Runtime = Runtime_1 = class Runtime {
|
|
|
47
47
|
get name() {
|
|
48
48
|
return this.inner.name;
|
|
49
49
|
}
|
|
50
|
-
get historyManager() {
|
|
51
|
-
return this.inner.options.historyManager;
|
|
52
|
-
}
|
|
53
50
|
config;
|
|
54
51
|
state;
|
|
55
52
|
agents = new Proxy({}, { get: (_, prop) => this.resolveSync(prop.toString()) });
|
package/lib/dts/agent.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare abstract class Agent<I extends RunnableInput = RunnableInput, O e
|
|
|
32
32
|
run(input: I, options?: RunOptions & {
|
|
33
33
|
stream?: false;
|
|
34
34
|
}): Promise<O>;
|
|
35
|
-
private addHistory;
|
|
36
35
|
/**
|
|
37
36
|
* Hook that is called before the agent result is returned.
|
|
38
37
|
* @param _result The agent result.
|
package/lib/dts/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LLMModelConfiguration } from "./llm-model";
|
|
2
|
-
import type { Memorable } from "./memorable";
|
|
3
2
|
import type { Runnable, RunnableDefinition } from "./runnable";
|
|
4
3
|
export interface ContextState {
|
|
5
4
|
userId?: string;
|
|
@@ -10,13 +9,8 @@ export interface ContextConfig {
|
|
|
10
9
|
llmModel?: LLMModelConfiguration;
|
|
11
10
|
}
|
|
12
11
|
export interface Context<State extends ContextState = ContextState, Config extends ContextConfig = ContextConfig> {
|
|
13
|
-
id: string;
|
|
14
12
|
state: State;
|
|
15
13
|
config: Config;
|
|
16
|
-
historyManager?: Memorable<{
|
|
17
|
-
input: object;
|
|
18
|
-
output: object;
|
|
19
|
-
}>;
|
|
20
14
|
resolve<T extends Runnable>(id: string | RunnableDefinition | T): Promise<T>;
|
|
21
15
|
register<R extends Array<RunnableDefinition | Runnable> = []>(...definition: R): void;
|
|
22
16
|
resolveDependency<T>(token: string | symbol): T;
|
package/lib/dts/memorable.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Agent } from "./agent";
|
|
2
1
|
import type { Context } from "./context";
|
|
3
2
|
import type { LLMModelInputMessage } from "./llm-model";
|
|
4
3
|
import { Runnable } from "./runnable";
|
|
@@ -26,7 +25,6 @@ export interface MemoryItem<T> {
|
|
|
26
25
|
id: string;
|
|
27
26
|
userId?: string;
|
|
28
27
|
sessionId?: string;
|
|
29
|
-
agentId?: string;
|
|
30
28
|
createdAt: string;
|
|
31
29
|
updatedAt: string;
|
|
32
30
|
memory: T;
|
|
@@ -43,7 +41,6 @@ export type MemoryActions<T> = {
|
|
|
43
41
|
options?: {
|
|
44
42
|
userId?: string;
|
|
45
43
|
sessionId?: string;
|
|
46
|
-
agentId?: string;
|
|
47
44
|
metadata?: MemoryMetadata;
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -58,7 +55,6 @@ export type MemoryActions<T> = {
|
|
|
58
55
|
k?: number;
|
|
59
56
|
userId?: string;
|
|
60
57
|
sessionId?: string;
|
|
61
|
-
agentId?: string;
|
|
62
58
|
filter?: MemoryMetadata;
|
|
63
59
|
sort?: MemorySortOptions;
|
|
64
60
|
};
|
|
@@ -73,7 +69,6 @@ export type MemoryActions<T> = {
|
|
|
73
69
|
k?: number;
|
|
74
70
|
userId?: string;
|
|
75
71
|
sessionId?: string;
|
|
76
|
-
agentId?: string;
|
|
77
72
|
filter?: MemoryMetadata;
|
|
78
73
|
sort?: MemorySortOptions;
|
|
79
74
|
};
|
|
@@ -96,7 +91,6 @@ export type MemoryActions<T> = {
|
|
|
96
91
|
options?: {
|
|
97
92
|
userId?: string;
|
|
98
93
|
sessionId?: string;
|
|
99
|
-
agentId?: string;
|
|
100
94
|
metadata?: MemoryMetadata;
|
|
101
95
|
};
|
|
102
96
|
};
|
|
@@ -134,7 +128,7 @@ export interface SortItem {
|
|
|
134
128
|
direction: "asc" | "desc";
|
|
135
129
|
}
|
|
136
130
|
export type MemorySortOptions = SortItem | SortItem[];
|
|
137
|
-
export declare abstract class Memorable<T, C
|
|
131
|
+
export declare abstract class Memorable<T, C = undefined> extends Runnable<MemoryActions<T>, MemoryActions<T>["outputs"]> {
|
|
138
132
|
constructor(context?: Context);
|
|
139
133
|
abstract runner?: MemoryRunner<T, C>;
|
|
140
134
|
abstract add(messages: Extract<MemoryActions<T>, {
|
|
@@ -180,11 +174,10 @@ export declare abstract class Memorable<T, C extends Record<string, any> = Recor
|
|
|
180
174
|
}>["outputs"]>;
|
|
181
175
|
abstract reset(): Promise<void>;
|
|
182
176
|
}
|
|
183
|
-
export type MemoryRunnerInput<C
|
|
177
|
+
export type MemoryRunnerInput<C = undefined> = {
|
|
184
178
|
messages: MemoryMessage[];
|
|
185
179
|
userId?: string;
|
|
186
180
|
sessionId?: string;
|
|
187
|
-
agentId?: string;
|
|
188
181
|
metadata?: MemoryMetadata;
|
|
189
182
|
filter?: MemoryMetadata;
|
|
190
183
|
customData: C;
|
|
@@ -192,7 +185,7 @@ export type MemoryRunnerInput<C extends Record<string, any> = Record<string, any
|
|
|
192
185
|
export type MemoryRunnerOutput<T> = {
|
|
193
186
|
actions: MemoryActionItem<T>[];
|
|
194
187
|
};
|
|
195
|
-
export declare abstract class MemoryRunner<T, C
|
|
188
|
+
export declare abstract class MemoryRunner<T, C = undefined> extends Runnable<MemoryRunnerInput<C>, MemoryRunnerOutput<T>> {
|
|
196
189
|
constructor(name: string);
|
|
197
190
|
}
|
|
198
191
|
export type MemorableSearchOutput<T extends Memorable<unknown>> = Awaited<ReturnType<T["search"]>>["results"];
|
package/lib/dts/runtime.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { type DependencyContainer } from "tsyringe";
|
|
|
2
2
|
import type { constructor as Constructor } from "tsyringe/dist/typings/types";
|
|
3
3
|
import type { Context, ContextState } from "./context";
|
|
4
4
|
import type { LLMModel, LLMModelConfiguration } from "./llm-model";
|
|
5
|
-
import type { Memorable } from "./memorable";
|
|
6
5
|
import { Runnable, type RunnableDefinition } from "./runnable";
|
|
7
6
|
import type { SandboxFunctionRunner } from "./sandbox-function-runner";
|
|
8
7
|
import { OrderedRecord } from "./utils/ordered-map";
|
|
@@ -18,10 +17,6 @@ export interface RuntimeOptions<Agents extends {
|
|
|
18
17
|
config?: RuntimeConfiguration;
|
|
19
18
|
state?: State;
|
|
20
19
|
agents?: Agents;
|
|
21
|
-
historyManager?: Memorable<{
|
|
22
|
-
input: object;
|
|
23
|
-
output: object;
|
|
24
|
-
}>;
|
|
25
20
|
llmModel?: LLMModel | Constructor<LLMModel>;
|
|
26
21
|
sandboxFunctionRunner?: SandboxFunctionRunner | Constructor<SandboxFunctionRunner>;
|
|
27
22
|
}
|
|
@@ -33,10 +28,6 @@ export declare class Runtime<Agents extends {
|
|
|
33
28
|
get options(): RuntimeOptions<Agents, State>;
|
|
34
29
|
get id(): string;
|
|
35
30
|
get name(): string | undefined;
|
|
36
|
-
get historyManager(): Memorable<{
|
|
37
|
-
input: object;
|
|
38
|
-
output: object;
|
|
39
|
-
}, Record<string, any>> | undefined;
|
|
40
31
|
config: RuntimeConfiguration;
|
|
41
32
|
state: State;
|
|
42
33
|
agents: Agents;
|
package/lib/esm/agent.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare abstract class Agent<I extends RunnableInput = RunnableInput, O e
|
|
|
32
32
|
run(input: I, options?: RunOptions & {
|
|
33
33
|
stream?: false;
|
|
34
34
|
}): Promise<O>;
|
|
35
|
-
private addHistory;
|
|
36
35
|
/**
|
|
37
36
|
* Hook that is called before the agent result is returned.
|
|
38
37
|
* @param _result The agent result.
|
package/lib/esm/agent.js
CHANGED
|
@@ -115,7 +115,6 @@ export class Agent extends Runnable {
|
|
|
115
115
|
logger.debug(`AIGNE core: run agent ${this.name || this.id} success`, {
|
|
116
116
|
result,
|
|
117
117
|
});
|
|
118
|
-
await this.addHistory({ input, output: result });
|
|
119
118
|
await this.onResult(result);
|
|
120
119
|
});
|
|
121
120
|
}
|
|
@@ -128,17 +127,9 @@ export class Agent extends Runnable {
|
|
|
128
127
|
result,
|
|
129
128
|
});
|
|
130
129
|
// TODO: validate result against outputs schema
|
|
131
|
-
await this.addHistory({ input, output: result });
|
|
132
130
|
await this.onResult(result);
|
|
133
131
|
return result;
|
|
134
132
|
}
|
|
135
|
-
async addHistory({ input, output }) {
|
|
136
|
-
await this.context?.historyManager?.create({ input, output }, {
|
|
137
|
-
userId: this.context?.state.userId,
|
|
138
|
-
sessionId: this.context?.state.sessionId,
|
|
139
|
-
agentId: this.id,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
133
|
/**
|
|
143
134
|
* Hook that is called before the agent result is returned.
|
|
144
135
|
* @param _result The agent result.
|
package/lib/esm/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LLMModelConfiguration } from "./llm-model";
|
|
2
|
-
import type { Memorable } from "./memorable";
|
|
3
2
|
import type { Runnable, RunnableDefinition } from "./runnable";
|
|
4
3
|
export interface ContextState {
|
|
5
4
|
userId?: string;
|
|
@@ -10,13 +9,8 @@ export interface ContextConfig {
|
|
|
10
9
|
llmModel?: LLMModelConfiguration;
|
|
11
10
|
}
|
|
12
11
|
export interface Context<State extends ContextState = ContextState, Config extends ContextConfig = ContextConfig> {
|
|
13
|
-
id: string;
|
|
14
12
|
state: State;
|
|
15
13
|
config: Config;
|
|
16
|
-
historyManager?: Memorable<{
|
|
17
|
-
input: object;
|
|
18
|
-
output: object;
|
|
19
|
-
}>;
|
|
20
14
|
resolve<T extends Runnable>(id: string | RunnableDefinition | T): Promise<T>;
|
|
21
15
|
register<R extends Array<RunnableDefinition | Runnable> = []>(...definition: R): void;
|
|
22
16
|
resolveDependency<T>(token: string | symbol): T;
|
package/lib/esm/memorable.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Agent } from "./agent";
|
|
2
1
|
import type { Context } from "./context";
|
|
3
2
|
import type { LLMModelInputMessage } from "./llm-model";
|
|
4
3
|
import { Runnable } from "./runnable";
|
|
@@ -26,7 +25,6 @@ export interface MemoryItem<T> {
|
|
|
26
25
|
id: string;
|
|
27
26
|
userId?: string;
|
|
28
27
|
sessionId?: string;
|
|
29
|
-
agentId?: string;
|
|
30
28
|
createdAt: string;
|
|
31
29
|
updatedAt: string;
|
|
32
30
|
memory: T;
|
|
@@ -43,7 +41,6 @@ export type MemoryActions<T> = {
|
|
|
43
41
|
options?: {
|
|
44
42
|
userId?: string;
|
|
45
43
|
sessionId?: string;
|
|
46
|
-
agentId?: string;
|
|
47
44
|
metadata?: MemoryMetadata;
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -58,7 +55,6 @@ export type MemoryActions<T> = {
|
|
|
58
55
|
k?: number;
|
|
59
56
|
userId?: string;
|
|
60
57
|
sessionId?: string;
|
|
61
|
-
agentId?: string;
|
|
62
58
|
filter?: MemoryMetadata;
|
|
63
59
|
sort?: MemorySortOptions;
|
|
64
60
|
};
|
|
@@ -73,7 +69,6 @@ export type MemoryActions<T> = {
|
|
|
73
69
|
k?: number;
|
|
74
70
|
userId?: string;
|
|
75
71
|
sessionId?: string;
|
|
76
|
-
agentId?: string;
|
|
77
72
|
filter?: MemoryMetadata;
|
|
78
73
|
sort?: MemorySortOptions;
|
|
79
74
|
};
|
|
@@ -96,7 +91,6 @@ export type MemoryActions<T> = {
|
|
|
96
91
|
options?: {
|
|
97
92
|
userId?: string;
|
|
98
93
|
sessionId?: string;
|
|
99
|
-
agentId?: string;
|
|
100
94
|
metadata?: MemoryMetadata;
|
|
101
95
|
};
|
|
102
96
|
};
|
|
@@ -134,7 +128,7 @@ export interface SortItem {
|
|
|
134
128
|
direction: "asc" | "desc";
|
|
135
129
|
}
|
|
136
130
|
export type MemorySortOptions = SortItem | SortItem[];
|
|
137
|
-
export declare abstract class Memorable<T, C
|
|
131
|
+
export declare abstract class Memorable<T, C = undefined> extends Runnable<MemoryActions<T>, MemoryActions<T>["outputs"]> {
|
|
138
132
|
constructor(context?: Context);
|
|
139
133
|
abstract runner?: MemoryRunner<T, C>;
|
|
140
134
|
abstract add(messages: Extract<MemoryActions<T>, {
|
|
@@ -180,11 +174,10 @@ export declare abstract class Memorable<T, C extends Record<string, any> = Recor
|
|
|
180
174
|
}>["outputs"]>;
|
|
181
175
|
abstract reset(): Promise<void>;
|
|
182
176
|
}
|
|
183
|
-
export type MemoryRunnerInput<C
|
|
177
|
+
export type MemoryRunnerInput<C = undefined> = {
|
|
184
178
|
messages: MemoryMessage[];
|
|
185
179
|
userId?: string;
|
|
186
180
|
sessionId?: string;
|
|
187
|
-
agentId?: string;
|
|
188
181
|
metadata?: MemoryMetadata;
|
|
189
182
|
filter?: MemoryMetadata;
|
|
190
183
|
customData: C;
|
|
@@ -192,7 +185,7 @@ export type MemoryRunnerInput<C extends Record<string, any> = Record<string, any
|
|
|
192
185
|
export type MemoryRunnerOutput<T> = {
|
|
193
186
|
actions: MemoryActionItem<T>[];
|
|
194
187
|
};
|
|
195
|
-
export declare abstract class MemoryRunner<T, C
|
|
188
|
+
export declare abstract class MemoryRunner<T, C = undefined> extends Runnable<MemoryRunnerInput<C>, MemoryRunnerOutput<T>> {
|
|
196
189
|
constructor(name: string);
|
|
197
190
|
}
|
|
198
191
|
export type MemorableSearchOutput<T extends Memorable<unknown>> = Awaited<ReturnType<T["search"]>>["results"];
|
package/lib/esm/memorable.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { camelCase, startCase } from "lodash";
|
|
2
|
-
import { Agent } from "./agent";
|
|
3
2
|
import { Runnable } from "./runnable";
|
|
4
3
|
import { OrderedRecord } from "./utils";
|
|
5
4
|
export class Memorable extends Runnable {
|
|
@@ -13,7 +12,7 @@ export class Memorable extends Runnable {
|
|
|
13
12
|
}, context);
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
export class MemoryRunner extends
|
|
15
|
+
export class MemoryRunner extends Runnable {
|
|
17
16
|
constructor(name) {
|
|
18
17
|
const id = `${camelCase(name)}_runner`;
|
|
19
18
|
super({
|
package/lib/esm/runtime.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { type DependencyContainer } from "tsyringe";
|
|
|
2
2
|
import type { constructor as Constructor } from "tsyringe/dist/typings/types";
|
|
3
3
|
import type { Context, ContextState } from "./context";
|
|
4
4
|
import type { LLMModel, LLMModelConfiguration } from "./llm-model";
|
|
5
|
-
import type { Memorable } from "./memorable";
|
|
6
5
|
import { Runnable, type RunnableDefinition } from "./runnable";
|
|
7
6
|
import type { SandboxFunctionRunner } from "./sandbox-function-runner";
|
|
8
7
|
import { OrderedRecord } from "./utils/ordered-map";
|
|
@@ -18,10 +17,6 @@ export interface RuntimeOptions<Agents extends {
|
|
|
18
17
|
config?: RuntimeConfiguration;
|
|
19
18
|
state?: State;
|
|
20
19
|
agents?: Agents;
|
|
21
|
-
historyManager?: Memorable<{
|
|
22
|
-
input: object;
|
|
23
|
-
output: object;
|
|
24
|
-
}>;
|
|
25
20
|
llmModel?: LLMModel | Constructor<LLMModel>;
|
|
26
21
|
sandboxFunctionRunner?: SandboxFunctionRunner | Constructor<SandboxFunctionRunner>;
|
|
27
22
|
}
|
|
@@ -33,10 +28,6 @@ export declare class Runtime<Agents extends {
|
|
|
33
28
|
get options(): RuntimeOptions<Agents, State>;
|
|
34
29
|
get id(): string;
|
|
35
30
|
get name(): string | undefined;
|
|
36
|
-
get historyManager(): Memorable<{
|
|
37
|
-
input: object;
|
|
38
|
-
output: object;
|
|
39
|
-
}, Record<string, any>> | undefined;
|
|
40
31
|
config: RuntimeConfiguration;
|
|
41
32
|
state: State;
|
|
42
33
|
agents: Agents;
|
package/lib/esm/runtime.js
CHANGED
|
@@ -44,9 +44,6 @@ let Runtime = Runtime_1 = class Runtime {
|
|
|
44
44
|
get name() {
|
|
45
45
|
return this.inner.name;
|
|
46
46
|
}
|
|
47
|
-
get historyManager() {
|
|
48
|
-
return this.inner.options.historyManager;
|
|
49
|
-
}
|
|
50
47
|
config;
|
|
51
48
|
state;
|
|
52
49
|
agents = new Proxy({}, { get: (_, prop) => this.resolveSync(prop.toString()) });
|