agentxjs 2.6.1 → 2.8.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/README.md +44 -1
- package/dist/chunk-JUZULVWQ.js +388 -0
- package/dist/chunk-JUZULVWQ.js.map +1 -0
- package/dist/index.d.ts +59 -289
- package/dist/index.js +124 -304
- package/dist/index.js.map +1 -1
- package/dist/server-MVOHQ5ZM.js +184 -0
- package/dist/server-MVOHQ5ZM.js.map +1 -0
- package/package.json +3 -3
- package/src/AgentHandle.ts +16 -14
- package/src/CommandHandler.ts +89 -204
- package/src/LocalClient.ts +21 -51
- package/src/RemoteClient.ts +20 -45
- package/src/index.ts +12 -26
- package/src/namespaces/agents.ts +34 -28
- package/src/namespaces/images.ts +21 -29
- package/src/namespaces/llm.ts +16 -10
- package/src/namespaces/presentations.ts +7 -7
- package/src/namespaces/sessions.ts +16 -14
- package/src/presentation/Presentation.ts +11 -11
- package/src/types.ts +64 -206
- package/dist/chunk-JTHR3AK6.js +0 -652
- package/dist/chunk-JTHR3AK6.js.map +0 -1
- package/dist/server-UCQISBKH.js +0 -7
- package/dist/server-UCQISBKH.js.map +0 -1
- package/src/namespaces/containers.ts +0 -68
- package/src/namespaces/prototypes.ts +0 -136
package/src/LocalClient.ts
CHANGED
|
@@ -12,20 +12,12 @@ import type { AgentXRuntime } from "@agentxjs/core/runtime";
|
|
|
12
12
|
import { createLogger } from "commonxjs/logger";
|
|
13
13
|
import { AgentHandleImpl } from "./AgentHandle";
|
|
14
14
|
import { CommandHandler } from "./CommandHandler";
|
|
15
|
-
import {
|
|
16
|
-
import { createLocalContainers } from "./namespaces/containers";
|
|
15
|
+
import { createLocalInstances } from "./namespaces/agents";
|
|
17
16
|
import { createLocalImages } from "./namespaces/images";
|
|
18
17
|
import { createLocalLLM } from "./namespaces/llm";
|
|
19
18
|
import { createPresentations } from "./namespaces/presentations";
|
|
20
|
-
import { createLocalPrototypes } from "./namespaces/prototypes";
|
|
21
19
|
import { createLocalSessions } from "./namespaces/sessions";
|
|
22
|
-
import type {
|
|
23
|
-
AgentX,
|
|
24
|
-
ChatNamespace,
|
|
25
|
-
LLMNamespace,
|
|
26
|
-
PrototypeNamespace,
|
|
27
|
-
RuntimeNamespace,
|
|
28
|
-
} from "./types";
|
|
20
|
+
import type { AgentX, ChatNamespace, LLMNamespace, RuntimeNamespace } from "./types";
|
|
29
21
|
|
|
30
22
|
const logger = createLogger("agentx/LocalClient");
|
|
31
23
|
|
|
@@ -40,23 +32,19 @@ export class LocalClient implements AgentX {
|
|
|
40
32
|
readonly chat: ChatNamespace;
|
|
41
33
|
readonly runtime: RuntimeNamespace;
|
|
42
34
|
readonly provider: LLMNamespace;
|
|
43
|
-
readonly prototype: PrototypeNamespace;
|
|
44
35
|
|
|
45
36
|
constructor(agentxRuntime: AgentXRuntime) {
|
|
46
37
|
this._runtime = agentxRuntime;
|
|
47
38
|
const platform = agentxRuntime.platform;
|
|
48
39
|
|
|
49
|
-
const container = createLocalContainers(platform);
|
|
50
40
|
const image = createLocalImages(platform);
|
|
51
|
-
const
|
|
41
|
+
const instance = createLocalInstances(agentxRuntime);
|
|
52
42
|
const session = createLocalSessions(agentxRuntime);
|
|
53
43
|
const llm = createLocalLLM(platform);
|
|
54
|
-
const
|
|
55
|
-
const present = createPresentations(this, image);
|
|
44
|
+
const present = createPresentations(this, session);
|
|
56
45
|
|
|
57
|
-
this.runtime = {
|
|
46
|
+
this.runtime = { image, instance, session, present, llm };
|
|
58
47
|
this.provider = llm;
|
|
59
|
-
this.prototype = prototype;
|
|
60
48
|
this.chat = this.createChatNamespace();
|
|
61
49
|
|
|
62
50
|
logger.info("LocalClient initialized");
|
|
@@ -110,55 +98,37 @@ export class LocalClient implements AgentX {
|
|
|
110
98
|
// ==================== Private ====================
|
|
111
99
|
|
|
112
100
|
private createChatNamespace(): ChatNamespace {
|
|
113
|
-
const
|
|
101
|
+
const rt = this.runtime;
|
|
114
102
|
return {
|
|
115
103
|
async create(params) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
let mergedParams = { ...params };
|
|
119
|
-
if (params.prototypeId) {
|
|
120
|
-
const protoRes = await instance.prototype.get(params.prototypeId);
|
|
121
|
-
if (protoRes.record) {
|
|
122
|
-
const proto = protoRes.record;
|
|
123
|
-
mergedParams = {
|
|
124
|
-
name: proto.name,
|
|
125
|
-
description: proto.description,
|
|
126
|
-
contextId: proto.contextId,
|
|
127
|
-
embody: proto.embody,
|
|
128
|
-
customData: proto.customData,
|
|
129
|
-
...params, // inline params override prototype
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const { prototypeId: _pid, ...imageParams } = mergedParams;
|
|
134
|
-
const imgRes = await instance.image.create({ containerId, ...imageParams });
|
|
135
|
-
const agentRes = await instance.agent.create({ imageId: imgRes.record.imageId });
|
|
104
|
+
const imgRes = await rt.image.create(params);
|
|
105
|
+
const instRes = await rt.instance.create({ imageId: imgRes.record.imageId });
|
|
136
106
|
return new AgentHandleImpl(
|
|
137
107
|
{
|
|
138
|
-
|
|
139
|
-
imageId:
|
|
140
|
-
containerId:
|
|
141
|
-
sessionId:
|
|
108
|
+
instanceId: instRes.instanceId,
|
|
109
|
+
imageId: instRes.imageId,
|
|
110
|
+
containerId: instRes.containerId,
|
|
111
|
+
sessionId: instRes.sessionId,
|
|
142
112
|
},
|
|
143
|
-
|
|
113
|
+
rt
|
|
144
114
|
);
|
|
145
115
|
},
|
|
146
116
|
async list() {
|
|
147
|
-
return
|
|
117
|
+
return rt.image.list();
|
|
148
118
|
},
|
|
149
119
|
async get(id) {
|
|
150
|
-
const res = await
|
|
120
|
+
const res = await rt.image.get(id);
|
|
151
121
|
if (!res.record) return null;
|
|
152
122
|
const r = res.record;
|
|
153
|
-
const
|
|
123
|
+
const instRes = await rt.instance.create({ imageId: r.imageId });
|
|
154
124
|
return new AgentHandleImpl(
|
|
155
125
|
{
|
|
156
|
-
|
|
157
|
-
imageId:
|
|
158
|
-
containerId:
|
|
159
|
-
sessionId:
|
|
126
|
+
instanceId: instRes.instanceId,
|
|
127
|
+
imageId: instRes.imageId,
|
|
128
|
+
containerId: instRes.containerId,
|
|
129
|
+
sessionId: instRes.sessionId,
|
|
160
130
|
},
|
|
161
|
-
|
|
131
|
+
rt
|
|
162
132
|
);
|
|
163
133
|
},
|
|
164
134
|
};
|
package/src/RemoteClient.ts
CHANGED
|
@@ -11,18 +11,15 @@ import { EventBusImpl } from "@agentxjs/core/event";
|
|
|
11
11
|
import { RpcClient, type RpcMethod } from "@agentxjs/core/network";
|
|
12
12
|
import { createLogger } from "commonxjs/logger";
|
|
13
13
|
import { AgentHandleImpl } from "./AgentHandle";
|
|
14
|
-
import {
|
|
15
|
-
import { createRemoteContainers } from "./namespaces/containers";
|
|
14
|
+
import { createRemoteInstances } from "./namespaces/agents";
|
|
16
15
|
import { createRemoteImages } from "./namespaces/images";
|
|
17
16
|
import { createRemoteLLM } from "./namespaces/llm";
|
|
18
17
|
import { createPresentations } from "./namespaces/presentations";
|
|
19
|
-
import { createRemotePrototypes } from "./namespaces/prototypes";
|
|
20
18
|
import { createRemoteSessions } from "./namespaces/sessions";
|
|
21
19
|
import type {
|
|
22
20
|
AgentX,
|
|
23
21
|
ChatNamespace,
|
|
24
22
|
LLMNamespace,
|
|
25
|
-
PrototypeNamespace,
|
|
26
23
|
RemoteClientConfig,
|
|
27
24
|
RuntimeNamespace,
|
|
28
25
|
} from "./types";
|
|
@@ -40,7 +37,6 @@ export class RemoteClient implements AgentX {
|
|
|
40
37
|
readonly chat: ChatNamespace;
|
|
41
38
|
readonly runtime: RuntimeNamespace;
|
|
42
39
|
readonly provider: LLMNamespace;
|
|
43
|
-
readonly prototype: PrototypeNamespace;
|
|
44
40
|
|
|
45
41
|
constructor(config: RemoteClientConfig) {
|
|
46
42
|
this.config = config;
|
|
@@ -63,17 +59,14 @@ export class RemoteClient implements AgentX {
|
|
|
63
59
|
});
|
|
64
60
|
|
|
65
61
|
// Assemble namespaces
|
|
66
|
-
const container = createRemoteContainers(this.rpcClient);
|
|
67
62
|
const image = createRemoteImages(this.rpcClient, (sessionId) => this.subscribe(sessionId));
|
|
68
|
-
const
|
|
63
|
+
const instance = createRemoteInstances(this.rpcClient);
|
|
69
64
|
const session = createRemoteSessions(this.rpcClient);
|
|
70
65
|
const llm = createRemoteLLM(this.rpcClient);
|
|
71
|
-
const
|
|
72
|
-
const present = createPresentations(this, image);
|
|
66
|
+
const present = createPresentations(this, session);
|
|
73
67
|
|
|
74
|
-
this.runtime = {
|
|
68
|
+
this.runtime = { image, instance, session, present, llm };
|
|
75
69
|
this.provider = llm;
|
|
76
|
-
this.prototype = prototype;
|
|
77
70
|
this.chat = this.createChatNamespace();
|
|
78
71
|
}
|
|
79
72
|
|
|
@@ -137,55 +130,37 @@ export class RemoteClient implements AgentX {
|
|
|
137
130
|
// ==================== Private ====================
|
|
138
131
|
|
|
139
132
|
private createChatNamespace(): ChatNamespace {
|
|
140
|
-
const
|
|
133
|
+
const rt = this.runtime;
|
|
141
134
|
return {
|
|
142
135
|
async create(params) {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
let mergedParams = { ...params };
|
|
146
|
-
if (params.prototypeId) {
|
|
147
|
-
const protoRes = await instance.prototype.get(params.prototypeId);
|
|
148
|
-
if (protoRes.record) {
|
|
149
|
-
const proto = protoRes.record;
|
|
150
|
-
mergedParams = {
|
|
151
|
-
name: proto.name,
|
|
152
|
-
description: proto.description,
|
|
153
|
-
contextId: proto.contextId,
|
|
154
|
-
embody: proto.embody,
|
|
155
|
-
customData: proto.customData,
|
|
156
|
-
...params, // inline params override prototype
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const { prototypeId: _pid, ...imageParams } = mergedParams;
|
|
161
|
-
const imgRes = await instance.image.create({ containerId, ...imageParams });
|
|
162
|
-
const agentRes = await instance.agent.create({ imageId: imgRes.record.imageId });
|
|
136
|
+
const imgRes = await rt.image.create(params);
|
|
137
|
+
const instRes = await rt.instance.create({ imageId: imgRes.record.imageId });
|
|
163
138
|
return new AgentHandleImpl(
|
|
164
139
|
{
|
|
165
|
-
|
|
166
|
-
imageId:
|
|
167
|
-
containerId:
|
|
168
|
-
sessionId:
|
|
140
|
+
instanceId: instRes.instanceId,
|
|
141
|
+
imageId: instRes.imageId,
|
|
142
|
+
containerId: instRes.containerId,
|
|
143
|
+
sessionId: instRes.sessionId,
|
|
169
144
|
},
|
|
170
|
-
|
|
145
|
+
rt
|
|
171
146
|
);
|
|
172
147
|
},
|
|
173
148
|
async list() {
|
|
174
|
-
return
|
|
149
|
+
return rt.image.list();
|
|
175
150
|
},
|
|
176
151
|
async get(id) {
|
|
177
|
-
const res = await
|
|
152
|
+
const res = await rt.image.get(id);
|
|
178
153
|
if (!res.record) return null;
|
|
179
154
|
const r = res.record;
|
|
180
|
-
const
|
|
155
|
+
const instRes = await rt.instance.create({ imageId: r.imageId });
|
|
181
156
|
return new AgentHandleImpl(
|
|
182
157
|
{
|
|
183
|
-
|
|
184
|
-
imageId:
|
|
185
|
-
containerId:
|
|
186
|
-
sessionId:
|
|
158
|
+
instanceId: instRes.instanceId,
|
|
159
|
+
imageId: instRes.imageId,
|
|
160
|
+
containerId: instRes.containerId,
|
|
161
|
+
sessionId: instRes.sessionId,
|
|
187
162
|
},
|
|
188
|
-
|
|
163
|
+
rt
|
|
189
164
|
);
|
|
190
165
|
},
|
|
191
166
|
};
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* import { nodePlatform } from "@agentxjs/node-platform";
|
|
10
10
|
*
|
|
11
11
|
* const ax = createAgentX(nodePlatform({ createDriver }));
|
|
12
|
-
* const agent = await ax.chat.create({ name: "Aristotle",
|
|
12
|
+
* const agent = await ax.chat.create({ name: "Aristotle", model: "claude-sonnet-4-6" });
|
|
13
13
|
* await agent.send("Hello!");
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
@@ -87,10 +87,6 @@ export function createAgentX(config?: PlatformConfig): AgentXBuilder {
|
|
|
87
87
|
return getLocalClient().chat;
|
|
88
88
|
},
|
|
89
89
|
|
|
90
|
-
get prototype() {
|
|
91
|
-
return getLocalClient().prototype;
|
|
92
|
-
},
|
|
93
|
-
|
|
94
90
|
on(type, handler) {
|
|
95
91
|
return getLocalClient().on(type, handler);
|
|
96
92
|
},
|
|
@@ -156,12 +152,12 @@ export function createAgentX(config?: PlatformConfig): AgentXBuilder {
|
|
|
156
152
|
};
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
export
|
|
155
|
+
// Re-export context interfaces
|
|
156
|
+
export type { Capability, Context, ContextProvider } from "@agentxjs/core/context";
|
|
160
157
|
// Re-export error types
|
|
158
|
+
export type { AgentXErrorCategory, AgentXErrorContext } from "@agentxjs/core/error";
|
|
161
159
|
export { AgentXError, AgentXErrorCode } from "@agentxjs/core/error";
|
|
162
|
-
// Re-export
|
|
163
|
-
export { CommandHandler } from "./CommandHandler";
|
|
164
|
-
// Re-export Presentation types and classes
|
|
160
|
+
// Re-export Presentation
|
|
165
161
|
export type {
|
|
166
162
|
AssistantConversation,
|
|
167
163
|
Block,
|
|
@@ -184,32 +180,27 @@ export {
|
|
|
184
180
|
Presentation,
|
|
185
181
|
presentationReducer,
|
|
186
182
|
} from "./presentation";
|
|
187
|
-
export { createServer, type ServerConfig } from "./server";
|
|
188
183
|
// Re-export types
|
|
189
184
|
export type {
|
|
190
|
-
|
|
191
|
-
AgentGetResponse,
|
|
185
|
+
AgentConfig,
|
|
192
186
|
AgentHandle,
|
|
193
|
-
AgentInfo,
|
|
194
|
-
AgentListResponse,
|
|
195
|
-
AgentNamespace,
|
|
196
187
|
AgentX,
|
|
197
188
|
AgentXBuilder,
|
|
198
189
|
AgentXServer,
|
|
199
190
|
BaseResponse,
|
|
200
191
|
ChatNamespace,
|
|
201
192
|
ConnectOptions,
|
|
202
|
-
ContainerCreateResponse,
|
|
203
|
-
ContainerGetResponse,
|
|
204
|
-
ContainerInfo,
|
|
205
|
-
ContainerListResponse,
|
|
206
|
-
ContainerNamespace,
|
|
207
|
-
Embodiment,
|
|
208
193
|
ImageCreateResponse,
|
|
209
194
|
ImageGetResponse,
|
|
210
195
|
ImageListResponse,
|
|
211
196
|
ImageNamespace,
|
|
212
197
|
ImageRecord,
|
|
198
|
+
ImageUpdateResponse,
|
|
199
|
+
InstanceCreateResponse,
|
|
200
|
+
InstanceGetResponse,
|
|
201
|
+
InstanceInfo,
|
|
202
|
+
InstanceListResponse,
|
|
203
|
+
InstanceNamespace,
|
|
213
204
|
LLMNamespace,
|
|
214
205
|
LLMProviderCreateResponse,
|
|
215
206
|
LLMProviderDefaultResponse,
|
|
@@ -219,11 +210,6 @@ export type {
|
|
|
219
210
|
MaybeAsync,
|
|
220
211
|
MessageSendResponse,
|
|
221
212
|
PresentationNamespace,
|
|
222
|
-
PrototypeCreateResponse,
|
|
223
|
-
PrototypeGetResponse,
|
|
224
|
-
PrototypeListResponse,
|
|
225
|
-
PrototypeNamespace,
|
|
226
|
-
PrototypeUpdateResponse,
|
|
227
213
|
RuntimeNamespace,
|
|
228
214
|
ServeConfig,
|
|
229
215
|
SessionNamespace,
|
package/src/namespaces/agents.ts
CHANGED
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
import type { RpcClient, RpcMethod } from "@agentxjs/core/network";
|
|
6
6
|
import type { AgentXRuntime } from "@agentxjs/core/runtime";
|
|
7
7
|
import type {
|
|
8
|
-
AgentCreateResponse,
|
|
9
|
-
AgentGetResponse,
|
|
10
|
-
AgentListResponse,
|
|
11
|
-
AgentNamespace,
|
|
12
8
|
BaseResponse,
|
|
9
|
+
InstanceCreateResponse,
|
|
10
|
+
InstanceGetResponse,
|
|
11
|
+
InstanceListResponse,
|
|
12
|
+
InstanceNamespace,
|
|
13
13
|
} from "../types";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Create local agent namespace backed by embedded runtime
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
18
|
+
export function createLocalInstances(runtime: AgentXRuntime): InstanceNamespace {
|
|
19
19
|
return {
|
|
20
|
-
async create(params: {
|
|
20
|
+
async create(params: {
|
|
21
|
+
imageId: string;
|
|
22
|
+
instanceId?: string;
|
|
23
|
+
}): Promise<InstanceCreateResponse> {
|
|
21
24
|
// Reuse existing running agent for this image
|
|
22
25
|
const existingAgent = runtime
|
|
23
26
|
.getAgents()
|
|
@@ -25,7 +28,7 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
25
28
|
|
|
26
29
|
if (existingAgent) {
|
|
27
30
|
return {
|
|
28
|
-
|
|
31
|
+
instanceId: existingAgent.instanceId,
|
|
29
32
|
imageId: existingAgent.imageId,
|
|
30
33
|
containerId: existingAgent.containerId,
|
|
31
34
|
sessionId: existingAgent.sessionId,
|
|
@@ -35,11 +38,11 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
35
38
|
|
|
36
39
|
const agent = await runtime.createAgent({
|
|
37
40
|
imageId: params.imageId,
|
|
38
|
-
|
|
41
|
+
instanceId: params.instanceId,
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
return {
|
|
42
|
-
|
|
45
|
+
instanceId: agent.instanceId,
|
|
43
46
|
imageId: agent.imageId,
|
|
44
47
|
containerId: agent.containerId,
|
|
45
48
|
sessionId: agent.sessionId,
|
|
@@ -47,12 +50,12 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
47
50
|
};
|
|
48
51
|
},
|
|
49
52
|
|
|
50
|
-
async get(
|
|
51
|
-
const agent = runtime.getAgent(
|
|
53
|
+
async get(instanceId: string): Promise<InstanceGetResponse> {
|
|
54
|
+
const agent = runtime.getAgent(instanceId);
|
|
52
55
|
return {
|
|
53
56
|
agent: agent
|
|
54
57
|
? {
|
|
55
|
-
|
|
58
|
+
instanceId: agent.instanceId,
|
|
56
59
|
imageId: agent.imageId,
|
|
57
60
|
containerId: agent.containerId,
|
|
58
61
|
sessionId: agent.sessionId,
|
|
@@ -64,12 +67,12 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
64
67
|
};
|
|
65
68
|
},
|
|
66
69
|
|
|
67
|
-
async list(
|
|
68
|
-
const agents =
|
|
70
|
+
async list(): Promise<InstanceListResponse> {
|
|
71
|
+
const agents = runtime.getAgents();
|
|
69
72
|
|
|
70
73
|
return {
|
|
71
74
|
agents: agents.map((a) => ({
|
|
72
|
-
|
|
75
|
+
instanceId: a.instanceId,
|
|
73
76
|
imageId: a.imageId,
|
|
74
77
|
containerId: a.containerId,
|
|
75
78
|
sessionId: a.sessionId,
|
|
@@ -79,10 +82,10 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
79
82
|
};
|
|
80
83
|
},
|
|
81
84
|
|
|
82
|
-
async destroy(
|
|
83
|
-
const agent = runtime.getAgent(
|
|
85
|
+
async destroy(instanceId: string): Promise<BaseResponse> {
|
|
86
|
+
const agent = runtime.getAgent(instanceId);
|
|
84
87
|
if (agent) {
|
|
85
|
-
await runtime.destroyAgent(
|
|
88
|
+
await runtime.destroyAgent(instanceId);
|
|
86
89
|
}
|
|
87
90
|
return { requestId: "" };
|
|
88
91
|
},
|
|
@@ -92,29 +95,32 @@ export function createLocalAgents(runtime: AgentXRuntime): AgentNamespace {
|
|
|
92
95
|
/**
|
|
93
96
|
* Create remote agent namespace backed by RPC client
|
|
94
97
|
*/
|
|
95
|
-
export function
|
|
98
|
+
export function createRemoteInstances(rpcClient: RpcClient): InstanceNamespace {
|
|
96
99
|
return {
|
|
97
|
-
async create(params: {
|
|
100
|
+
async create(params: {
|
|
101
|
+
imageId: string;
|
|
102
|
+
instanceId?: string;
|
|
103
|
+
}): Promise<InstanceCreateResponse> {
|
|
98
104
|
// Agent creation via image.run RPC
|
|
99
|
-
const result = await rpcClient.call<
|
|
105
|
+
const result = await rpcClient.call<InstanceCreateResponse>("image.run" as RpcMethod, {
|
|
100
106
|
imageId: params.imageId,
|
|
101
|
-
|
|
107
|
+
instanceId: params.instanceId,
|
|
102
108
|
});
|
|
103
109
|
return { ...result, requestId: "" };
|
|
104
110
|
},
|
|
105
111
|
|
|
106
|
-
async get(
|
|
107
|
-
const result = await rpcClient.call<
|
|
112
|
+
async get(instanceId: string): Promise<InstanceGetResponse> {
|
|
113
|
+
const result = await rpcClient.call<InstanceGetResponse>("instance.get", { instanceId });
|
|
108
114
|
return { ...result, requestId: "" };
|
|
109
115
|
},
|
|
110
116
|
|
|
111
|
-
async list(
|
|
112
|
-
const result = await rpcClient.call<
|
|
117
|
+
async list(): Promise<InstanceListResponse> {
|
|
118
|
+
const result = await rpcClient.call<InstanceListResponse>("instance.list", {});
|
|
113
119
|
return { ...result, requestId: "" };
|
|
114
120
|
},
|
|
115
121
|
|
|
116
|
-
async destroy(
|
|
117
|
-
const result = await rpcClient.call<BaseResponse>("
|
|
122
|
+
async destroy(instanceId: string): Promise<BaseResponse> {
|
|
123
|
+
const result = await rpcClient.call<BaseResponse>("instance.destroy", { instanceId });
|
|
118
124
|
return { ...result, requestId: "" };
|
|
119
125
|
},
|
|
120
126
|
};
|
package/src/namespaces/images.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Message } from "@agentxjs/core/agent";
|
|
6
|
+
import { DEFAULT_CONTAINER_ID } from "@agentxjs/core/container";
|
|
6
7
|
import type { RpcClient } from "@agentxjs/core/network";
|
|
7
8
|
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
8
9
|
import type {
|
|
10
|
+
AgentConfig,
|
|
9
11
|
BaseResponse,
|
|
10
12
|
ImageCreateResponse,
|
|
11
13
|
ImageGetResponse,
|
|
@@ -19,25 +21,21 @@ import type {
|
|
|
19
21
|
*/
|
|
20
22
|
export function createLocalImages(platform: AgentXPlatform): ImageNamespace {
|
|
21
23
|
return {
|
|
22
|
-
async create(params: {
|
|
23
|
-
containerId: string;
|
|
24
|
-
name?: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
systemPrompt?: string;
|
|
27
|
-
mcpServers?: Record<string, unknown>;
|
|
28
|
-
customData?: Record<string, unknown>;
|
|
29
|
-
}): Promise<ImageCreateResponse> {
|
|
24
|
+
async create(params: AgentConfig): Promise<ImageCreateResponse> {
|
|
30
25
|
const { imageRepository, sessionRepository } = platform;
|
|
31
26
|
const { createImage } = await import("@agentxjs/core/image");
|
|
32
27
|
|
|
28
|
+
const { model, systemPrompt, mcpServers, ...rest } = params;
|
|
29
|
+
const embody =
|
|
30
|
+
model || systemPrompt || mcpServers
|
|
31
|
+
? { model, systemPrompt, mcpServers: mcpServers as any }
|
|
32
|
+
: undefined;
|
|
33
|
+
|
|
33
34
|
const image = await createImage(
|
|
34
35
|
{
|
|
35
|
-
containerId:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
systemPrompt: params.systemPrompt,
|
|
39
|
-
mcpServers: params.mcpServers as any,
|
|
40
|
-
customData: params.customData,
|
|
36
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
37
|
+
...rest,
|
|
38
|
+
embody,
|
|
41
39
|
},
|
|
42
40
|
{ imageRepository, sessionRepository }
|
|
43
41
|
);
|
|
@@ -58,10 +56,8 @@ export function createLocalImages(platform: AgentXPlatform): ImageNamespace {
|
|
|
58
56
|
};
|
|
59
57
|
},
|
|
60
58
|
|
|
61
|
-
async list(
|
|
62
|
-
const records =
|
|
63
|
-
? await platform.imageRepository.findImagesByContainerId(containerId)
|
|
64
|
-
: await platform.imageRepository.findAllImages();
|
|
59
|
+
async list(): Promise<ImageListResponse> {
|
|
60
|
+
const records = await platform.imageRepository.findAllImages();
|
|
65
61
|
|
|
66
62
|
return {
|
|
67
63
|
records,
|
|
@@ -118,15 +114,11 @@ export function createRemoteImages(
|
|
|
118
114
|
subscribeFn: (sessionId: string) => void
|
|
119
115
|
): ImageNamespace {
|
|
120
116
|
return {
|
|
121
|
-
async create(params: {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
mcpServers?: Record<string, unknown>;
|
|
127
|
-
customData?: Record<string, unknown>;
|
|
128
|
-
}): Promise<ImageCreateResponse> {
|
|
129
|
-
const result = await rpcClient.call<ImageCreateResponse>("image.create", params);
|
|
117
|
+
async create(params: AgentConfig): Promise<ImageCreateResponse> {
|
|
118
|
+
const result = await rpcClient.call<ImageCreateResponse>("image.create", {
|
|
119
|
+
...params,
|
|
120
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
121
|
+
});
|
|
130
122
|
|
|
131
123
|
// Auto subscribe to session events
|
|
132
124
|
if (result.__subscriptions) {
|
|
@@ -151,8 +143,8 @@ export function createRemoteImages(
|
|
|
151
143
|
return { ...result, requestId: "" };
|
|
152
144
|
},
|
|
153
145
|
|
|
154
|
-
async list(
|
|
155
|
-
const result = await rpcClient.call<ImageListResponse>("image.list", {
|
|
146
|
+
async list(): Promise<ImageListResponse> {
|
|
147
|
+
const result = await rpcClient.call<ImageListResponse>("image.list", {});
|
|
156
148
|
|
|
157
149
|
// Auto subscribe
|
|
158
150
|
if (result.__subscriptions) {
|
package/src/namespaces/llm.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* LLM Provider namespace factories
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { DEFAULT_CONTAINER_ID } from "@agentxjs/core/container";
|
|
5
6
|
import type { RpcClient } from "@agentxjs/core/network";
|
|
6
7
|
import type { LLMProviderRecord } from "@agentxjs/core/persistence";
|
|
7
8
|
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
@@ -30,7 +31,7 @@ export function createLocalLLM(platform: AgentXPlatform): LLMNamespace {
|
|
|
30
31
|
const now = Date.now();
|
|
31
32
|
const record: LLMProviderRecord = {
|
|
32
33
|
id: generateId("llm"),
|
|
33
|
-
containerId:
|
|
34
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
34
35
|
name: params.name,
|
|
35
36
|
vendor: params.vendor,
|
|
36
37
|
protocol: params.protocol,
|
|
@@ -51,8 +52,8 @@ export function createLocalLLM(platform: AgentXPlatform): LLMNamespace {
|
|
|
51
52
|
return { record, requestId: "" };
|
|
52
53
|
},
|
|
53
54
|
|
|
54
|
-
async list(
|
|
55
|
-
const records = await repo.findLLMProvidersByContainerId(
|
|
55
|
+
async list(): Promise<LLMProviderListResponse> {
|
|
56
|
+
const records = await repo.findLLMProvidersByContainerId(DEFAULT_CONTAINER_ID);
|
|
56
57
|
return { records, requestId: "" };
|
|
57
58
|
},
|
|
58
59
|
|
|
@@ -85,8 +86,8 @@ export function createLocalLLM(platform: AgentXPlatform): LLMNamespace {
|
|
|
85
86
|
return { requestId: "" };
|
|
86
87
|
},
|
|
87
88
|
|
|
88
|
-
async getDefault(
|
|
89
|
-
const record = await repo.findDefaultLLMProvider(
|
|
89
|
+
async getDefault(): Promise<LLMProviderDefaultResponse> {
|
|
90
|
+
const record = await repo.findDefaultLLMProvider(DEFAULT_CONTAINER_ID);
|
|
90
91
|
return { record, requestId: "" };
|
|
91
92
|
},
|
|
92
93
|
};
|
|
@@ -98,7 +99,10 @@ export function createLocalLLM(platform: AgentXPlatform): LLMNamespace {
|
|
|
98
99
|
export function createRemoteLLM(rpcClient: RpcClient): LLMNamespace {
|
|
99
100
|
return {
|
|
100
101
|
async create(params): Promise<LLMProviderCreateResponse> {
|
|
101
|
-
const result = await rpcClient.call<LLMProviderCreateResponse>("llm.create",
|
|
102
|
+
const result = await rpcClient.call<LLMProviderCreateResponse>("llm.create", {
|
|
103
|
+
...params,
|
|
104
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
105
|
+
});
|
|
102
106
|
return { ...result, requestId: "" };
|
|
103
107
|
},
|
|
104
108
|
|
|
@@ -107,8 +111,10 @@ export function createRemoteLLM(rpcClient: RpcClient): LLMNamespace {
|
|
|
107
111
|
return { ...result, requestId: "" };
|
|
108
112
|
},
|
|
109
113
|
|
|
110
|
-
async list(
|
|
111
|
-
const result = await rpcClient.call<LLMProviderListResponse>("llm.list", {
|
|
114
|
+
async list(): Promise<LLMProviderListResponse> {
|
|
115
|
+
const result = await rpcClient.call<LLMProviderListResponse>("llm.list", {
|
|
116
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
117
|
+
});
|
|
112
118
|
return { ...result, requestId: "" };
|
|
113
119
|
},
|
|
114
120
|
|
|
@@ -130,9 +136,9 @@ export function createRemoteLLM(rpcClient: RpcClient): LLMNamespace {
|
|
|
130
136
|
return { ...result, requestId: "" };
|
|
131
137
|
},
|
|
132
138
|
|
|
133
|
-
async getDefault(
|
|
139
|
+
async getDefault(): Promise<LLMProviderDefaultResponse> {
|
|
134
140
|
const result = await rpcClient.call<LLMProviderDefaultResponse>("llm.default", {
|
|
135
|
-
containerId,
|
|
141
|
+
containerId: DEFAULT_CONTAINER_ID,
|
|
136
142
|
});
|
|
137
143
|
return { ...result, requestId: "" };
|
|
138
144
|
},
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { messagesToConversations, Presentation, type PresentationOptions } from "../presentation";
|
|
8
|
-
import type { AgentX,
|
|
8
|
+
import type { AgentX, PresentationNamespace, SessionNamespace } from "../types";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Create presentation namespace.
|
|
12
12
|
*
|
|
13
|
-
* Takes the full AgentX (for Presentation event wiring) and the
|
|
14
|
-
* (for message history
|
|
13
|
+
* Takes the full AgentX (for Presentation event wiring) and the SessionNamespace
|
|
14
|
+
* (for message history via instanceId).
|
|
15
15
|
*/
|
|
16
16
|
export function createPresentations(
|
|
17
17
|
agentx: AgentX,
|
|
18
|
-
|
|
18
|
+
sessionNs: SessionNamespace
|
|
19
19
|
): PresentationNamespace {
|
|
20
20
|
return {
|
|
21
|
-
async create(
|
|
22
|
-
const messages = await
|
|
21
|
+
async create(instanceId: string, options?: PresentationOptions): Promise<Presentation> {
|
|
22
|
+
const messages = await sessionNs.getMessages(instanceId);
|
|
23
23
|
const conversations = messagesToConversations(messages);
|
|
24
|
-
return new Presentation(agentx,
|
|
24
|
+
return new Presentation(agentx, instanceId, options, conversations);
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
}
|