agentxjs 2.7.0 → 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/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
- CommandHandler,
3
- createServer
4
- } from "./chunk-NPRCFKO5.js";
2
+ CommandHandler
3
+ } from "./chunk-JUZULVWQ.js";
5
4
 
6
5
  // src/index.ts
7
6
  import { createAgentXRuntime } from "@agentxjs/core/runtime";
@@ -84,8 +83,8 @@ function createLocalInstances(runtime) {
84
83
  requestId: ""
85
84
  };
86
85
  },
87
- async list(containerId) {
88
- const agents = containerId ? runtime.getAgentsByContainer(containerId) : runtime.getAgents();
86
+ async list() {
87
+ const agents = runtime.getAgents();
89
88
  return {
90
89
  agents: agents.map((a) => ({
91
90
  instanceId: a.instanceId,
@@ -119,8 +118,8 @@ function createRemoteInstances(rpcClient) {
119
118
  const result = await rpcClient.call("instance.get", { instanceId });
120
119
  return { ...result, requestId: "" };
121
120
  },
122
- async list(containerId) {
123
- const result = await rpcClient.call("instance.list", { containerId });
121
+ async list() {
122
+ const result = await rpcClient.call("instance.list", {});
124
123
  return { ...result, requestId: "" };
125
124
  },
126
125
  async destroy(instanceId) {
@@ -130,64 +129,20 @@ function createRemoteInstances(rpcClient) {
130
129
  };
131
130
  }
132
131
 
133
- // src/namespaces/containers.ts
134
- function createLocalContainers(platform) {
135
- return {
136
- async create(containerId) {
137
- const { getOrCreateContainer } = await import("@agentxjs/core/container");
138
- const { containerRepository, imageRepository, sessionRepository } = platform;
139
- const container = await getOrCreateContainer(containerId, {
140
- containerRepository,
141
- imageRepository,
142
- sessionRepository
143
- });
144
- return { containerId: container.containerId, requestId: "" };
145
- },
146
- async get(containerId) {
147
- const exists = await platform.containerRepository.containerExists(containerId);
148
- return { containerId, exists, requestId: "" };
149
- },
150
- async list() {
151
- const containers = await platform.containerRepository.findAllContainers();
152
- return { containerIds: containers.map((c) => c.containerId), requestId: "" };
153
- }
154
- };
155
- }
156
- function createRemoteContainers(rpcClient) {
157
- return {
158
- async create(containerId) {
159
- const result = await rpcClient.call("container.create", {
160
- containerId
161
- });
162
- return { ...result, requestId: "" };
163
- },
164
- async get(containerId) {
165
- const result = await rpcClient.call("container.get", {
166
- containerId
167
- });
168
- return { ...result, requestId: "" };
169
- },
170
- async list() {
171
- const result = await rpcClient.call("container.list", {});
172
- return { ...result, requestId: "" };
173
- }
174
- };
175
- }
176
-
177
132
  // src/namespaces/images.ts
133
+ import { DEFAULT_CONTAINER_ID } from "@agentxjs/core/container";
178
134
  function createLocalImages(platform) {
179
135
  return {
180
136
  async create(params) {
181
137
  const { imageRepository, sessionRepository } = platform;
182
138
  const { createImage } = await import("@agentxjs/core/image");
139
+ const { model, systemPrompt, mcpServers, ...rest } = params;
140
+ const embody = model || systemPrompt || mcpServers ? { model, systemPrompt, mcpServers } : void 0;
183
141
  const image = await createImage(
184
142
  {
185
- containerId: params.containerId,
186
- name: params.name,
187
- description: params.description,
188
- systemPrompt: params.systemPrompt,
189
- mcpServers: params.mcpServers,
190
- customData: params.customData
143
+ containerId: DEFAULT_CONTAINER_ID,
144
+ ...rest,
145
+ embody
191
146
  },
192
147
  { imageRepository, sessionRepository }
193
148
  );
@@ -205,8 +160,8 @@ function createLocalImages(platform) {
205
160
  requestId: ""
206
161
  };
207
162
  },
208
- async list(containerId) {
209
- const records = containerId ? await platform.imageRepository.findImagesByContainerId(containerId) : await platform.imageRepository.findAllImages();
163
+ async list() {
164
+ const records = await platform.imageRepository.findAllImages();
210
165
  return {
211
166
  records,
212
167
  __subscriptions: records.map((r) => r.sessionId),
@@ -242,7 +197,10 @@ function createLocalImages(platform) {
242
197
  function createRemoteImages(rpcClient, subscribeFn) {
243
198
  return {
244
199
  async create(params) {
245
- const result = await rpcClient.call("image.create", params);
200
+ const result = await rpcClient.call("image.create", {
201
+ ...params,
202
+ containerId: DEFAULT_CONTAINER_ID
203
+ });
246
204
  if (result.__subscriptions) {
247
205
  for (const sessionId of result.__subscriptions) {
248
206
  subscribeFn(sessionId);
@@ -259,8 +217,8 @@ function createRemoteImages(rpcClient, subscribeFn) {
259
217
  }
260
218
  return { ...result, requestId: "" };
261
219
  },
262
- async list(containerId) {
263
- const result = await rpcClient.call("image.list", { containerId });
220
+ async list() {
221
+ const result = await rpcClient.call("image.list", {});
264
222
  if (result.__subscriptions) {
265
223
  for (const sessionId of result.__subscriptions) {
266
224
  subscribeFn(sessionId);
@@ -287,6 +245,7 @@ function createRemoteImages(rpcClient, subscribeFn) {
287
245
  }
288
246
 
289
247
  // src/namespaces/llm.ts
248
+ import { DEFAULT_CONTAINER_ID as DEFAULT_CONTAINER_ID2 } from "@agentxjs/core/container";
290
249
  import { generateId } from "@deepracticex/id";
291
250
  function createLocalLLM(platform) {
292
251
  const repo = platform.llmProviderRepository;
@@ -298,7 +257,7 @@ function createLocalLLM(platform) {
298
257
  const now = Date.now();
299
258
  const record = {
300
259
  id: generateId("llm"),
301
- containerId: params.containerId,
260
+ containerId: DEFAULT_CONTAINER_ID2,
302
261
  name: params.name,
303
262
  vendor: params.vendor,
304
263
  protocol: params.protocol,
@@ -316,8 +275,8 @@ function createLocalLLM(platform) {
316
275
  const record = await repo.findLLMProviderById(id);
317
276
  return { record, requestId: "" };
318
277
  },
319
- async list(containerId) {
320
- const records = await repo.findLLMProvidersByContainerId(containerId);
278
+ async list() {
279
+ const records = await repo.findLLMProvidersByContainerId(DEFAULT_CONTAINER_ID2);
321
280
  return { records, requestId: "" };
322
281
  },
323
282
  async update(id, updates) {
@@ -344,8 +303,8 @@ function createLocalLLM(platform) {
344
303
  await repo.setDefaultLLMProvider(id);
345
304
  return { requestId: "" };
346
305
  },
347
- async getDefault(containerId) {
348
- const record = await repo.findDefaultLLMProvider(containerId);
306
+ async getDefault() {
307
+ const record = await repo.findDefaultLLMProvider(DEFAULT_CONTAINER_ID2);
349
308
  return { record, requestId: "" };
350
309
  }
351
310
  };
@@ -353,15 +312,20 @@ function createLocalLLM(platform) {
353
312
  function createRemoteLLM(rpcClient) {
354
313
  return {
355
314
  async create(params) {
356
- const result = await rpcClient.call("llm.create", params);
315
+ const result = await rpcClient.call("llm.create", {
316
+ ...params,
317
+ containerId: DEFAULT_CONTAINER_ID2
318
+ });
357
319
  return { ...result, requestId: "" };
358
320
  },
359
321
  async get(id) {
360
322
  const result = await rpcClient.call("llm.get", { id });
361
323
  return { ...result, requestId: "" };
362
324
  },
363
- async list(containerId) {
364
- const result = await rpcClient.call("llm.list", { containerId });
325
+ async list() {
326
+ const result = await rpcClient.call("llm.list", {
327
+ containerId: DEFAULT_CONTAINER_ID2
328
+ });
365
329
  return { ...result, requestId: "" };
366
330
  },
367
331
  async update(id, updates) {
@@ -379,9 +343,9 @@ function createRemoteLLM(rpcClient) {
379
343
  const result = await rpcClient.call("llm.default", { id });
380
344
  return { ...result, requestId: "" };
381
345
  },
382
- async getDefault(containerId) {
346
+ async getDefault() {
383
347
  const result = await rpcClient.call("llm.default", {
384
- containerId
348
+ containerId: DEFAULT_CONTAINER_ID2
385
349
  });
386
350
  return { ...result, requestId: "" };
387
351
  }
@@ -819,103 +783,6 @@ function createPresentations(agentx, sessionNs) {
819
783
  };
820
784
  }
821
785
 
822
- // src/namespaces/prototypes.ts
823
- function createLocalPrototypes(platform) {
824
- return {
825
- async create(params) {
826
- const repo = platform.prototypeRepository;
827
- if (!repo) {
828
- throw new Error("Prototype repository not available");
829
- }
830
- const now = Date.now();
831
- const random = Math.random().toString(36).slice(2, 8);
832
- const record = {
833
- prototypeId: `proto_${now}_${random}`,
834
- containerId: params.containerId,
835
- name: params.name,
836
- description: params.description,
837
- contextId: params.contextId,
838
- embody: params.embody,
839
- customData: params.customData,
840
- createdAt: now,
841
- updatedAt: now
842
- };
843
- await repo.savePrototype(record);
844
- return { record, requestId: "" };
845
- },
846
- async get(prototypeId) {
847
- const repo = platform.prototypeRepository;
848
- if (!repo) {
849
- throw new Error("Prototype repository not available");
850
- }
851
- const record = await repo.findPrototypeById(prototypeId);
852
- return { record, requestId: "" };
853
- },
854
- async list(containerId) {
855
- const repo = platform.prototypeRepository;
856
- if (!repo) {
857
- throw new Error("Prototype repository not available");
858
- }
859
- const records = containerId ? await repo.findPrototypesByContainerId(containerId) : await repo.findAllPrototypes();
860
- return { records, requestId: "" };
861
- },
862
- async update(prototypeId, updates) {
863
- const repo = platform.prototypeRepository;
864
- if (!repo) {
865
- throw new Error("Prototype repository not available");
866
- }
867
- const existing = await repo.findPrototypeById(prototypeId);
868
- if (!existing) {
869
- throw new Error(`Prototype not found: ${prototypeId}`);
870
- }
871
- const { embody: embodyUpdates, ...otherUpdates } = updates;
872
- const updatedRecord = {
873
- ...existing,
874
- ...otherUpdates,
875
- embody: embodyUpdates ? { ...existing.embody, ...embodyUpdates } : existing.embody,
876
- updatedAt: Date.now()
877
- };
878
- await repo.savePrototype(updatedRecord);
879
- return { record: updatedRecord, requestId: "" };
880
- },
881
- async delete(prototypeId) {
882
- const repo = platform.prototypeRepository;
883
- if (!repo) {
884
- throw new Error("Prototype repository not available");
885
- }
886
- await repo.deletePrototype(prototypeId);
887
- return { requestId: "" };
888
- }
889
- };
890
- }
891
- function createRemotePrototypes(rpcClient) {
892
- return {
893
- async create(params) {
894
- const result = await rpcClient.call("prototype.create", params);
895
- return { ...result, requestId: "" };
896
- },
897
- async get(prototypeId) {
898
- const result = await rpcClient.call("prototype.get", { prototypeId });
899
- return { ...result, requestId: "" };
900
- },
901
- async list(containerId) {
902
- const result = await rpcClient.call("prototype.list", { containerId });
903
- return { ...result, requestId: "" };
904
- },
905
- async update(prototypeId, updates) {
906
- const result = await rpcClient.call("prototype.update", {
907
- prototypeId,
908
- updates
909
- });
910
- return { ...result, requestId: "" };
911
- },
912
- async delete(prototypeId) {
913
- const result = await rpcClient.call("prototype.delete", { prototypeId });
914
- return { ...result, requestId: "" };
915
- }
916
- };
917
- }
918
-
919
786
  // src/namespaces/sessions.ts
920
787
  function createLocalSessions(runtime) {
921
788
  return {
@@ -969,20 +836,16 @@ var LocalClient = class {
969
836
  chat;
970
837
  runtime;
971
838
  provider;
972
- prototype;
973
839
  constructor(agentxRuntime) {
974
840
  this._runtime = agentxRuntime;
975
841
  const platform = agentxRuntime.platform;
976
- const container = createLocalContainers(platform);
977
842
  const image = createLocalImages(platform);
978
843
  const instance = createLocalInstances(agentxRuntime);
979
844
  const session = createLocalSessions(agentxRuntime);
980
845
  const llm = createLocalLLM(platform);
981
- const prototype = createLocalPrototypes(platform);
982
846
  const present = createPresentations(this, session);
983
- this.runtime = { container, image, instance, session, present, llm, prototype };
847
+ this.runtime = { image, instance, session, present, llm };
984
848
  this.provider = llm;
985
- this.prototype = prototype;
986
849
  this.chat = this.createChatNamespace();
987
850
  logger.info("LocalClient initialized");
988
851
  }
@@ -1024,25 +887,7 @@ var LocalClient = class {
1024
887
  const rt = this.runtime;
1025
888
  return {
1026
889
  async create(params) {
1027
- const containerId = "default";
1028
- let mergedParams = { ...params };
1029
- if (params.prototypeId) {
1030
- const protoRes = await rt.prototype.get(params.prototypeId);
1031
- if (protoRes.record) {
1032
- const proto = protoRes.record;
1033
- mergedParams = {
1034
- name: proto.name,
1035
- description: proto.description,
1036
- contextId: proto.contextId,
1037
- embody: proto.embody,
1038
- customData: proto.customData,
1039
- ...params
1040
- // inline params override prototype
1041
- };
1042
- }
1043
- }
1044
- const { prototypeId: _pid, ...imageParams } = mergedParams;
1045
- const imgRes = await rt.image.create({ containerId, ...imageParams });
890
+ const imgRes = await rt.image.create(params);
1046
891
  const instRes = await rt.instance.create({ imageId: imgRes.record.imageId });
1047
892
  return new AgentHandleImpl(
1048
893
  {
@@ -1097,7 +942,6 @@ var RemoteClient = class {
1097
942
  chat;
1098
943
  runtime;
1099
944
  provider;
1100
- prototype;
1101
945
  constructor(config) {
1102
946
  this.config = config;
1103
947
  this.eventBus = new EventBusImpl();
@@ -1113,16 +957,13 @@ var RemoteClient = class {
1113
957
  logger2.debug("Received stream event", { topic, type: event.type });
1114
958
  this.eventBus.emit(event);
1115
959
  });
1116
- const container = createRemoteContainers(this.rpcClient);
1117
960
  const image = createRemoteImages(this.rpcClient, (sessionId) => this.subscribe(sessionId));
1118
961
  const instance = createRemoteInstances(this.rpcClient);
1119
962
  const session = createRemoteSessions(this.rpcClient);
1120
963
  const llm = createRemoteLLM(this.rpcClient);
1121
- const prototype = createRemotePrototypes(this.rpcClient);
1122
964
  const present = createPresentations(this, session);
1123
- this.runtime = { container, image, instance, session, present, llm, prototype };
965
+ this.runtime = { image, instance, session, present, llm };
1124
966
  this.provider = llm;
1125
- this.prototype = prototype;
1126
967
  this.chat = this.createChatNamespace();
1127
968
  }
1128
969
  // ==================== Properties ====================
@@ -1172,25 +1013,7 @@ var RemoteClient = class {
1172
1013
  const rt = this.runtime;
1173
1014
  return {
1174
1015
  async create(params) {
1175
- const containerId = "default";
1176
- let mergedParams = { ...params };
1177
- if (params.prototypeId) {
1178
- const protoRes = await rt.prototype.get(params.prototypeId);
1179
- if (protoRes.record) {
1180
- const proto = protoRes.record;
1181
- mergedParams = {
1182
- name: proto.name,
1183
- description: proto.description,
1184
- contextId: proto.contextId,
1185
- embody: proto.embody,
1186
- customData: proto.customData,
1187
- ...params
1188
- // inline params override prototype
1189
- };
1190
- }
1191
- }
1192
- const { prototypeId: _pid, ...imageParams } = mergedParams;
1193
- const imgRes = await rt.image.create({ containerId, ...imageParams });
1016
+ const imgRes = await rt.image.create(params);
1194
1017
  const instRes = await rt.instance.create({ imageId: imgRes.record.imageId });
1195
1018
  return new AgentHandleImpl(
1196
1019
  {
@@ -1258,9 +1081,6 @@ function createAgentX(config) {
1258
1081
  get chat() {
1259
1082
  return getLocalClient().chat;
1260
1083
  },
1261
- get prototype() {
1262
- return getLocalClient().prototype;
1263
- },
1264
1084
  on(type, handler) {
1265
1085
  return getLocalClient().on(type, handler);
1266
1086
  },
@@ -1301,8 +1121,8 @@ function createAgentX(config) {
1301
1121
  "serve() requires platform.channelServer. Ensure your platform supports server mode."
1302
1122
  );
1303
1123
  }
1304
- const { createServer: createServer2 } = await import("./server-3BCYHXYA.js");
1305
- return createServer2({
1124
+ const { createServer } = await import("./server-MVOHQ5ZM.js");
1125
+ return createServer({
1306
1126
  platform: config.platform,
1307
1127
  createDriver: config.createDriver,
1308
1128
  port: serveConfig?.port,
@@ -1319,12 +1139,10 @@ function createAgentX(config) {
1319
1139
  export {
1320
1140
  AgentXError,
1321
1141
  AgentXErrorCode,
1322
- CommandHandler,
1323
1142
  Presentation,
1324
1143
  addUserConversation,
1325
1144
  createAgentX,
1326
1145
  createInitialState,
1327
- createServer,
1328
1146
  initialPresentationState,
1329
1147
  messagesToConversations,
1330
1148
  presentationReducer