@silvana-one/coordination 1.0.25 → 1.0.26

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.
Files changed (53) hide show
  1. package/dist/node/agent.d.ts +43 -15
  2. package/dist/node/agent.js +129 -31
  3. package/dist/node/agent.js.map +1 -1
  4. package/dist/node/app_instance.d.ts +58 -0
  5. package/dist/node/app_instance.js +203 -0
  6. package/dist/node/app_instance.js.map +1 -0
  7. package/dist/node/execute.d.ts +1 -0
  8. package/dist/node/execute.js +10 -2
  9. package/dist/node/execute.js.map +1 -1
  10. package/dist/node/index.cjs +750 -27
  11. package/dist/node/index.d.ts +4 -0
  12. package/dist/node/index.js +4 -0
  13. package/dist/node/index.js.map +1 -1
  14. package/dist/node/job.d.ts +57 -0
  15. package/dist/node/job.js +168 -0
  16. package/dist/node/job.js.map +1 -0
  17. package/dist/node/package.d.ts +1 -0
  18. package/dist/node/package.js +6 -0
  19. package/dist/node/package.js.map +1 -0
  20. package/dist/node/test.d.ts +48 -0
  21. package/dist/node/test.js +278 -0
  22. package/dist/node/test.js.map +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/tsconfig.web.tsbuildinfo +1 -1
  25. package/dist/web/agent.d.ts +43 -15
  26. package/dist/web/agent.js +129 -31
  27. package/dist/web/agent.js.map +1 -1
  28. package/dist/web/app_instance.d.ts +58 -0
  29. package/dist/web/app_instance.js +203 -0
  30. package/dist/web/app_instance.js.map +1 -0
  31. package/dist/web/execute.d.ts +1 -0
  32. package/dist/web/execute.js +10 -2
  33. package/dist/web/execute.js.map +1 -1
  34. package/dist/web/index.d.ts +4 -0
  35. package/dist/web/index.js +4 -0
  36. package/dist/web/index.js.map +1 -1
  37. package/dist/web/job.d.ts +57 -0
  38. package/dist/web/job.js +168 -0
  39. package/dist/web/job.js.map +1 -0
  40. package/dist/web/package.d.ts +1 -0
  41. package/dist/web/package.js +6 -0
  42. package/dist/web/package.js.map +1 -0
  43. package/dist/web/test.d.ts +48 -0
  44. package/dist/web/test.js +278 -0
  45. package/dist/web/test.js.map +1 -0
  46. package/package.json +5 -3
  47. package/src/agent.ts +204 -56
  48. package/src/app_instance.ts +264 -0
  49. package/src/execute.ts +11 -2
  50. package/src/index.ts +4 -0
  51. package/src/job.ts +223 -0
  52. package/src/package.ts +6 -0
  53. package/src/test.ts +383 -0
@@ -12,3 +12,7 @@ export * from "./walrus.js";
12
12
  export * from "./faucet.js";
13
13
  export * from "./ipfs.js";
14
14
  export * from "./public-key.js";
15
+ export * from "./job.js";
16
+ export * from "./app_instance.js";
17
+ export * from "./package.js";
18
+ export * from "./test.js";
@@ -12,4 +12,8 @@ export * from "./walrus.js";
12
12
  export * from "./faucet.js";
13
13
  export * from "./ipfs.js";
14
14
  export * from "./public-key.js";
15
+ export * from "./job.js";
16
+ export * from "./app_instance.js";
17
+ export * from "./package.js";
18
+ export * from "./test.js";
15
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ export type JobStatus = {
3
+ type: "Pending";
4
+ } | {
5
+ type: "Running";
6
+ } | {
7
+ type: "Failed";
8
+ error: string;
9
+ };
10
+ export interface Job {
11
+ id: string;
12
+ jobId: number;
13
+ description?: string;
14
+ developer: string;
15
+ agent: string;
16
+ agentMethod: string;
17
+ app: string;
18
+ appInstance: string;
19
+ appInstanceMethod: string;
20
+ sequences?: number[];
21
+ data: Uint8Array;
22
+ status: JobStatus;
23
+ attempts: number;
24
+ createdAt: number;
25
+ updatedAt: number;
26
+ }
27
+ export interface CreateJobParams {
28
+ jobs: string;
29
+ description?: string;
30
+ developer: string;
31
+ agent: string;
32
+ agentMethod: string;
33
+ app: string;
34
+ appInstance: string;
35
+ appInstanceMethod: string;
36
+ sequences?: number[];
37
+ data: Uint8Array;
38
+ }
39
+ export declare class JobManager {
40
+ private readonly jobs;
41
+ constructor(params: {
42
+ jobs: string;
43
+ });
44
+ static createJobs(maxAttempts?: number): Transaction;
45
+ createJob(params: CreateJobParams): Transaction;
46
+ startJob(jobId: number): Transaction;
47
+ completeJob(jobId: number): Transaction;
48
+ failJob(params: {
49
+ jobId: number;
50
+ error: string;
51
+ }): Transaction;
52
+ updateMaxAttempts(maxAttempts: number): Transaction;
53
+ getJob(jobId: number): Promise<Job | undefined>;
54
+ getPendingJobs(): Promise<number[]>;
55
+ getNextPendingJob(): Promise<number | undefined>;
56
+ getMaxAttempts(): Promise<number>;
57
+ }
@@ -0,0 +1,168 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
3
+ import { silvanaRegistryPackage } from "./package.js";
4
+ import { fetchSuiDynamicField, fetchSuiObject } from "./fetch.js";
5
+ export class JobManager {
6
+ constructor(params) {
7
+ this.jobs = params.jobs;
8
+ }
9
+ static createJobs(maxAttempts) {
10
+ const tx = new Transaction();
11
+ tx.moveCall({
12
+ target: `${silvanaRegistryPackage}::jobs::create_jobs`,
13
+ arguments: [
14
+ tx.pure.option("u8", maxAttempts ?? null),
15
+ ],
16
+ });
17
+ return tx;
18
+ }
19
+ createJob(params) {
20
+ const { description, developer, agent, agentMethod, app, appInstance, appInstanceMethod, sequences, data, } = params;
21
+ const tx = new Transaction();
22
+ tx.moveCall({
23
+ target: `${silvanaRegistryPackage}::jobs::create_job`,
24
+ arguments: [
25
+ tx.object(this.jobs),
26
+ tx.pure.option("string", description ?? null),
27
+ tx.pure.string(developer),
28
+ tx.pure.string(agent),
29
+ tx.pure.string(agentMethod),
30
+ tx.pure.string(app),
31
+ tx.pure.string(appInstance),
32
+ tx.pure.string(appInstanceMethod),
33
+ tx.pure.option("vector<u64>", sequences ?? null),
34
+ tx.pure.vector("u8", Array.from(data)),
35
+ tx.object(SUI_CLOCK_OBJECT_ID),
36
+ ],
37
+ });
38
+ return tx;
39
+ }
40
+ startJob(jobId) {
41
+ const tx = new Transaction();
42
+ tx.moveCall({
43
+ target: `${silvanaRegistryPackage}::jobs::start_job`,
44
+ arguments: [
45
+ tx.object(this.jobs),
46
+ tx.pure.u64(jobId),
47
+ tx.object(SUI_CLOCK_OBJECT_ID),
48
+ ],
49
+ });
50
+ return tx;
51
+ }
52
+ completeJob(jobId) {
53
+ const tx = new Transaction();
54
+ tx.moveCall({
55
+ target: `${silvanaRegistryPackage}::jobs::complete_job`,
56
+ arguments: [
57
+ tx.object(this.jobs),
58
+ tx.pure.u64(jobId),
59
+ ],
60
+ });
61
+ return tx;
62
+ }
63
+ failJob(params) {
64
+ const { jobId, error } = params;
65
+ const tx = new Transaction();
66
+ tx.moveCall({
67
+ target: `${silvanaRegistryPackage}::jobs::fail_job`,
68
+ arguments: [
69
+ tx.object(this.jobs),
70
+ tx.pure.u64(jobId),
71
+ tx.pure.string(error),
72
+ tx.object(SUI_CLOCK_OBJECT_ID),
73
+ ],
74
+ });
75
+ return tx;
76
+ }
77
+ updateMaxAttempts(maxAttempts) {
78
+ const tx = new Transaction();
79
+ tx.moveCall({
80
+ target: `${silvanaRegistryPackage}::jobs::update_max_attempts`,
81
+ arguments: [
82
+ tx.object(this.jobs),
83
+ tx.pure.u64(maxAttempts),
84
+ ],
85
+ });
86
+ return tx;
87
+ }
88
+ async getJob(jobId) {
89
+ try {
90
+ const jobsObject = await fetchSuiObject(this.jobs);
91
+ if (!jobsObject)
92
+ return undefined;
93
+ const jobsTableId = jobsObject?.jobs?.fields?.id?.id;
94
+ if (!jobsTableId)
95
+ return undefined;
96
+ const job = await fetchSuiDynamicField({
97
+ parentID: jobsTableId,
98
+ fieldName: "jobs",
99
+ type: "u64",
100
+ key: String(jobId),
101
+ });
102
+ if (!job)
103
+ return undefined;
104
+ const parseStatus = (status) => {
105
+ if (status?.Pending !== undefined)
106
+ return { type: "Pending" };
107
+ if (status?.Running !== undefined)
108
+ return { type: "Running" };
109
+ if (status?.Failed !== undefined)
110
+ return { type: "Failed", error: status.Failed };
111
+ return { type: "Pending" };
112
+ };
113
+ return {
114
+ id: job?.id?.id,
115
+ jobId: Number(job.job_id),
116
+ description: job?.description ?? undefined,
117
+ developer: job.developer,
118
+ agent: job.agent,
119
+ agentMethod: job.agent_method,
120
+ app: job.app,
121
+ appInstance: job.app_instance,
122
+ appInstanceMethod: job.app_instance_method,
123
+ sequences: job?.sequences?.map((s) => Number(s)) ?? undefined,
124
+ data: new Uint8Array(job.data),
125
+ status: parseStatus(job.status),
126
+ attempts: Number(job.attempts),
127
+ createdAt: Number(job.created_at),
128
+ updatedAt: Number(job.updated_at),
129
+ };
130
+ }
131
+ catch (error) {
132
+ console.error("Error fetching job:", error);
133
+ return undefined;
134
+ }
135
+ }
136
+ async getPendingJobs() {
137
+ try {
138
+ const jobsObject = await fetchSuiObject(this.jobs);
139
+ if (!jobsObject)
140
+ return [];
141
+ const pendingJobs = jobsObject?.pending_jobs?.fields?.contents;
142
+ if (!Array.isArray(pendingJobs))
143
+ return [];
144
+ return pendingJobs.map((id) => Number(id));
145
+ }
146
+ catch (error) {
147
+ console.error("Error fetching pending jobs:", error);
148
+ return [];
149
+ }
150
+ }
151
+ async getNextPendingJob() {
152
+ const pendingJobs = await this.getPendingJobs();
153
+ return pendingJobs.length > 0 ? pendingJobs[0] : undefined;
154
+ }
155
+ async getMaxAttempts() {
156
+ try {
157
+ const jobsObject = await fetchSuiObject(this.jobs);
158
+ if (!jobsObject)
159
+ return 3; // default value
160
+ return Number(jobsObject?.max_attempts ?? 3);
161
+ }
162
+ catch (error) {
163
+ console.error("Error fetching max attempts:", error);
164
+ return 3;
165
+ }
166
+ }
167
+ }
168
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAsClE,MAAM,OAAO,UAAU;IAGrB,YAAY,MAAwB;QAClC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,WAAoB;QACpC,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAC;QAC7B,EAAE,CAAC,QAAQ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AAkB,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC;YACxE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;gBAAE,OAAO,EAAE,CAAC;YAE3C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YACrD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,UAAU;gBAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB;YAE3C,OAAO,MAAM,CAAE,UAAkB,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YACrD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const silvanaRegistryPackage: string;
@@ -0,0 +1,6 @@
1
+ // Get Silvana registry package address from environment variables
2
+ // Compatible with both Node.js and Next.js environments
3
+ export const silvanaRegistryPackage = process.env.SILVANA_REGISTRY_PACKAGE ??
4
+ process.env.NEXT_PUBLIC_SILVANA_REGISTRY_PACKAGE ??
5
+ "@silvana/agent";
6
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,wDAAwD;AACxD,MAAM,CAAC,MAAM,sBAAsB,GACjC,OAAO,CAAC,GAAG,CAAC,wBAAwB;IACpC,OAAO,CAAC,GAAG,CAAC,oCAAoC;IAChD,gBAAgB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { AgentRegistry } from "./agent.js";
2
+ import { AppInstanceManager } from "./app_instance.js";
3
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
4
+ export interface TestRegistryConfig {
5
+ registryName?: string;
6
+ developerName?: string;
7
+ developerGithub?: string;
8
+ developerImage?: string;
9
+ developerDescription?: string;
10
+ developerSite?: string;
11
+ appName?: string;
12
+ appDescription?: string;
13
+ appImage?: string;
14
+ appSite?: string;
15
+ testAgentName?: string;
16
+ testAgentImage?: string;
17
+ testAgentChains?: string[];
18
+ }
19
+ export interface TestRegistryResult {
20
+ registryAddress: string;
21
+ developerName: string;
22
+ appName: string;
23
+ agentName?: string;
24
+ registry: AgentRegistry;
25
+ appInstanceManager: AppInstanceManager;
26
+ keyPair: Ed25519Keypair;
27
+ address: string;
28
+ }
29
+ export interface TestAppResult {
30
+ testAppAddress: string;
31
+ appInstanceAddress: string;
32
+ appInstanceCapAddress: string;
33
+ registryAddress: string;
34
+ appName: string;
35
+ keyPair: Ed25519Keypair;
36
+ address: string;
37
+ appInstanceManager: AppInstanceManager;
38
+ }
39
+ /**
40
+ * Creates a test Silvana Registry with a test developer, app, and optionally an agent
41
+ * This is a helper function for testing that sets up a complete test environment
42
+ */
43
+ export declare function createTestRegistry(config?: TestRegistryConfig): Promise<TestRegistryResult>;
44
+ /**
45
+ * Creates a TestApp with an initialized AppInstance using the new TestApp module
46
+ * This uses the create_test_app function from the Move contract
47
+ */
48
+ export declare function createTestApp(registryAddress: string, appName?: string): Promise<TestAppResult>;
@@ -0,0 +1,278 @@
1
+ import { AgentRegistry } from "./agent.js";
2
+ import { AppInstanceManager } from "./app_instance.js";
3
+ import { executeTx, waitTx } from "./execute.js";
4
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
5
+ import { Transaction } from "@mysten/sui/transactions";
6
+ /**
7
+ * Creates a test Silvana Registry with a test developer, app, and optionally an agent
8
+ * This is a helper function for testing that sets up a complete test environment
9
+ */
10
+ export async function createTestRegistry(config = {}) {
11
+ // Default values
12
+ const registryName = config.registryName ?? "Test Silvana Registry";
13
+ const developerName = config.developerName ?? "TestDev";
14
+ const developerGithub = config.developerGithub ?? "testdev";
15
+ const developerImage = config.developerImage;
16
+ const developerDescription = config.developerDescription ?? "Test developer for automated testing";
17
+ const developerSite = config.developerSite ?? "https://test.dev";
18
+ const appName = config.appName ?? "TestApp";
19
+ const appDescription = config.appDescription ?? "Test application for automated testing";
20
+ const appImage = config.appImage;
21
+ const appSite = config.appSite ?? "https://testapp.dev";
22
+ const testAgentName = config.testAgentName ?? "TestAgent";
23
+ const testAgentImage = config.testAgentImage;
24
+ const testAgentChains = config.testAgentChains ?? ["sui-testnet", "sui-devnet"];
25
+ // Get key from environment
26
+ const key = process.env.SUI_KEY;
27
+ if (!key) {
28
+ throw new Error("SUI_KEY is not set in environment");
29
+ }
30
+ const keyPair = Ed25519Keypair.fromSecretKey(key);
31
+ const address = keyPair.toSuiAddress();
32
+ console.log("Creating test registry with sender address:", address);
33
+ console.log("Chain:", process.env.SUI_CHAIN);
34
+ // Step 1: Create the registry
35
+ console.log("Step 1: Creating registry...");
36
+ const createRegistryTx = AgentRegistry.createAgentRegistry({
37
+ name: registryName,
38
+ });
39
+ createRegistryTx.setSender(address);
40
+ createRegistryTx.setGasBudget(100_000_000);
41
+ const registryResult = await executeTx({
42
+ tx: createRegistryTx,
43
+ keyPair,
44
+ });
45
+ if (!registryResult) {
46
+ throw new Error("Failed to create registry - no result");
47
+ }
48
+ if (registryResult.error) {
49
+ throw new Error(`Failed to create registry: ${registryResult.error}`);
50
+ }
51
+ if (!registryResult.tx?.objectChanges) {
52
+ throw new Error("Failed to create registry - no object changes");
53
+ }
54
+ // Find the created registry object
55
+ const registryObject = registryResult.tx.objectChanges.find((obj) => obj.type === "created" && obj.objectType?.includes("::registry::SilvanaRegistry"));
56
+ if (!registryObject || !('objectId' in registryObject)) {
57
+ throw new Error("Failed to find created registry object");
58
+ }
59
+ const registryAddress = registryObject.objectId;
60
+ console.log("Registry created with address:", registryAddress);
61
+ if (registryResult.digest) {
62
+ await waitTx(registryResult.digest);
63
+ }
64
+ // Create registry instance for further operations
65
+ const registry = new AgentRegistry({ registry: registryAddress });
66
+ const appInstanceManager = new AppInstanceManager({ registry: registryAddress });
67
+ // Step 2: Create developer
68
+ console.log("Step 2: Creating developer...");
69
+ const createDeveloperTx = registry.createDeveloper({
70
+ name: developerName,
71
+ github: developerGithub,
72
+ image: developerImage,
73
+ description: developerDescription,
74
+ site: developerSite,
75
+ });
76
+ createDeveloperTx.setSender(address);
77
+ createDeveloperTx.setGasBudget(100_000_000);
78
+ const developerResult = await executeTx({
79
+ tx: createDeveloperTx,
80
+ keyPair,
81
+ });
82
+ if (!developerResult) {
83
+ throw new Error("Failed to create developer - no result");
84
+ }
85
+ if (developerResult.error) {
86
+ throw new Error(`Failed to create developer: ${developerResult.error}`);
87
+ }
88
+ if (developerResult.digest) {
89
+ await waitTx(developerResult.digest);
90
+ }
91
+ console.log("Developer created:", developerName);
92
+ // Step 3: Create app (using registry::add_app)
93
+ console.log("Step 3: Creating app...");
94
+ const createAppTx = new Transaction();
95
+ createAppTx.moveCall({
96
+ target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::registry::add_app`,
97
+ arguments: [
98
+ createAppTx.object(registryAddress),
99
+ createAppTx.pure.string(appName),
100
+ createAppTx.pure.option("string", appDescription),
101
+ createAppTx.object("0x6"), // SUI_CLOCK_OBJECT_ID
102
+ ],
103
+ });
104
+ createAppTx.setSender(address);
105
+ createAppTx.setGasBudget(100_000_000);
106
+ const appResult = await executeTx({
107
+ tx: createAppTx,
108
+ keyPair,
109
+ });
110
+ if (!appResult) {
111
+ throw new Error("Failed to create app - no result");
112
+ }
113
+ if (appResult.error) {
114
+ throw new Error(`Failed to create app: ${appResult.error}`);
115
+ }
116
+ if (appResult.digest) {
117
+ await waitTx(appResult.digest);
118
+ }
119
+ console.log("App created:", appName);
120
+ // Step 4: Optionally create agent (if test agent name is provided with chains)
121
+ let agentName;
122
+ if (config.testAgentName && config.testAgentChains) {
123
+ console.log("Step 4: Creating agent...");
124
+ const createAgentTx = registry.createAgent({
125
+ developer: developerName,
126
+ name: testAgentName,
127
+ image: testAgentImage,
128
+ description: "Test agent for automated testing",
129
+ chains: testAgentChains,
130
+ });
131
+ createAgentTx.setSender(address);
132
+ createAgentTx.setGasBudget(100_000_000);
133
+ const agentResult = await executeTx({
134
+ tx: createAgentTx,
135
+ keyPair,
136
+ });
137
+ if (!agentResult) {
138
+ throw new Error("Failed to create agent - no result");
139
+ }
140
+ if (agentResult.error) {
141
+ throw new Error(`Failed to create agent: ${agentResult.error}`);
142
+ }
143
+ if (agentResult.digest) {
144
+ await waitTx(agentResult.digest);
145
+ }
146
+ agentName = testAgentName;
147
+ console.log("Agent created:", testAgentName);
148
+ }
149
+ console.log("Test registry setup complete!");
150
+ console.log("Registry address:", registryAddress);
151
+ console.log("Developer:", developerName);
152
+ console.log("App:", appName);
153
+ if (agentName) {
154
+ console.log("Agent:", agentName);
155
+ }
156
+ return {
157
+ registryAddress,
158
+ developerName,
159
+ appName,
160
+ agentName,
161
+ registry,
162
+ appInstanceManager,
163
+ keyPair,
164
+ address,
165
+ };
166
+ }
167
+ /**
168
+ * Creates a TestApp with an initialized AppInstance using the new TestApp module
169
+ * This uses the create_test_app function from the Move contract
170
+ */
171
+ export async function createTestApp(registryAddress, appName = "test_app") {
172
+ // Get key from environment
173
+ const key = process.env.SUI_KEY;
174
+ if (!key) {
175
+ throw new Error("SUI_KEY is not set in environment");
176
+ }
177
+ const keyPair = Ed25519Keypair.fromSecretKey(key);
178
+ const address = keyPair.toSuiAddress();
179
+ console.log("Creating TestApp with AppInstance...");
180
+ console.log("Registry address:", registryAddress);
181
+ console.log("Sender address:", address);
182
+ // First, check if the app already exists by trying to create it
183
+ // If it fails with "already exists" error, that's fine - we can continue
184
+ const createAppTx = new Transaction();
185
+ createAppTx.moveCall({
186
+ target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::registry::add_app`,
187
+ arguments: [
188
+ createAppTx.object(registryAddress),
189
+ createAppTx.pure.string(appName),
190
+ createAppTx.pure.option("string", "Test app for TestApp module"),
191
+ createAppTx.object("0x6"), // SUI_CLOCK_OBJECT_ID
192
+ ],
193
+ });
194
+ createAppTx.setSender(address);
195
+ createAppTx.setGasBudget(100_000_000);
196
+ const appResult = await executeTx({
197
+ tx: createAppTx,
198
+ keyPair,
199
+ showErrors: false, // Don't throw, we'll handle the error
200
+ });
201
+ if (appResult?.digest && !appResult.error) {
202
+ await waitTx(appResult.digest);
203
+ console.log("App created:", appName);
204
+ }
205
+ else if (appResult?.error?.includes("0) in command 0")) {
206
+ // Error code 0 from dynamic_field::add means the field already exists
207
+ console.log("App already exists, continuing:", appName);
208
+ }
209
+ else if (appResult?.error) {
210
+ throw new Error(`Failed to create app for TestApp: ${appResult.error}`);
211
+ }
212
+ // Call create_test_app to create a TestApp with an AppInstance
213
+ const tx = new Transaction();
214
+ tx.moveCall({
215
+ target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::test_app::create_test_app`,
216
+ arguments: [
217
+ tx.object(registryAddress),
218
+ tx.object("0x6"), // SUI_CLOCK_OBJECT_ID
219
+ ],
220
+ });
221
+ tx.setSender(address);
222
+ tx.setGasBudget(100_000_000);
223
+ const result = await executeTx({
224
+ tx,
225
+ keyPair,
226
+ });
227
+ if (!result) {
228
+ throw new Error("Failed to create TestApp - no result");
229
+ }
230
+ if (result.error) {
231
+ throw new Error(`Failed to create TestApp: ${result.error}`);
232
+ }
233
+ if (!result.tx) {
234
+ throw new Error("Failed to create TestApp - no transaction result");
235
+ }
236
+ // Wait for the transaction to be confirmed
237
+ if (result.digest) {
238
+ const confirmedTx = await waitTx(result.digest);
239
+ result.tx = confirmedTx;
240
+ }
241
+ if (!result?.tx?.objectChanges) {
242
+ throw new Error("Failed to create TestApp - no object changes");
243
+ }
244
+ // Find the created TestApp object (it will be shared)
245
+ const testAppObject = result.tx.objectChanges.find((obj) => obj.type === "created" &&
246
+ obj.objectType?.includes("::test_app::TestApp"));
247
+ if (!testAppObject || !('objectId' in testAppObject)) {
248
+ throw new Error("Failed to find created TestApp object");
249
+ }
250
+ // Find the created AppInstance object (it will be shared)
251
+ const appInstanceObject = result.tx.objectChanges.find((obj) => obj.type === "created" &&
252
+ obj.objectType?.includes("::app_instance::AppInstance"));
253
+ if (!appInstanceObject || !('objectId' in appInstanceObject)) {
254
+ throw new Error("Failed to find created AppInstance object");
255
+ }
256
+ const testAppAddress = testAppObject.objectId;
257
+ const appInstanceAddress = appInstanceObject.objectId;
258
+ // AppInstanceCap is stored inside the TestApp, not as a separate shared object
259
+ // We'll use the TestApp address as a placeholder since the cap is embedded
260
+ const appInstanceCapAddress = testAppAddress;
261
+ console.log("TestApp created:", testAppAddress);
262
+ console.log("AppInstance created:", appInstanceAddress);
263
+ console.log("AppInstanceCap created:", appInstanceCapAddress);
264
+ const appInstanceManager = new AppInstanceManager({ registry: registryAddress });
265
+ return {
266
+ testAppAddress,
267
+ appInstanceAddress,
268
+ appInstanceCapAddress,
269
+ registryAddress,
270
+ appName,
271
+ keyPair,
272
+ address,
273
+ appInstanceManager,
274
+ };
275
+ }
276
+ // Note: createTestAppInstance has been removed. Use createTestApp instead, which creates
277
+ // a TestApp with an embedded AppInstance using the Move test_app module.
278
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"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