@moltium/cli 0.1.20 → 0.1.22

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
@@ -19,6 +19,7 @@ function codeTemplate(ctx) {
19
19
  const model = ctx.llmProvider === "anthropic" ? "claude-sonnet-4-20250514" : "gpt-4o";
20
20
  const socialConfig = buildSocialConfig(ctx.socialPlatforms);
21
21
  const a2aConfig = ctx.enableA2A !== false ? buildA2AConfig() : "";
22
+ const worldConfig = buildWorldConfig(ctx.connectToWorld, ctx.worldUrl);
22
23
  return `import type { AgentConfig } from '@moltium/core';
23
24
  import { exampleAction } from './actions/example.js';
24
25
 
@@ -41,7 +42,7 @@ export default {
41
42
 
42
43
  social: {${socialConfig}
43
44
  },
44
- ${a2aConfig}
45
+ ${a2aConfig}${worldConfig}
45
46
  behaviors: {
46
47
  autonomous: true,
47
48
  decisionMaking: 'llm-driven',
@@ -117,6 +118,28 @@ function buildA2AConfig() {
117
118
  // verbose: false,
118
119
  // },
119
120
 
121
+ `;
122
+ }
123
+ function buildWorldConfig(connectToWorld, worldUrl) {
124
+ if (connectToWorld && worldUrl) {
125
+ return ` // World SDK Integration \u2014 connect this agent to a Moltium World
126
+ // The agent will auto-join the world on startup and register world actions:
127
+ // join_world, leave_world, query_world, send_world_message
128
+ world: {
129
+ url: process.env.WORLD_URL || '${worldUrl}',
130
+ autoJoin: true,
131
+ },
132
+
133
+ `;
134
+ }
135
+ return ` // World SDK Integration \u2014 connect this agent to a Moltium World
136
+ // Uncomment to join a world on startup. Automatically registers world actions:
137
+ // join_world, leave_world, query_world, send_world_message
138
+ // world: {
139
+ // url: process.env.WORLD_URL || 'http://localhost:4000',
140
+ // autoJoin: true,
141
+ // },
142
+
120
143
  `;
121
144
  }
122
145
 
@@ -322,6 +345,7 @@ export async function onShutdown(agent: Agent): Promise<void> {
322
345
  function markdownTemplate(ctx) {
323
346
  const socialSections = buildSocialSections(ctx.socialPlatforms);
324
347
  const a2aSection = ctx.enableA2A !== false ? buildA2ASection() : "";
348
+ const worldSection = buildWorldSection(ctx.connectToWorld, ctx.worldUrl);
325
349
  return `# Agent Configuration
326
350
 
327
351
  ## Identity
@@ -336,7 +360,7 @@ detailed trait definitions.
336
360
 
337
361
  ## Social Platforms
338
362
  ${socialSections}
339
- ${a2aSection}
363
+ ${a2aSection}${worldSection}
340
364
  ## Behaviors
341
365
  autonomous: true
342
366
  decision_making: llm-driven
@@ -424,6 +448,22 @@ a2a:
424
448
  verbose: false
425
449
  -->
426
450
 
451
+ `;
452
+ }
453
+ function buildWorldSection(connectToWorld, worldUrl) {
454
+ if (connectToWorld && worldUrl) {
455
+ return `## World
456
+ url: ${worldUrl}
457
+ auto_join: true
458
+
459
+ `;
460
+ }
461
+ return `## World
462
+ <!-- Uncomment to connect this agent to a Moltium World on startup -->
463
+ <!-- Automatically registers: join_world, leave_world, query_world, send_world_message -->
464
+ <!-- url: http://localhost:4000 -->
465
+ <!-- auto_join: true -->
466
+
427
467
  `;
428
468
  }
429
469
 
@@ -502,6 +542,16 @@ if (config.social.twitter?.enabled) {
502
542
  };
503
543
  }
504
544
 
545
+ // \u2500\u2500 Wire world config from environment \u2500\u2500
546
+ // WORLD_URL env var overrides the value in agent.md
547
+ if (process.env.WORLD_URL) {
548
+ config.world = {
549
+ url: process.env.WORLD_URL,
550
+ autoJoin: config.world?.autoJoin !== false,
551
+ walletAddress: config.world?.walletAddress,
552
+ };
553
+ }
554
+
505
555
  // \u2500\u2500 Create agent \u2500\u2500
506
556
  const agent = new Agent(config);
507
557
 
@@ -581,12 +631,16 @@ agent.setHooks({
581
631
  // \u2500\u2500 Start \u2500\u2500
582
632
  const port = parseInt(process.env.PORT || '3000', 10);
583
633
 
584
- startServer(agent, {
634
+ startServer(agent, {
585
635
  port${a2aConfig},
586
636
  a2aConfig: {
587
637
  enabled: true,
588
638
  baseUrl: \`http://0.0.0.0:\${port}\`,
589
639
  },
640
+ }).catch((err) => {
641
+ console.error('Failed to start agent:', err);
642
+ process.exit(1);
643
+ });
590
644
  `;
591
645
  }
592
646
 
@@ -1079,7 +1133,7 @@ function getCoreDepVersion() {
1079
1133
  const corePkg = require2("@moltium/core/package.json");
1080
1134
  return `^${corePkg.version}`;
1081
1135
  } catch {
1082
- return "^0.1.20";
1136
+ return "^0.1.22";
1083
1137
  }
1084
1138
  }
1085
1139
  var initCommand = new Command("init").description("Initialize a new Moltium agent").argument("[name]", "Agent name").action(async (name) => {
@@ -1131,6 +1185,19 @@ var initCommand = new Command("init").description("Initialize a new Moltium agen
1131
1185
  message: "Enable A2A Protocol support? (Agent-to-Agent communication)",
1132
1186
  default: true
1133
1187
  },
1188
+ {
1189
+ type: "confirm",
1190
+ name: "connectToWorld",
1191
+ message: "Connect to a Moltium World? (World SDK integration)",
1192
+ default: false
1193
+ },
1194
+ {
1195
+ type: "input",
1196
+ name: "worldUrl",
1197
+ message: "World server URL:",
1198
+ default: "http://localhost:4000",
1199
+ when: (answers2) => answers2.connectToWorld
1200
+ },
1134
1201
  {
1135
1202
  type: "list",
1136
1203
  name: "deployTarget",
@@ -1295,6 +1362,13 @@ function generateEnvFile(ctx) {
1295
1362
  lines.push(`${tw}TWITTER_ACCESS_TOKEN=your-twitter-access-token`);
1296
1363
  lines.push(`${tw}TWITTER_ACCESS_SECRET=your-twitter-access-secret`);
1297
1364
  lines.push("");
1365
+ lines.push("# World SDK Integration (set URL to auto-connect on startup)");
1366
+ if (ctx.connectToWorld && ctx.worldUrl) {
1367
+ lines.push(`WORLD_URL=${ctx.worldUrl}`);
1368
+ } else {
1369
+ lines.push("# WORLD_URL=http://localhost:4000");
1370
+ }
1371
+ lines.push("");
1298
1372
  lines.push("PORT=3000");
1299
1373
  lines.push("LOG_LEVEL=info");
1300
1374
  lines.push("");