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/{chunk-NPRCFKO5.js → chunk-JUZULVWQ.js} +33 -297
- package/dist/chunk-JUZULVWQ.js.map +1 -0
- package/dist/index.d.ts +36 -266
- package/dist/index.js +42 -224
- 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 +9 -7
- package/src/CommandHandler.ts +48 -163
- package/src/LocalClient.ts +3 -33
- package/src/RemoteClient.ts +2 -27
- package/src/index.ts +7 -21
- package/src/namespaces/agents.ts +4 -4
- package/src/namespaces/images.ts +21 -29
- package/src/namespaces/llm.ts +16 -10
- package/src/types.ts +44 -186
- package/dist/chunk-NPRCFKO5.js.map +0 -1
- package/dist/server-3BCYHXYA.js +0 -7
- package/dist/server-3BCYHXYA.js.map +0 -1
- package/src/namespaces/containers.ts +0 -68
- package/src/namespaces/prototypes.ts +0 -136
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Container namespace factories
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RpcClient } from "@agentxjs/core/network";
|
|
6
|
-
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
7
|
-
import type {
|
|
8
|
-
ContainerCreateResponse,
|
|
9
|
-
ContainerGetResponse,
|
|
10
|
-
ContainerListResponse,
|
|
11
|
-
ContainerNamespace,
|
|
12
|
-
} from "../types";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Create local container namespace backed by embedded runtime
|
|
16
|
-
*/
|
|
17
|
-
export function createLocalContainers(platform: AgentXPlatform): ContainerNamespace {
|
|
18
|
-
return {
|
|
19
|
-
async create(containerId: string): Promise<ContainerCreateResponse> {
|
|
20
|
-
const { getOrCreateContainer } = await import("@agentxjs/core/container");
|
|
21
|
-
const { containerRepository, imageRepository, sessionRepository } = platform;
|
|
22
|
-
|
|
23
|
-
const container = await getOrCreateContainer(containerId, {
|
|
24
|
-
containerRepository,
|
|
25
|
-
imageRepository,
|
|
26
|
-
sessionRepository,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return { containerId: container.containerId, requestId: "" };
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
async get(containerId: string): Promise<ContainerGetResponse> {
|
|
33
|
-
const exists = await platform.containerRepository.containerExists(containerId);
|
|
34
|
-
return { containerId, exists, requestId: "" };
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
async list(): Promise<ContainerListResponse> {
|
|
38
|
-
const containers = await platform.containerRepository.findAllContainers();
|
|
39
|
-
return { containerIds: containers.map((c) => c.containerId), requestId: "" };
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Create remote container namespace backed by RPC client
|
|
46
|
-
*/
|
|
47
|
-
export function createRemoteContainers(rpcClient: RpcClient): ContainerNamespace {
|
|
48
|
-
return {
|
|
49
|
-
async create(containerId: string): Promise<ContainerCreateResponse> {
|
|
50
|
-
const result = await rpcClient.call<ContainerCreateResponse>("container.create", {
|
|
51
|
-
containerId,
|
|
52
|
-
});
|
|
53
|
-
return { ...result, requestId: "" };
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
async get(containerId: string): Promise<ContainerGetResponse> {
|
|
57
|
-
const result = await rpcClient.call<ContainerGetResponse>("container.get", {
|
|
58
|
-
containerId,
|
|
59
|
-
});
|
|
60
|
-
return { ...result, requestId: "" };
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
async list(): Promise<ContainerListResponse> {
|
|
64
|
-
const result = await rpcClient.call<ContainerListResponse>("container.list", {});
|
|
65
|
-
return { ...result, requestId: "" };
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prototype namespace factories
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RpcClient } from "@agentxjs/core/network";
|
|
6
|
-
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
7
|
-
import type {
|
|
8
|
-
BaseResponse,
|
|
9
|
-
PrototypeCreateResponse,
|
|
10
|
-
PrototypeGetResponse,
|
|
11
|
-
PrototypeListResponse,
|
|
12
|
-
PrototypeNamespace,
|
|
13
|
-
PrototypeUpdateResponse,
|
|
14
|
-
} from "../types";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create local prototype namespace backed by embedded runtime
|
|
18
|
-
*/
|
|
19
|
-
export function createLocalPrototypes(platform: AgentXPlatform): PrototypeNamespace {
|
|
20
|
-
return {
|
|
21
|
-
async create(params): Promise<PrototypeCreateResponse> {
|
|
22
|
-
const repo = platform.prototypeRepository;
|
|
23
|
-
if (!repo) {
|
|
24
|
-
throw new Error("Prototype repository not available");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const now = Date.now();
|
|
28
|
-
const random = Math.random().toString(36).slice(2, 8);
|
|
29
|
-
const record = {
|
|
30
|
-
prototypeId: `proto_${now}_${random}`,
|
|
31
|
-
containerId: params.containerId,
|
|
32
|
-
name: params.name,
|
|
33
|
-
description: params.description,
|
|
34
|
-
contextId: params.contextId,
|
|
35
|
-
embody: params.embody,
|
|
36
|
-
customData: params.customData,
|
|
37
|
-
createdAt: now,
|
|
38
|
-
updatedAt: now,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
await repo.savePrototype(record);
|
|
42
|
-
return { record, requestId: "" };
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
async get(prototypeId: string): Promise<PrototypeGetResponse> {
|
|
46
|
-
const repo = platform.prototypeRepository;
|
|
47
|
-
if (!repo) {
|
|
48
|
-
throw new Error("Prototype repository not available");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const record = await repo.findPrototypeById(prototypeId);
|
|
52
|
-
return { record, requestId: "" };
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
async list(containerId?: string): Promise<PrototypeListResponse> {
|
|
56
|
-
const repo = platform.prototypeRepository;
|
|
57
|
-
if (!repo) {
|
|
58
|
-
throw new Error("Prototype repository not available");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const records = containerId
|
|
62
|
-
? await repo.findPrototypesByContainerId(containerId)
|
|
63
|
-
: await repo.findAllPrototypes();
|
|
64
|
-
|
|
65
|
-
return { records, requestId: "" };
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
async update(prototypeId, updates): Promise<PrototypeUpdateResponse> {
|
|
69
|
-
const repo = platform.prototypeRepository;
|
|
70
|
-
if (!repo) {
|
|
71
|
-
throw new Error("Prototype repository not available");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const existing = await repo.findPrototypeById(prototypeId);
|
|
75
|
-
if (!existing) {
|
|
76
|
-
throw new Error(`Prototype not found: ${prototypeId}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const { embody: embodyUpdates, ...otherUpdates } = updates;
|
|
80
|
-
const updatedRecord = {
|
|
81
|
-
...existing,
|
|
82
|
-
...otherUpdates,
|
|
83
|
-
embody: embodyUpdates ? { ...existing.embody, ...embodyUpdates } : existing.embody,
|
|
84
|
-
updatedAt: Date.now(),
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
await repo.savePrototype(updatedRecord);
|
|
88
|
-
return { record: updatedRecord, requestId: "" };
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
async delete(prototypeId: string): Promise<BaseResponse> {
|
|
92
|
-
const repo = platform.prototypeRepository;
|
|
93
|
-
if (!repo) {
|
|
94
|
-
throw new Error("Prototype repository not available");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
await repo.deletePrototype(prototypeId);
|
|
98
|
-
return { requestId: "" };
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Create remote prototype namespace backed by RPC client
|
|
105
|
-
*/
|
|
106
|
-
export function createRemotePrototypes(rpcClient: RpcClient): PrototypeNamespace {
|
|
107
|
-
return {
|
|
108
|
-
async create(params): Promise<PrototypeCreateResponse> {
|
|
109
|
-
const result = await rpcClient.call<PrototypeCreateResponse>("prototype.create", params);
|
|
110
|
-
return { ...result, requestId: "" };
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
async get(prototypeId: string): Promise<PrototypeGetResponse> {
|
|
114
|
-
const result = await rpcClient.call<PrototypeGetResponse>("prototype.get", { prototypeId });
|
|
115
|
-
return { ...result, requestId: "" };
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
async list(containerId?: string): Promise<PrototypeListResponse> {
|
|
119
|
-
const result = await rpcClient.call<PrototypeListResponse>("prototype.list", { containerId });
|
|
120
|
-
return { ...result, requestId: "" };
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
async update(prototypeId, updates): Promise<PrototypeUpdateResponse> {
|
|
124
|
-
const result = await rpcClient.call<PrototypeUpdateResponse>("prototype.update", {
|
|
125
|
-
prototypeId,
|
|
126
|
-
updates,
|
|
127
|
-
});
|
|
128
|
-
return { ...result, requestId: "" };
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
async delete(prototypeId: string): Promise<BaseResponse> {
|
|
132
|
-
const result = await rpcClient.call<BaseResponse>("prototype.delete", { prototypeId });
|
|
133
|
-
return { ...result, requestId: "" };
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
}
|