Omnichain smart agents automatically manage liquidity across markets." class="mx-auto">
1use talus::agent::{AgentName, AgentBlueprint};
2use talus::task::TaskBlueprint;
3
4// === Data models ===
5
6/// An object that holds a cluster definition.
7public struct Cluster has key, store {
8 id: UID,
9 blueprint: ClusterBlueprint,
10}
11
12/// Usually an owned object that permissions operations on the [`Cluster`].
13public struct ClusterOwnerCap has key, store {
14 id: UID,
15 cluster: ID,
16}
17
18/// Blueprint for execution.
19public struct ClusterBlueprint has store, copy, drop {
20 name: String,
21 description: String,
22 tasks: vector<TaskBlueprint>,
23 agents: VecMap<AgentName, AgentBlueprint>,
24}
25
26// === Constructors ===
27
28/// Create an empty [`Cluster`] shared object.
29/// The tx sender gets an owned object [`ClusterOwnerCap`] that allows them to
30/// modify the cluster.
31public entry fun create(
32 name: String,
33 description: String,
34 ctx: &mut TxContext
35) {
36 let cluster = Cluster {
37 id: object::new(ctx),
38 blueprint: ClusterBlueprint {
39 name,
40 description,
41 agents: vec_map::empty(),
42 tasks: vector::empty(),
43 }
44 };
45
46 let owner_cap = ClusterOwnerCap {
47 id: object::new(ctx),
48 cluster: object::id(&cluster),
49 };
50
51 event::emit(ClusterCreatedEvent {
52 cluster: object::id(&cluster),
53 owner_cap: object::id(&owner_cap),
54 });
55
56 transfer::share_object(cluster);
57 transfer::transfer(owner_cap, ctx.sender());
58}
59