@moltium/world-core 0.1.4 → 0.1.6
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.cjs +2195 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1234 -0
- package/dist/index.d.ts +1234 -0
- package/dist/index.js +2158 -0
- package/dist/index.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1234 @@
|
|
|
1
|
+
import { AgentCard } from '@a2a-js/sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import winston from 'winston';
|
|
4
|
+
import { Express } from 'express';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ============================================================================
|
|
8
|
+
* WORLD CONFIGURATION TYPES
|
|
9
|
+
* ============================================================================
|
|
10
|
+
*/
|
|
11
|
+
interface WorldConfig {
|
|
12
|
+
/** World name (unique identifier) */
|
|
13
|
+
name: string;
|
|
14
|
+
/** World description */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** World type (for plugin system) */
|
|
17
|
+
type?: string;
|
|
18
|
+
/** Server configuration */
|
|
19
|
+
server: {
|
|
20
|
+
port: number;
|
|
21
|
+
host: string;
|
|
22
|
+
};
|
|
23
|
+
/** A2A configuration for the world itself */
|
|
24
|
+
a2a?: {
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
pushNotifications?: boolean;
|
|
27
|
+
streaming?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Admission rules for agent entry */
|
|
30
|
+
admission: AdmissionRules;
|
|
31
|
+
/** Simulation configuration */
|
|
32
|
+
simulation?: {
|
|
33
|
+
/** Tick interval in milliseconds */
|
|
34
|
+
tickIntervalMs?: number;
|
|
35
|
+
/** Maximum ticks before auto-stop */
|
|
36
|
+
maxTicks?: number;
|
|
37
|
+
/** Auto-start simulation on world init */
|
|
38
|
+
autoStart?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Persistence configuration */
|
|
41
|
+
persistence?: PersistenceConfig;
|
|
42
|
+
/** Blockchain configuration */
|
|
43
|
+
blockchain?: BlockchainConfig;
|
|
44
|
+
/** Optional world token configuration */
|
|
45
|
+
token?: TokenConfig;
|
|
46
|
+
/** World-specific rules */
|
|
47
|
+
rules?: WorldRule[];
|
|
48
|
+
/** Pre-configured agent URLs to discover on startup */
|
|
49
|
+
agentUrls?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ============================================================================
|
|
53
|
+
* ADMISSION RULES
|
|
54
|
+
* ============================================================================
|
|
55
|
+
*/
|
|
56
|
+
interface AdmissionRules {
|
|
57
|
+
/** Maximum number of agents allowed */
|
|
58
|
+
maxAgents?: number;
|
|
59
|
+
/** Required skills (agent must have ALL of these) */
|
|
60
|
+
requiredSkills?: string[];
|
|
61
|
+
/** Required tags (agent must have AT LEAST ONE) */
|
|
62
|
+
requiredTags?: string[];
|
|
63
|
+
/** Minimum protocol version */
|
|
64
|
+
minProtocolVersion?: string;
|
|
65
|
+
/** Custom evaluator function */
|
|
66
|
+
customEvaluator?: (profile: AgentProfile) => Promise<AdmissionDecision>;
|
|
67
|
+
}
|
|
68
|
+
interface AdmissionDecision {
|
|
69
|
+
admitted: boolean;
|
|
70
|
+
reason?: string;
|
|
71
|
+
role?: string;
|
|
72
|
+
metadata?: Record<string, any>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* ============================================================================
|
|
76
|
+
* AGENT PROFILE
|
|
77
|
+
* ============================================================================
|
|
78
|
+
*/
|
|
79
|
+
interface AgentProfile {
|
|
80
|
+
/** Agent URL (canonical identifier from Agent Card) */
|
|
81
|
+
url: string;
|
|
82
|
+
/** Agent name */
|
|
83
|
+
name: string;
|
|
84
|
+
/** Protocol version */
|
|
85
|
+
protocolVersion: string;
|
|
86
|
+
/** Skills from Agent Card */
|
|
87
|
+
skills: Array<{
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
tags?: string[];
|
|
92
|
+
}>;
|
|
93
|
+
/** Capabilities */
|
|
94
|
+
capabilities: {
|
|
95
|
+
streaming: boolean;
|
|
96
|
+
pushNotifications: boolean;
|
|
97
|
+
stateTransitionHistory?: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** When agent joined the world */
|
|
100
|
+
joinedAt: number;
|
|
101
|
+
/** Assigned role (optional) */
|
|
102
|
+
role?: string;
|
|
103
|
+
/** Additional metadata */
|
|
104
|
+
metadata?: Record<string, any>;
|
|
105
|
+
/** Wallet address (for blockchain membership) */
|
|
106
|
+
walletAddress?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* ============================================================================
|
|
110
|
+
* WORLD STATE
|
|
111
|
+
* ============================================================================
|
|
112
|
+
*/
|
|
113
|
+
type WorldPhase = 'idle' | 'initializing' | 'ready' | 'running' | 'paused' | 'completed' | 'stopped' | 'failed';
|
|
114
|
+
interface WorldStateSnapshot {
|
|
115
|
+
phase: WorldPhase;
|
|
116
|
+
tick: number;
|
|
117
|
+
round: number;
|
|
118
|
+
timestamp: number;
|
|
119
|
+
metadata: Record<string, any>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* ============================================================================
|
|
123
|
+
* WORLD EVENTS
|
|
124
|
+
* ============================================================================
|
|
125
|
+
*/
|
|
126
|
+
interface WorldEvent {
|
|
127
|
+
id: string;
|
|
128
|
+
type: string;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
agentUrl?: string;
|
|
131
|
+
data?: Record<string, any>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* ============================================================================
|
|
135
|
+
* WORLD RULES
|
|
136
|
+
* ============================================================================
|
|
137
|
+
*/
|
|
138
|
+
interface WorldRule {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
evaluate: (context: RuleContext) => Promise<RuleViolation | null>;
|
|
143
|
+
}
|
|
144
|
+
interface RuleContext {
|
|
145
|
+
world: {
|
|
146
|
+
phase: WorldPhase;
|
|
147
|
+
tick: number;
|
|
148
|
+
agents: Map<string, AgentProfile>;
|
|
149
|
+
};
|
|
150
|
+
event?: WorldEvent;
|
|
151
|
+
agent?: AgentProfile;
|
|
152
|
+
}
|
|
153
|
+
interface RuleViolation {
|
|
154
|
+
ruleId: string;
|
|
155
|
+
severity: 'warning' | 'error' | 'critical';
|
|
156
|
+
message: string;
|
|
157
|
+
agentUrl?: string;
|
|
158
|
+
action?: 'warn' | 'kick' | 'pause_world';
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* ============================================================================
|
|
162
|
+
* PERSISTENCE CONFIGURATION
|
|
163
|
+
* ============================================================================
|
|
164
|
+
*/
|
|
165
|
+
interface PersistenceConfig {
|
|
166
|
+
type: 'memory' | 'postgres' | 'redis' | 'mongodb' | 'sqlite' | 'leveldb';
|
|
167
|
+
postgres?: {
|
|
168
|
+
host: string;
|
|
169
|
+
port?: number;
|
|
170
|
+
database: string;
|
|
171
|
+
user: string;
|
|
172
|
+
password: string;
|
|
173
|
+
ssl?: boolean;
|
|
174
|
+
max?: number;
|
|
175
|
+
};
|
|
176
|
+
redis?: {
|
|
177
|
+
host: string;
|
|
178
|
+
port?: number;
|
|
179
|
+
password?: string;
|
|
180
|
+
db?: number;
|
|
181
|
+
};
|
|
182
|
+
mongodb?: {
|
|
183
|
+
url: string;
|
|
184
|
+
database: string;
|
|
185
|
+
};
|
|
186
|
+
sqlite?: {
|
|
187
|
+
filename: string;
|
|
188
|
+
};
|
|
189
|
+
leveldb?: {
|
|
190
|
+
location: string;
|
|
191
|
+
};
|
|
192
|
+
/** Auto-save interval in milliseconds (default: 10000) */
|
|
193
|
+
autoSaveIntervalMs?: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* ============================================================================
|
|
197
|
+
* BLOCKCHAIN CONFIGURATION
|
|
198
|
+
* ============================================================================
|
|
199
|
+
*/
|
|
200
|
+
interface BlockchainConfig {
|
|
201
|
+
/** Monad RPC URL */
|
|
202
|
+
rpcUrl: string;
|
|
203
|
+
/** World owner's private key */
|
|
204
|
+
privateKey: string;
|
|
205
|
+
/** Entry fee in MON tokens */
|
|
206
|
+
entryFee: number;
|
|
207
|
+
/** Require NFT membership for participation (default: true) */
|
|
208
|
+
requireMembership?: boolean;
|
|
209
|
+
/** Enforce on-chain agent validation (default: false) */
|
|
210
|
+
enforceOnChainValidation?: boolean;
|
|
211
|
+
/** Contract addresses (filled after deployment) */
|
|
212
|
+
agentRegistryAddress?: string;
|
|
213
|
+
membershipContractAddress?: string;
|
|
214
|
+
worldTokenAddress?: string;
|
|
215
|
+
/** Chain ID */
|
|
216
|
+
chainId?: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* ============================================================================
|
|
220
|
+
* TOKEN CONFIGURATION
|
|
221
|
+
* ============================================================================
|
|
222
|
+
*/
|
|
223
|
+
interface TokenConfig {
|
|
224
|
+
/** Deploy custom world token */
|
|
225
|
+
deploy: boolean;
|
|
226
|
+
/** Token name */
|
|
227
|
+
name?: string;
|
|
228
|
+
/** Token symbol */
|
|
229
|
+
symbol?: string;
|
|
230
|
+
/** Initial supply */
|
|
231
|
+
initialSupply?: number;
|
|
232
|
+
/** Decimals */
|
|
233
|
+
decimals?: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* ============================================================================
|
|
237
|
+
* WORLD TYPE MODULE (for plugin system)
|
|
238
|
+
* ============================================================================
|
|
239
|
+
*/
|
|
240
|
+
interface WorldTypeModule {
|
|
241
|
+
name: string;
|
|
242
|
+
description: string;
|
|
243
|
+
defaultRules: WorldRule[];
|
|
244
|
+
defaultAdmissionRules: Partial<AdmissionRules>;
|
|
245
|
+
onInit?: (world: any) => Promise<void>;
|
|
246
|
+
onTick?: (world: any, tick: number) => Promise<void>;
|
|
247
|
+
onAgentJoin?: (world: any, agent: AgentProfile) => Promise<void>;
|
|
248
|
+
onAgentLeave?: (world: any, agent: AgentProfile) => Promise<void>;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* ============================================================================
|
|
252
|
+
* UTILITY TYPES
|
|
253
|
+
* ============================================================================
|
|
254
|
+
*/
|
|
255
|
+
interface EventFilter$1 {
|
|
256
|
+
type?: string;
|
|
257
|
+
agentUrl?: string;
|
|
258
|
+
fromTimestamp?: number;
|
|
259
|
+
toTimestamp?: number;
|
|
260
|
+
limit?: number;
|
|
261
|
+
}
|
|
262
|
+
/** Helper to build AgentProfile from AgentCard */
|
|
263
|
+
declare function profileFromCard(card: AgentCard, walletAddress?: string): AgentProfile;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* ============================================================================
|
|
267
|
+
* ZOD SCHEMAS FOR RUNTIME VALIDATION
|
|
268
|
+
* ============================================================================
|
|
269
|
+
*/
|
|
270
|
+
declare const AdmissionRulesSchema: z.ZodObject<{
|
|
271
|
+
maxAgents: z.ZodOptional<z.ZodNumber>;
|
|
272
|
+
requiredSkills: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
273
|
+
requiredTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
274
|
+
minProtocolVersion: z.ZodOptional<z.ZodString>;
|
|
275
|
+
customEvaluator: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
276
|
+
}, "strip", z.ZodTypeAny, {
|
|
277
|
+
maxAgents?: number | undefined;
|
|
278
|
+
requiredSkills?: string[] | undefined;
|
|
279
|
+
requiredTags?: string[] | undefined;
|
|
280
|
+
minProtocolVersion?: string | undefined;
|
|
281
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
282
|
+
}, {
|
|
283
|
+
maxAgents?: number | undefined;
|
|
284
|
+
requiredSkills?: string[] | undefined;
|
|
285
|
+
requiredTags?: string[] | undefined;
|
|
286
|
+
minProtocolVersion?: string | undefined;
|
|
287
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
288
|
+
}>;
|
|
289
|
+
declare const PersistenceConfigSchema: z.ZodObject<{
|
|
290
|
+
type: z.ZodEnum<["memory", "postgres", "redis", "mongodb", "sqlite", "leveldb"]>;
|
|
291
|
+
sqlite: z.ZodOptional<z.ZodObject<{
|
|
292
|
+
filename: z.ZodString;
|
|
293
|
+
memory: z.ZodOptional<z.ZodBoolean>;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
filename: string;
|
|
296
|
+
memory?: boolean | undefined;
|
|
297
|
+
}, {
|
|
298
|
+
filename: string;
|
|
299
|
+
memory?: boolean | undefined;
|
|
300
|
+
}>>;
|
|
301
|
+
postgres: z.ZodOptional<z.ZodObject<{
|
|
302
|
+
host: z.ZodString;
|
|
303
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
304
|
+
database: z.ZodString;
|
|
305
|
+
user: z.ZodString;
|
|
306
|
+
password: z.ZodString;
|
|
307
|
+
ssl: z.ZodOptional<z.ZodBoolean>;
|
|
308
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
309
|
+
}, "strip", z.ZodTypeAny, {
|
|
310
|
+
host: string;
|
|
311
|
+
database: string;
|
|
312
|
+
user: string;
|
|
313
|
+
password: string;
|
|
314
|
+
port?: number | undefined;
|
|
315
|
+
ssl?: boolean | undefined;
|
|
316
|
+
max?: number | undefined;
|
|
317
|
+
}, {
|
|
318
|
+
host: string;
|
|
319
|
+
database: string;
|
|
320
|
+
user: string;
|
|
321
|
+
password: string;
|
|
322
|
+
port?: number | undefined;
|
|
323
|
+
ssl?: boolean | undefined;
|
|
324
|
+
max?: number | undefined;
|
|
325
|
+
}>>;
|
|
326
|
+
redis: z.ZodOptional<z.ZodObject<{
|
|
327
|
+
host: z.ZodString;
|
|
328
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
329
|
+
password: z.ZodOptional<z.ZodString>;
|
|
330
|
+
db: z.ZodOptional<z.ZodNumber>;
|
|
331
|
+
keyPrefix: z.ZodOptional<z.ZodString>;
|
|
332
|
+
}, "strip", z.ZodTypeAny, {
|
|
333
|
+
host: string;
|
|
334
|
+
port?: number | undefined;
|
|
335
|
+
password?: string | undefined;
|
|
336
|
+
db?: number | undefined;
|
|
337
|
+
keyPrefix?: string | undefined;
|
|
338
|
+
}, {
|
|
339
|
+
host: string;
|
|
340
|
+
port?: number | undefined;
|
|
341
|
+
password?: string | undefined;
|
|
342
|
+
db?: number | undefined;
|
|
343
|
+
keyPrefix?: string | undefined;
|
|
344
|
+
}>>;
|
|
345
|
+
mongodb: z.ZodOptional<z.ZodObject<{
|
|
346
|
+
url: z.ZodString;
|
|
347
|
+
database: z.ZodString;
|
|
348
|
+
useUnifiedTopology: z.ZodOptional<z.ZodBoolean>;
|
|
349
|
+
}, "strip", z.ZodTypeAny, {
|
|
350
|
+
database: string;
|
|
351
|
+
url: string;
|
|
352
|
+
useUnifiedTopology?: boolean | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
database: string;
|
|
355
|
+
url: string;
|
|
356
|
+
useUnifiedTopology?: boolean | undefined;
|
|
357
|
+
}>>;
|
|
358
|
+
leveldb: z.ZodOptional<z.ZodObject<{
|
|
359
|
+
path: z.ZodString;
|
|
360
|
+
}, "strip", z.ZodTypeAny, {
|
|
361
|
+
path: string;
|
|
362
|
+
}, {
|
|
363
|
+
path: string;
|
|
364
|
+
}>>;
|
|
365
|
+
autoSaveIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
366
|
+
}, "strip", z.ZodTypeAny, {
|
|
367
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
368
|
+
postgres?: {
|
|
369
|
+
host: string;
|
|
370
|
+
database: string;
|
|
371
|
+
user: string;
|
|
372
|
+
password: string;
|
|
373
|
+
port?: number | undefined;
|
|
374
|
+
ssl?: boolean | undefined;
|
|
375
|
+
max?: number | undefined;
|
|
376
|
+
} | undefined;
|
|
377
|
+
redis?: {
|
|
378
|
+
host: string;
|
|
379
|
+
port?: number | undefined;
|
|
380
|
+
password?: string | undefined;
|
|
381
|
+
db?: number | undefined;
|
|
382
|
+
keyPrefix?: string | undefined;
|
|
383
|
+
} | undefined;
|
|
384
|
+
mongodb?: {
|
|
385
|
+
database: string;
|
|
386
|
+
url: string;
|
|
387
|
+
useUnifiedTopology?: boolean | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
sqlite?: {
|
|
390
|
+
filename: string;
|
|
391
|
+
memory?: boolean | undefined;
|
|
392
|
+
} | undefined;
|
|
393
|
+
leveldb?: {
|
|
394
|
+
path: string;
|
|
395
|
+
} | undefined;
|
|
396
|
+
autoSaveIntervalMs?: number | undefined;
|
|
397
|
+
}, {
|
|
398
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
399
|
+
postgres?: {
|
|
400
|
+
host: string;
|
|
401
|
+
database: string;
|
|
402
|
+
user: string;
|
|
403
|
+
password: string;
|
|
404
|
+
port?: number | undefined;
|
|
405
|
+
ssl?: boolean | undefined;
|
|
406
|
+
max?: number | undefined;
|
|
407
|
+
} | undefined;
|
|
408
|
+
redis?: {
|
|
409
|
+
host: string;
|
|
410
|
+
port?: number | undefined;
|
|
411
|
+
password?: string | undefined;
|
|
412
|
+
db?: number | undefined;
|
|
413
|
+
keyPrefix?: string | undefined;
|
|
414
|
+
} | undefined;
|
|
415
|
+
mongodb?: {
|
|
416
|
+
database: string;
|
|
417
|
+
url: string;
|
|
418
|
+
useUnifiedTopology?: boolean | undefined;
|
|
419
|
+
} | undefined;
|
|
420
|
+
sqlite?: {
|
|
421
|
+
filename: string;
|
|
422
|
+
memory?: boolean | undefined;
|
|
423
|
+
} | undefined;
|
|
424
|
+
leveldb?: {
|
|
425
|
+
path: string;
|
|
426
|
+
} | undefined;
|
|
427
|
+
autoSaveIntervalMs?: number | undefined;
|
|
428
|
+
}>;
|
|
429
|
+
declare const BlockchainConfigSchema: z.ZodObject<{
|
|
430
|
+
rpcUrl: z.ZodString;
|
|
431
|
+
privateKey: z.ZodString;
|
|
432
|
+
entryFee: z.ZodNumber;
|
|
433
|
+
requireMembership: z.ZodOptional<z.ZodBoolean>;
|
|
434
|
+
enforceOnChainValidation: z.ZodOptional<z.ZodBoolean>;
|
|
435
|
+
agentRegistryAddress: z.ZodOptional<z.ZodString>;
|
|
436
|
+
membershipContractAddress: z.ZodOptional<z.ZodString>;
|
|
437
|
+
worldTokenAddress: z.ZodOptional<z.ZodString>;
|
|
438
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
439
|
+
}, "strip", z.ZodTypeAny, {
|
|
440
|
+
rpcUrl: string;
|
|
441
|
+
privateKey: string;
|
|
442
|
+
entryFee: number;
|
|
443
|
+
requireMembership?: boolean | undefined;
|
|
444
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
445
|
+
agentRegistryAddress?: string | undefined;
|
|
446
|
+
membershipContractAddress?: string | undefined;
|
|
447
|
+
worldTokenAddress?: string | undefined;
|
|
448
|
+
chainId?: number | undefined;
|
|
449
|
+
}, {
|
|
450
|
+
rpcUrl: string;
|
|
451
|
+
privateKey: string;
|
|
452
|
+
entryFee: number;
|
|
453
|
+
requireMembership?: boolean | undefined;
|
|
454
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
455
|
+
agentRegistryAddress?: string | undefined;
|
|
456
|
+
membershipContractAddress?: string | undefined;
|
|
457
|
+
worldTokenAddress?: string | undefined;
|
|
458
|
+
chainId?: number | undefined;
|
|
459
|
+
}>;
|
|
460
|
+
declare const TokenConfigSchema: z.ZodObject<{
|
|
461
|
+
deploy: z.ZodBoolean;
|
|
462
|
+
name: z.ZodOptional<z.ZodString>;
|
|
463
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
464
|
+
initialSupply: z.ZodOptional<z.ZodNumber>;
|
|
465
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
466
|
+
}, "strip", z.ZodTypeAny, {
|
|
467
|
+
deploy: boolean;
|
|
468
|
+
symbol?: string | undefined;
|
|
469
|
+
name?: string | undefined;
|
|
470
|
+
initialSupply?: number | undefined;
|
|
471
|
+
decimals?: number | undefined;
|
|
472
|
+
}, {
|
|
473
|
+
deploy: boolean;
|
|
474
|
+
symbol?: string | undefined;
|
|
475
|
+
name?: string | undefined;
|
|
476
|
+
initialSupply?: number | undefined;
|
|
477
|
+
decimals?: number | undefined;
|
|
478
|
+
}>;
|
|
479
|
+
declare const WorldConfigSchema: z.ZodObject<{
|
|
480
|
+
name: z.ZodString;
|
|
481
|
+
description: z.ZodOptional<z.ZodString>;
|
|
482
|
+
type: z.ZodOptional<z.ZodString>;
|
|
483
|
+
server: z.ZodObject<{
|
|
484
|
+
port: z.ZodNumber;
|
|
485
|
+
host: z.ZodString;
|
|
486
|
+
}, "strip", z.ZodTypeAny, {
|
|
487
|
+
host: string;
|
|
488
|
+
port: number;
|
|
489
|
+
}, {
|
|
490
|
+
host: string;
|
|
491
|
+
port: number;
|
|
492
|
+
}>;
|
|
493
|
+
a2a: z.ZodOptional<z.ZodObject<{
|
|
494
|
+
baseUrl: z.ZodString;
|
|
495
|
+
pushNotifications: z.ZodOptional<z.ZodBoolean>;
|
|
496
|
+
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
497
|
+
}, "strip", z.ZodTypeAny, {
|
|
498
|
+
baseUrl: string;
|
|
499
|
+
pushNotifications?: boolean | undefined;
|
|
500
|
+
streaming?: boolean | undefined;
|
|
501
|
+
}, {
|
|
502
|
+
baseUrl: string;
|
|
503
|
+
pushNotifications?: boolean | undefined;
|
|
504
|
+
streaming?: boolean | undefined;
|
|
505
|
+
}>>;
|
|
506
|
+
admission: z.ZodObject<{
|
|
507
|
+
maxAgents: z.ZodOptional<z.ZodNumber>;
|
|
508
|
+
requiredSkills: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
509
|
+
requiredTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
510
|
+
minProtocolVersion: z.ZodOptional<z.ZodString>;
|
|
511
|
+
customEvaluator: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
512
|
+
}, "strip", z.ZodTypeAny, {
|
|
513
|
+
maxAgents?: number | undefined;
|
|
514
|
+
requiredSkills?: string[] | undefined;
|
|
515
|
+
requiredTags?: string[] | undefined;
|
|
516
|
+
minProtocolVersion?: string | undefined;
|
|
517
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
518
|
+
}, {
|
|
519
|
+
maxAgents?: number | undefined;
|
|
520
|
+
requiredSkills?: string[] | undefined;
|
|
521
|
+
requiredTags?: string[] | undefined;
|
|
522
|
+
minProtocolVersion?: string | undefined;
|
|
523
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
524
|
+
}>;
|
|
525
|
+
simulation: z.ZodOptional<z.ZodObject<{
|
|
526
|
+
tickIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
527
|
+
maxTicks: z.ZodOptional<z.ZodNumber>;
|
|
528
|
+
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
529
|
+
}, "strip", z.ZodTypeAny, {
|
|
530
|
+
tickIntervalMs?: number | undefined;
|
|
531
|
+
maxTicks?: number | undefined;
|
|
532
|
+
autoStart?: boolean | undefined;
|
|
533
|
+
}, {
|
|
534
|
+
tickIntervalMs?: number | undefined;
|
|
535
|
+
maxTicks?: number | undefined;
|
|
536
|
+
autoStart?: boolean | undefined;
|
|
537
|
+
}>>;
|
|
538
|
+
persistence: z.ZodOptional<z.ZodObject<{
|
|
539
|
+
type: z.ZodEnum<["memory", "postgres", "redis", "mongodb", "sqlite", "leveldb"]>;
|
|
540
|
+
sqlite: z.ZodOptional<z.ZodObject<{
|
|
541
|
+
filename: z.ZodString;
|
|
542
|
+
memory: z.ZodOptional<z.ZodBoolean>;
|
|
543
|
+
}, "strip", z.ZodTypeAny, {
|
|
544
|
+
filename: string;
|
|
545
|
+
memory?: boolean | undefined;
|
|
546
|
+
}, {
|
|
547
|
+
filename: string;
|
|
548
|
+
memory?: boolean | undefined;
|
|
549
|
+
}>>;
|
|
550
|
+
postgres: z.ZodOptional<z.ZodObject<{
|
|
551
|
+
host: z.ZodString;
|
|
552
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
553
|
+
database: z.ZodString;
|
|
554
|
+
user: z.ZodString;
|
|
555
|
+
password: z.ZodString;
|
|
556
|
+
ssl: z.ZodOptional<z.ZodBoolean>;
|
|
557
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
558
|
+
}, "strip", z.ZodTypeAny, {
|
|
559
|
+
host: string;
|
|
560
|
+
database: string;
|
|
561
|
+
user: string;
|
|
562
|
+
password: string;
|
|
563
|
+
port?: number | undefined;
|
|
564
|
+
ssl?: boolean | undefined;
|
|
565
|
+
max?: number | undefined;
|
|
566
|
+
}, {
|
|
567
|
+
host: string;
|
|
568
|
+
database: string;
|
|
569
|
+
user: string;
|
|
570
|
+
password: string;
|
|
571
|
+
port?: number | undefined;
|
|
572
|
+
ssl?: boolean | undefined;
|
|
573
|
+
max?: number | undefined;
|
|
574
|
+
}>>;
|
|
575
|
+
redis: z.ZodOptional<z.ZodObject<{
|
|
576
|
+
host: z.ZodString;
|
|
577
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
578
|
+
password: z.ZodOptional<z.ZodString>;
|
|
579
|
+
db: z.ZodOptional<z.ZodNumber>;
|
|
580
|
+
keyPrefix: z.ZodOptional<z.ZodString>;
|
|
581
|
+
}, "strip", z.ZodTypeAny, {
|
|
582
|
+
host: string;
|
|
583
|
+
port?: number | undefined;
|
|
584
|
+
password?: string | undefined;
|
|
585
|
+
db?: number | undefined;
|
|
586
|
+
keyPrefix?: string | undefined;
|
|
587
|
+
}, {
|
|
588
|
+
host: string;
|
|
589
|
+
port?: number | undefined;
|
|
590
|
+
password?: string | undefined;
|
|
591
|
+
db?: number | undefined;
|
|
592
|
+
keyPrefix?: string | undefined;
|
|
593
|
+
}>>;
|
|
594
|
+
mongodb: z.ZodOptional<z.ZodObject<{
|
|
595
|
+
url: z.ZodString;
|
|
596
|
+
database: z.ZodString;
|
|
597
|
+
useUnifiedTopology: z.ZodOptional<z.ZodBoolean>;
|
|
598
|
+
}, "strip", z.ZodTypeAny, {
|
|
599
|
+
database: string;
|
|
600
|
+
url: string;
|
|
601
|
+
useUnifiedTopology?: boolean | undefined;
|
|
602
|
+
}, {
|
|
603
|
+
database: string;
|
|
604
|
+
url: string;
|
|
605
|
+
useUnifiedTopology?: boolean | undefined;
|
|
606
|
+
}>>;
|
|
607
|
+
leveldb: z.ZodOptional<z.ZodObject<{
|
|
608
|
+
path: z.ZodString;
|
|
609
|
+
}, "strip", z.ZodTypeAny, {
|
|
610
|
+
path: string;
|
|
611
|
+
}, {
|
|
612
|
+
path: string;
|
|
613
|
+
}>>;
|
|
614
|
+
autoSaveIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
615
|
+
}, "strip", z.ZodTypeAny, {
|
|
616
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
617
|
+
postgres?: {
|
|
618
|
+
host: string;
|
|
619
|
+
database: string;
|
|
620
|
+
user: string;
|
|
621
|
+
password: string;
|
|
622
|
+
port?: number | undefined;
|
|
623
|
+
ssl?: boolean | undefined;
|
|
624
|
+
max?: number | undefined;
|
|
625
|
+
} | undefined;
|
|
626
|
+
redis?: {
|
|
627
|
+
host: string;
|
|
628
|
+
port?: number | undefined;
|
|
629
|
+
password?: string | undefined;
|
|
630
|
+
db?: number | undefined;
|
|
631
|
+
keyPrefix?: string | undefined;
|
|
632
|
+
} | undefined;
|
|
633
|
+
mongodb?: {
|
|
634
|
+
database: string;
|
|
635
|
+
url: string;
|
|
636
|
+
useUnifiedTopology?: boolean | undefined;
|
|
637
|
+
} | undefined;
|
|
638
|
+
sqlite?: {
|
|
639
|
+
filename: string;
|
|
640
|
+
memory?: boolean | undefined;
|
|
641
|
+
} | undefined;
|
|
642
|
+
leveldb?: {
|
|
643
|
+
path: string;
|
|
644
|
+
} | undefined;
|
|
645
|
+
autoSaveIntervalMs?: number | undefined;
|
|
646
|
+
}, {
|
|
647
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
648
|
+
postgres?: {
|
|
649
|
+
host: string;
|
|
650
|
+
database: string;
|
|
651
|
+
user: string;
|
|
652
|
+
password: string;
|
|
653
|
+
port?: number | undefined;
|
|
654
|
+
ssl?: boolean | undefined;
|
|
655
|
+
max?: number | undefined;
|
|
656
|
+
} | undefined;
|
|
657
|
+
redis?: {
|
|
658
|
+
host: string;
|
|
659
|
+
port?: number | undefined;
|
|
660
|
+
password?: string | undefined;
|
|
661
|
+
db?: number | undefined;
|
|
662
|
+
keyPrefix?: string | undefined;
|
|
663
|
+
} | undefined;
|
|
664
|
+
mongodb?: {
|
|
665
|
+
database: string;
|
|
666
|
+
url: string;
|
|
667
|
+
useUnifiedTopology?: boolean | undefined;
|
|
668
|
+
} | undefined;
|
|
669
|
+
sqlite?: {
|
|
670
|
+
filename: string;
|
|
671
|
+
memory?: boolean | undefined;
|
|
672
|
+
} | undefined;
|
|
673
|
+
leveldb?: {
|
|
674
|
+
path: string;
|
|
675
|
+
} | undefined;
|
|
676
|
+
autoSaveIntervalMs?: number | undefined;
|
|
677
|
+
}>>;
|
|
678
|
+
blockchain: z.ZodOptional<z.ZodObject<{
|
|
679
|
+
rpcUrl: z.ZodString;
|
|
680
|
+
privateKey: z.ZodString;
|
|
681
|
+
entryFee: z.ZodNumber;
|
|
682
|
+
requireMembership: z.ZodOptional<z.ZodBoolean>;
|
|
683
|
+
enforceOnChainValidation: z.ZodOptional<z.ZodBoolean>;
|
|
684
|
+
agentRegistryAddress: z.ZodOptional<z.ZodString>;
|
|
685
|
+
membershipContractAddress: z.ZodOptional<z.ZodString>;
|
|
686
|
+
worldTokenAddress: z.ZodOptional<z.ZodString>;
|
|
687
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
688
|
+
}, "strip", z.ZodTypeAny, {
|
|
689
|
+
rpcUrl: string;
|
|
690
|
+
privateKey: string;
|
|
691
|
+
entryFee: number;
|
|
692
|
+
requireMembership?: boolean | undefined;
|
|
693
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
694
|
+
agentRegistryAddress?: string | undefined;
|
|
695
|
+
membershipContractAddress?: string | undefined;
|
|
696
|
+
worldTokenAddress?: string | undefined;
|
|
697
|
+
chainId?: number | undefined;
|
|
698
|
+
}, {
|
|
699
|
+
rpcUrl: string;
|
|
700
|
+
privateKey: string;
|
|
701
|
+
entryFee: number;
|
|
702
|
+
requireMembership?: boolean | undefined;
|
|
703
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
704
|
+
agentRegistryAddress?: string | undefined;
|
|
705
|
+
membershipContractAddress?: string | undefined;
|
|
706
|
+
worldTokenAddress?: string | undefined;
|
|
707
|
+
chainId?: number | undefined;
|
|
708
|
+
}>>;
|
|
709
|
+
token: z.ZodOptional<z.ZodObject<{
|
|
710
|
+
deploy: z.ZodBoolean;
|
|
711
|
+
name: z.ZodOptional<z.ZodString>;
|
|
712
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
713
|
+
initialSupply: z.ZodOptional<z.ZodNumber>;
|
|
714
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
715
|
+
}, "strip", z.ZodTypeAny, {
|
|
716
|
+
deploy: boolean;
|
|
717
|
+
symbol?: string | undefined;
|
|
718
|
+
name?: string | undefined;
|
|
719
|
+
initialSupply?: number | undefined;
|
|
720
|
+
decimals?: number | undefined;
|
|
721
|
+
}, {
|
|
722
|
+
deploy: boolean;
|
|
723
|
+
symbol?: string | undefined;
|
|
724
|
+
name?: string | undefined;
|
|
725
|
+
initialSupply?: number | undefined;
|
|
726
|
+
decimals?: number | undefined;
|
|
727
|
+
}>>;
|
|
728
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
729
|
+
agentUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
730
|
+
}, "strip", z.ZodTypeAny, {
|
|
731
|
+
name: string;
|
|
732
|
+
server: {
|
|
733
|
+
host: string;
|
|
734
|
+
port: number;
|
|
735
|
+
};
|
|
736
|
+
admission: {
|
|
737
|
+
maxAgents?: number | undefined;
|
|
738
|
+
requiredSkills?: string[] | undefined;
|
|
739
|
+
requiredTags?: string[] | undefined;
|
|
740
|
+
minProtocolVersion?: string | undefined;
|
|
741
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
742
|
+
};
|
|
743
|
+
type?: string | undefined;
|
|
744
|
+
description?: string | undefined;
|
|
745
|
+
a2a?: {
|
|
746
|
+
baseUrl: string;
|
|
747
|
+
pushNotifications?: boolean | undefined;
|
|
748
|
+
streaming?: boolean | undefined;
|
|
749
|
+
} | undefined;
|
|
750
|
+
simulation?: {
|
|
751
|
+
tickIntervalMs?: number | undefined;
|
|
752
|
+
maxTicks?: number | undefined;
|
|
753
|
+
autoStart?: boolean | undefined;
|
|
754
|
+
} | undefined;
|
|
755
|
+
persistence?: {
|
|
756
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
757
|
+
postgres?: {
|
|
758
|
+
host: string;
|
|
759
|
+
database: string;
|
|
760
|
+
user: string;
|
|
761
|
+
password: string;
|
|
762
|
+
port?: number | undefined;
|
|
763
|
+
ssl?: boolean | undefined;
|
|
764
|
+
max?: number | undefined;
|
|
765
|
+
} | undefined;
|
|
766
|
+
redis?: {
|
|
767
|
+
host: string;
|
|
768
|
+
port?: number | undefined;
|
|
769
|
+
password?: string | undefined;
|
|
770
|
+
db?: number | undefined;
|
|
771
|
+
keyPrefix?: string | undefined;
|
|
772
|
+
} | undefined;
|
|
773
|
+
mongodb?: {
|
|
774
|
+
database: string;
|
|
775
|
+
url: string;
|
|
776
|
+
useUnifiedTopology?: boolean | undefined;
|
|
777
|
+
} | undefined;
|
|
778
|
+
sqlite?: {
|
|
779
|
+
filename: string;
|
|
780
|
+
memory?: boolean | undefined;
|
|
781
|
+
} | undefined;
|
|
782
|
+
leveldb?: {
|
|
783
|
+
path: string;
|
|
784
|
+
} | undefined;
|
|
785
|
+
autoSaveIntervalMs?: number | undefined;
|
|
786
|
+
} | undefined;
|
|
787
|
+
blockchain?: {
|
|
788
|
+
rpcUrl: string;
|
|
789
|
+
privateKey: string;
|
|
790
|
+
entryFee: number;
|
|
791
|
+
requireMembership?: boolean | undefined;
|
|
792
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
793
|
+
agentRegistryAddress?: string | undefined;
|
|
794
|
+
membershipContractAddress?: string | undefined;
|
|
795
|
+
worldTokenAddress?: string | undefined;
|
|
796
|
+
chainId?: number | undefined;
|
|
797
|
+
} | undefined;
|
|
798
|
+
token?: {
|
|
799
|
+
deploy: boolean;
|
|
800
|
+
symbol?: string | undefined;
|
|
801
|
+
name?: string | undefined;
|
|
802
|
+
initialSupply?: number | undefined;
|
|
803
|
+
decimals?: number | undefined;
|
|
804
|
+
} | undefined;
|
|
805
|
+
rules?: any[] | undefined;
|
|
806
|
+
agentUrls?: string[] | undefined;
|
|
807
|
+
}, {
|
|
808
|
+
name: string;
|
|
809
|
+
server: {
|
|
810
|
+
host: string;
|
|
811
|
+
port: number;
|
|
812
|
+
};
|
|
813
|
+
admission: {
|
|
814
|
+
maxAgents?: number | undefined;
|
|
815
|
+
requiredSkills?: string[] | undefined;
|
|
816
|
+
requiredTags?: string[] | undefined;
|
|
817
|
+
minProtocolVersion?: string | undefined;
|
|
818
|
+
customEvaluator?: ((...args: unknown[]) => unknown) | undefined;
|
|
819
|
+
};
|
|
820
|
+
type?: string | undefined;
|
|
821
|
+
description?: string | undefined;
|
|
822
|
+
a2a?: {
|
|
823
|
+
baseUrl: string;
|
|
824
|
+
pushNotifications?: boolean | undefined;
|
|
825
|
+
streaming?: boolean | undefined;
|
|
826
|
+
} | undefined;
|
|
827
|
+
simulation?: {
|
|
828
|
+
tickIntervalMs?: number | undefined;
|
|
829
|
+
maxTicks?: number | undefined;
|
|
830
|
+
autoStart?: boolean | undefined;
|
|
831
|
+
} | undefined;
|
|
832
|
+
persistence?: {
|
|
833
|
+
type: "memory" | "postgres" | "redis" | "mongodb" | "sqlite" | "leveldb";
|
|
834
|
+
postgres?: {
|
|
835
|
+
host: string;
|
|
836
|
+
database: string;
|
|
837
|
+
user: string;
|
|
838
|
+
password: string;
|
|
839
|
+
port?: number | undefined;
|
|
840
|
+
ssl?: boolean | undefined;
|
|
841
|
+
max?: number | undefined;
|
|
842
|
+
} | undefined;
|
|
843
|
+
redis?: {
|
|
844
|
+
host: string;
|
|
845
|
+
port?: number | undefined;
|
|
846
|
+
password?: string | undefined;
|
|
847
|
+
db?: number | undefined;
|
|
848
|
+
keyPrefix?: string | undefined;
|
|
849
|
+
} | undefined;
|
|
850
|
+
mongodb?: {
|
|
851
|
+
database: string;
|
|
852
|
+
url: string;
|
|
853
|
+
useUnifiedTopology?: boolean | undefined;
|
|
854
|
+
} | undefined;
|
|
855
|
+
sqlite?: {
|
|
856
|
+
filename: string;
|
|
857
|
+
memory?: boolean | undefined;
|
|
858
|
+
} | undefined;
|
|
859
|
+
leveldb?: {
|
|
860
|
+
path: string;
|
|
861
|
+
} | undefined;
|
|
862
|
+
autoSaveIntervalMs?: number | undefined;
|
|
863
|
+
} | undefined;
|
|
864
|
+
blockchain?: {
|
|
865
|
+
rpcUrl: string;
|
|
866
|
+
privateKey: string;
|
|
867
|
+
entryFee: number;
|
|
868
|
+
requireMembership?: boolean | undefined;
|
|
869
|
+
enforceOnChainValidation?: boolean | undefined;
|
|
870
|
+
agentRegistryAddress?: string | undefined;
|
|
871
|
+
membershipContractAddress?: string | undefined;
|
|
872
|
+
worldTokenAddress?: string | undefined;
|
|
873
|
+
chainId?: number | undefined;
|
|
874
|
+
} | undefined;
|
|
875
|
+
token?: {
|
|
876
|
+
deploy: boolean;
|
|
877
|
+
symbol?: string | undefined;
|
|
878
|
+
name?: string | undefined;
|
|
879
|
+
initialSupply?: number | undefined;
|
|
880
|
+
decimals?: number | undefined;
|
|
881
|
+
} | undefined;
|
|
882
|
+
rules?: any[] | undefined;
|
|
883
|
+
agentUrls?: string[] | undefined;
|
|
884
|
+
}>;
|
|
885
|
+
/**
|
|
886
|
+
* Validate world configuration
|
|
887
|
+
*/
|
|
888
|
+
declare function validateWorldConfig(config: unknown): void;
|
|
889
|
+
/**
|
|
890
|
+
* Validate world configuration and return result
|
|
891
|
+
*/
|
|
892
|
+
declare function isValidWorldConfig(config: unknown): boolean;
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* ============================================================================
|
|
896
|
+
* PERSISTENCE ADAPTER INTERFACE
|
|
897
|
+
* ============================================================================
|
|
898
|
+
*
|
|
899
|
+
* Unified interface for all persistence backends.
|
|
900
|
+
* Allows switching between SQLite, PostgreSQL, Redis, MongoDB, LevelDB
|
|
901
|
+
* without code changes.
|
|
902
|
+
*/
|
|
903
|
+
interface EventFilter {
|
|
904
|
+
type?: string;
|
|
905
|
+
agentUrl?: string;
|
|
906
|
+
since?: number;
|
|
907
|
+
until?: number;
|
|
908
|
+
limit?: number;
|
|
909
|
+
}
|
|
910
|
+
interface PersistenceAdapter {
|
|
911
|
+
/**
|
|
912
|
+
* Save current world state snapshot
|
|
913
|
+
*/
|
|
914
|
+
saveState(state: WorldStateSnapshot): Promise<void>;
|
|
915
|
+
/**
|
|
916
|
+
* Load saved world state (null if none exists)
|
|
917
|
+
*/
|
|
918
|
+
loadState(): Promise<WorldStateSnapshot | null>;
|
|
919
|
+
/**
|
|
920
|
+
* Save world event to persistence
|
|
921
|
+
*/
|
|
922
|
+
saveEvent(event: WorldEvent): Promise<void>;
|
|
923
|
+
/**
|
|
924
|
+
* Query events with optional filters
|
|
925
|
+
*/
|
|
926
|
+
getEvents(filter?: EventFilter): Promise<WorldEvent[]>;
|
|
927
|
+
/**
|
|
928
|
+
* Save agent profile
|
|
929
|
+
*/
|
|
930
|
+
saveAgent(profile: AgentProfile): Promise<void>;
|
|
931
|
+
/**
|
|
932
|
+
* Remove agent from persistence
|
|
933
|
+
*/
|
|
934
|
+
removeAgent(agentUrl: string): Promise<void>;
|
|
935
|
+
/**
|
|
936
|
+
* Get all saved agents
|
|
937
|
+
*/
|
|
938
|
+
getAgents(): Promise<AgentProfile[]>;
|
|
939
|
+
/**
|
|
940
|
+
* Get single agent by URL
|
|
941
|
+
*/
|
|
942
|
+
getAgent(agentUrl: string): Promise<AgentProfile | null>;
|
|
943
|
+
/**
|
|
944
|
+
* Connect to persistence backend
|
|
945
|
+
*/
|
|
946
|
+
connect(): Promise<void>;
|
|
947
|
+
/**
|
|
948
|
+
* Disconnect from persistence backend
|
|
949
|
+
*/
|
|
950
|
+
disconnect(): Promise<void>;
|
|
951
|
+
/**
|
|
952
|
+
* Health check
|
|
953
|
+
*/
|
|
954
|
+
healthCheck(): Promise<boolean>;
|
|
955
|
+
/**
|
|
956
|
+
* Optional: Clear all data (for testing)
|
|
957
|
+
*/
|
|
958
|
+
clear?(): Promise<void>;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* ============================================================================
|
|
963
|
+
* PERSISTENCE FACTORY
|
|
964
|
+
* ============================================================================
|
|
965
|
+
*
|
|
966
|
+
* Creates the appropriate persistence adapter based on configuration.
|
|
967
|
+
* Uses lazy-loading for optional dependencies to avoid requiring all databases.
|
|
968
|
+
*/
|
|
969
|
+
declare function createPersistence(config: PersistenceConfig): PersistenceAdapter;
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* ============================================================================
|
|
973
|
+
* IN-MEMORY PERSISTENCE ADAPTER
|
|
974
|
+
* ============================================================================
|
|
975
|
+
*
|
|
976
|
+
* Simple in-memory persistence for testing and development.
|
|
977
|
+
* No external dependencies - works on any Node version.
|
|
978
|
+
*
|
|
979
|
+
* WARNING: All data is lost when process exits.
|
|
980
|
+
*
|
|
981
|
+
* Use Case: Testing, development, temporary worlds
|
|
982
|
+
*/
|
|
983
|
+
declare class InMemoryAdapter implements PersistenceAdapter {
|
|
984
|
+
private state;
|
|
985
|
+
private events;
|
|
986
|
+
private agents;
|
|
987
|
+
connect(): Promise<void>;
|
|
988
|
+
saveState(state: WorldStateSnapshot): Promise<void>;
|
|
989
|
+
loadState(): Promise<WorldStateSnapshot | null>;
|
|
990
|
+
saveEvent(event: WorldEvent): Promise<void>;
|
|
991
|
+
getEvents(filter?: EventFilter$1): Promise<WorldEvent[]>;
|
|
992
|
+
saveAgent(profile: AgentProfile): Promise<void>;
|
|
993
|
+
removeAgent(agentUrl: string): Promise<void>;
|
|
994
|
+
getAgents(): Promise<AgentProfile[]>;
|
|
995
|
+
getAgent(agentUrl: string): Promise<AgentProfile | null>;
|
|
996
|
+
disconnect(): Promise<void>;
|
|
997
|
+
healthCheck(): Promise<boolean>;
|
|
998
|
+
clear(): Promise<void>;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
declare const logger: winston.Logger;
|
|
1002
|
+
/**
|
|
1003
|
+
* Create a child logger with a specific module name
|
|
1004
|
+
*/
|
|
1005
|
+
declare function createLogger(moduleName: string): winston.Logger;
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* ============================================================================
|
|
1009
|
+
* WORLD ENGINE
|
|
1010
|
+
* ============================================================================
|
|
1011
|
+
*
|
|
1012
|
+
* Core world runtime managing:
|
|
1013
|
+
* - Agent discovery and admission
|
|
1014
|
+
* - World state and lifecycle
|
|
1015
|
+
* - Persistence and event logging
|
|
1016
|
+
* - Simulation ticks (if enabled)
|
|
1017
|
+
* - Rule enforcement
|
|
1018
|
+
*/
|
|
1019
|
+
declare class World {
|
|
1020
|
+
readonly config: WorldConfig;
|
|
1021
|
+
private state;
|
|
1022
|
+
private agents;
|
|
1023
|
+
private persistence;
|
|
1024
|
+
private blockchainClient;
|
|
1025
|
+
private cardFetcher;
|
|
1026
|
+
private evaluator;
|
|
1027
|
+
private tickInterval;
|
|
1028
|
+
private autoSaveInterval;
|
|
1029
|
+
constructor(config: WorldConfig);
|
|
1030
|
+
/**
|
|
1031
|
+
* Initialize the world (connect persistence, restore state, discover agents)
|
|
1032
|
+
*/
|
|
1033
|
+
init(): Promise<void>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Start the world simulation
|
|
1036
|
+
*/
|
|
1037
|
+
start(): Promise<void>;
|
|
1038
|
+
/**
|
|
1039
|
+
* Stop the world simulation
|
|
1040
|
+
*/
|
|
1041
|
+
stop(): Promise<void>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Admit an agent to the world
|
|
1044
|
+
*/
|
|
1045
|
+
admitAgent(card: any, walletAddress?: string): Promise<void>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Remove an agent from the world
|
|
1048
|
+
*/
|
|
1049
|
+
removeAgent(agentUrl: string): Promise<void>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Get all agents in the world
|
|
1052
|
+
*/
|
|
1053
|
+
getAgents(): AgentProfile[];
|
|
1054
|
+
/**
|
|
1055
|
+
* Get current world state
|
|
1056
|
+
*/
|
|
1057
|
+
getState(): WorldStateSnapshot;
|
|
1058
|
+
/**
|
|
1059
|
+
* Log an event
|
|
1060
|
+
*/
|
|
1061
|
+
private logEvent;
|
|
1062
|
+
/**
|
|
1063
|
+
* Set world phase
|
|
1064
|
+
*/
|
|
1065
|
+
private setState;
|
|
1066
|
+
/**
|
|
1067
|
+
* Start auto-save interval
|
|
1068
|
+
*/
|
|
1069
|
+
private startAutoSave;
|
|
1070
|
+
/**
|
|
1071
|
+
* Start simulation ticking
|
|
1072
|
+
*/
|
|
1073
|
+
private startTicking;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* ============================================================================
|
|
1078
|
+
* AGENT CARD FETCHER
|
|
1079
|
+
* ============================================================================
|
|
1080
|
+
*
|
|
1081
|
+
* Discovers agents by fetching their A2A Agent Cards.
|
|
1082
|
+
* Follows the A2A protocol specification.
|
|
1083
|
+
*/
|
|
1084
|
+
interface FetchResult {
|
|
1085
|
+
success: boolean;
|
|
1086
|
+
card?: AgentCard;
|
|
1087
|
+
error?: string;
|
|
1088
|
+
}
|
|
1089
|
+
declare class CardFetcher {
|
|
1090
|
+
/**
|
|
1091
|
+
* Fetch an agent's card from their A2A endpoint.
|
|
1092
|
+
*
|
|
1093
|
+
* @param agentUrl Base URL of the agent (e.g., http://localhost:3000)
|
|
1094
|
+
* @returns Fetch result with card or error
|
|
1095
|
+
*/
|
|
1096
|
+
fetchCard(agentUrl: string): Promise<FetchResult>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Fetch multiple agent cards in parallel.
|
|
1099
|
+
*
|
|
1100
|
+
* @param agentUrls Array of agent URLs
|
|
1101
|
+
* @returns Array of fetch results
|
|
1102
|
+
*/
|
|
1103
|
+
fetchCards(agentUrls: string[]): Promise<FetchResult[]>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Verify that an agent card is valid for A2A protocol v0.3.0.
|
|
1106
|
+
*
|
|
1107
|
+
* @param card Agent card to verify
|
|
1108
|
+
* @returns True if valid
|
|
1109
|
+
*/
|
|
1110
|
+
verifyCard(card: AgentCard): boolean;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Helper to extract base URL from various formats
|
|
1114
|
+
*/
|
|
1115
|
+
declare function normalizeAgentUrl(url: string): string;
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* ============================================================================
|
|
1119
|
+
* AGENT EVALUATOR
|
|
1120
|
+
* ============================================================================
|
|
1121
|
+
*
|
|
1122
|
+
* Evaluates whether an agent should be admitted to the world based on rules.
|
|
1123
|
+
*
|
|
1124
|
+
* Evaluation criteria:
|
|
1125
|
+
* - Max agents limit
|
|
1126
|
+
* - Required skills (agent must have ALL)
|
|
1127
|
+
* - Required tags (agent must have AT LEAST ONE)
|
|
1128
|
+
* - Minimum protocol version
|
|
1129
|
+
* - Custom evaluator function
|
|
1130
|
+
*/
|
|
1131
|
+
declare class AgentEvaluator {
|
|
1132
|
+
private rules;
|
|
1133
|
+
constructor(rules: AdmissionRules);
|
|
1134
|
+
/**
|
|
1135
|
+
* Evaluate whether an agent should be admitted.
|
|
1136
|
+
*
|
|
1137
|
+
* @param card Agent's A2A card
|
|
1138
|
+
* @param currentAgentCount Current number of agents in world
|
|
1139
|
+
* @param walletAddress Optional wallet address for blockchain membership
|
|
1140
|
+
* @returns Admission decision
|
|
1141
|
+
*/
|
|
1142
|
+
evaluate(card: AgentCard, currentAgentCount: number, walletAddress?: string): Promise<AdmissionDecision>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Check if agent's protocol version meets minimum requirement.
|
|
1145
|
+
* Simple semver comparison (major.minor).
|
|
1146
|
+
*/
|
|
1147
|
+
private meetsProtocolVersion;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* ============================================================================
|
|
1152
|
+
* BLOCKCHAIN CLIENT
|
|
1153
|
+
* ============================================================================
|
|
1154
|
+
*
|
|
1155
|
+
* Handles all blockchain interactions for the World SDK:
|
|
1156
|
+
* - Agent registry validation
|
|
1157
|
+
* - Membership NFT minting
|
|
1158
|
+
* - Entry fee collection
|
|
1159
|
+
* - World token operations
|
|
1160
|
+
*/
|
|
1161
|
+
declare class BlockchainClient {
|
|
1162
|
+
private config;
|
|
1163
|
+
private provider;
|
|
1164
|
+
private wallet;
|
|
1165
|
+
private agentRegistry?;
|
|
1166
|
+
private membershipContract?;
|
|
1167
|
+
private worldToken?;
|
|
1168
|
+
constructor(config: BlockchainConfig);
|
|
1169
|
+
/**
|
|
1170
|
+
* Initialize contract connections
|
|
1171
|
+
*/
|
|
1172
|
+
init(): Promise<void>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Validate agent on-chain
|
|
1175
|
+
* @param walletAddress Agent's wallet address
|
|
1176
|
+
* @returns True if agent is registered and valid
|
|
1177
|
+
*/
|
|
1178
|
+
validateAgent(walletAddress: string): Promise<boolean>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Mint membership NFT for an agent
|
|
1181
|
+
* @param agentWallet Agent's wallet address
|
|
1182
|
+
* @returns Transaction hash
|
|
1183
|
+
*/
|
|
1184
|
+
mintMembership(agentWallet: string): Promise<string>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Check if agent has membership
|
|
1187
|
+
* @param agentWallet Agent's wallet address
|
|
1188
|
+
* @returns True if agent has membership
|
|
1189
|
+
*/
|
|
1190
|
+
hasMembership(agentWallet: string): Promise<boolean>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Revoke membership NFT
|
|
1193
|
+
* @param agentWallet Agent's wallet address
|
|
1194
|
+
* @returns Transaction hash
|
|
1195
|
+
*/
|
|
1196
|
+
revokeMembership(agentWallet: string): Promise<string>;
|
|
1197
|
+
/**
|
|
1198
|
+
* Get total number of members
|
|
1199
|
+
*/
|
|
1200
|
+
getTotalMembers(): Promise<number>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Withdraw collected entry fees (world owner only)
|
|
1203
|
+
*/
|
|
1204
|
+
withdrawFees(): Promise<string>;
|
|
1205
|
+
/**
|
|
1206
|
+
* Get world owner's wallet address
|
|
1207
|
+
*/
|
|
1208
|
+
getWalletAddress(): string;
|
|
1209
|
+
/**
|
|
1210
|
+
* Get entry fee in MON
|
|
1211
|
+
*/
|
|
1212
|
+
getEntryFee(): Promise<string>;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* ============================================================================
|
|
1217
|
+
* WORLD HTTP SERVER
|
|
1218
|
+
* ============================================================================
|
|
1219
|
+
*
|
|
1220
|
+
* Express server providing HTTP endpoints for:
|
|
1221
|
+
* - World information
|
|
1222
|
+
* - Agent join requests
|
|
1223
|
+
* - Agent list
|
|
1224
|
+
* - World state and events
|
|
1225
|
+
*
|
|
1226
|
+
* Mirrors the agent SDK server pattern.
|
|
1227
|
+
*/
|
|
1228
|
+
declare function createWorldApp(world: World): Express;
|
|
1229
|
+
/**
|
|
1230
|
+
* Start world server on configured port
|
|
1231
|
+
*/
|
|
1232
|
+
declare function startWorldServer(world: World): Promise<void>;
|
|
1233
|
+
|
|
1234
|
+
export { type AdmissionDecision, type AdmissionRules, AdmissionRulesSchema, AgentEvaluator, type AgentProfile, BlockchainClient, type BlockchainConfig, BlockchainConfigSchema, CardFetcher, type EventFilter$1 as EventFilter, type FetchResult, InMemoryAdapter, type PersistenceAdapter, type PersistenceConfig, PersistenceConfigSchema, type RuleContext, type RuleViolation, type TokenConfig, TokenConfigSchema, World, type WorldConfig, WorldConfigSchema, type WorldEvent, type WorldPhase, type WorldRule, type WorldStateSnapshot, type WorldTypeModule, createLogger, createPersistence, createWorldApp, isValidWorldConfig, logger, normalizeAgentUrl, profileFromCard, startWorldServer, validateWorldConfig };
|