@moltium/cli 0.1.19 → 0.1.20

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
@@ -18,6 +18,7 @@ function codeTemplate(ctx) {
18
18
  const envKey = ctx.llmProvider === "anthropic" ? "ANTHROPIC_API_KEY" : "OPENAI_API_KEY";
19
19
  const model = ctx.llmProvider === "anthropic" ? "claude-sonnet-4-20250514" : "gpt-4o";
20
20
  const socialConfig = buildSocialConfig(ctx.socialPlatforms);
21
+ const a2aConfig = ctx.enableA2A !== false ? buildA2AConfig() : "";
21
22
  return `import type { AgentConfig } from '@moltium/core';
22
23
  import { exampleAction } from './actions/example.js';
23
24
 
@@ -40,7 +41,7 @@ export default {
40
41
 
41
42
  social: {${socialConfig}
42
43
  },
43
-
44
+ ${a2aConfig}
44
45
  behaviors: {
45
46
  autonomous: true,
46
47
  decisionMaking: 'llm-driven',
@@ -100,9 +101,36 @@ function buildSocialConfig(platforms) {
100
101
  maxTweetsPerDay: 5,
101
102
  },`;
102
103
  }
104
+ function buildA2AConfig() {
105
+ return ` // A2A Protocol \u2014 Agent-to-Agent communication
106
+ // Uncomment and configure to enable communication with other agents
107
+ // When enabled, automatically registers 'talk_to_agent' action
108
+ // a2a: {
109
+ // enabled: true,
110
+ // // Define peer agents this agent can talk to
111
+ // peers: {
112
+ // // talk_to_analyst: 'http://localhost:3001',
113
+ // // talk_to_researcher: 'http://localhost:3002',
114
+ // },
115
+ // // Or use a default peer URL
116
+ // // defaultPeerUrl: 'http://localhost:3001',
117
+ // verbose: false,
118
+ // },
119
+
120
+ `;
121
+ }
103
122
 
104
123
  // src/templates/code-based/start.ts
105
124
  function codeStartTemplate(ctx) {
125
+ const a2aComment = ctx.enableA2A !== false ? `// A2A Protocol endpoints are enabled by default:
126
+ // - /.well-known/agent-card.json (Agent discovery)
127
+ // - /a2a/jsonrpc (JSON-RPC transport)
128
+ // - /a2a/rest (HTTP+JSON/REST transport)
129
+ // To disable, pass { enableA2A: false } to startServer()` : `// A2A Protocol is disabled
130
+ // To enable, pass { enableA2A: true } to startServer()`;
131
+ const a2aConfig = ctx.enableA2A !== false ? `,
132
+ enableA2A: true, // Enable A2A Protocol endpoints` : `,
133
+ enableA2A: false`;
106
134
  return `import 'dotenv/config';
107
135
  import { Agent, startServer } from '@moltium/core';
108
136
  import config from './agent.config.js';
@@ -118,6 +146,8 @@ import { onShutdown } from './hooks/onShutdown.js';
118
146
  * 2. Wires up lifecycle hooks (onInit, onTick, onShutdown)
119
147
  * 3. Starts the HTTP server with REST endpoints
120
148
  *
149
+ * ${a2aComment}
150
+ *
121
151
  * Run with: npx tsx start.ts
122
152
  * Or: npm start
123
153
  */
@@ -133,7 +163,13 @@ const agent = new Agent(config, {
133
163
 
134
164
  const port = parseInt(process.env.PORT || '3000', 10);
135
165
 
136
- startServer(agent, { port }).catch((err) => {
166
+ startServer(agent, {
167
+ port${a2aConfig},
168
+ a2aConfig: {
169
+ enabled: true,
170
+ baseUrl: \`http://0.0.0.0:\${port}\`,
171
+ },
172
+ }).catch((err) => {
137
173
  console.error('Failed to start agent:', err);
138
174
  process.exit(1);
139
175
  });
@@ -285,6 +321,7 @@ export async function onShutdown(agent: Agent): Promise<void> {
285
321
  // src/templates/markdown-based/index.ts
286
322
  function markdownTemplate(ctx) {
287
323
  const socialSections = buildSocialSections(ctx.socialPlatforms);
324
+ const a2aSection = ctx.enableA2A !== false ? buildA2ASection() : "";
288
325
  return `# Agent Configuration
289
326
 
290
327
  ## Identity
@@ -299,7 +336,7 @@ detailed trait definitions.
299
336
 
300
337
  ## Social Platforms
301
338
  ${socialSections}
302
-
339
+ ${a2aSection}
303
340
  ## Behaviors
304
341
  autonomous: true
305
342
  decision_making: llm-driven
@@ -372,11 +409,37 @@ Content strategy:
372
409
  - Minimal hashtag use (0-2 per tweet)`);
373
410
  return sections.join("\n\n");
374
411
  }
412
+ function buildA2ASection() {
413
+ return `
414
+ ## A2A Protocol (Agent-to-Agent Communication)
415
+ <!--
416
+ Uncomment to enable communication with other agents.
417
+ When enabled, automatically registers 'talk_to_agent' action.
418
+
419
+ a2a:
420
+ enabled: true
421
+ peers:
422
+ talk_to_analyst: http://localhost:3001
423
+ talk_to_researcher: http://localhost:3002
424
+ verbose: false
425
+ -->
426
+
427
+ `;
428
+ }
375
429
 
376
430
  // src/templates/markdown-based/start.ts
377
431
  function markdownStartTemplate(ctx) {
378
432
  const envKey = ctx.llmProvider === "anthropic" ? "ANTHROPIC_API_KEY" : "OPENAI_API_KEY";
379
433
  const model = ctx.llmProvider === "anthropic" ? "claude-sonnet-4-20250514" : "gpt-4o";
434
+ const a2aComment = ctx.enableA2A !== false ? `// A2A Protocol endpoints are enabled by default:
435
+ // - /.well-known/agent-card.json (Agent discovery)
436
+ // - /a2a/jsonrpc (JSON-RPC transport)
437
+ // - /a2a/rest (HTTP+JSON/REST transport)
438
+ // To disable, pass { enableA2A: false } to startServer()` : `// A2A Protocol is disabled
439
+ // To enable, pass { enableA2A: true } to startServer()`;
440
+ const a2aConfig = ctx.enableA2A !== false ? `,
441
+ enableA2A: true, // Enable A2A Protocol endpoints` : `,
442
+ enableA2A: false`;
380
443
  return `import 'dotenv/config';
381
444
  import { readFileSync, readdirSync, existsSync } from 'node:fs';
382
445
  import { join, basename } from 'node:path';
@@ -392,6 +455,8 @@ import type { AgentConfig } from '@moltium/core';
392
455
  * 3. Registers skills as LLM-interpreted actions
393
456
  * 4. Starts the HTTP server with REST endpoints
394
457
  *
458
+ * ${a2aComment}
459
+ *
395
460
  * Run with: npx tsx start.ts
396
461
  * Or: npm start
397
462
  */
@@ -516,10 +581,12 @@ agent.setHooks({
516
581
  // \u2500\u2500 Start \u2500\u2500
517
582
  const port = parseInt(process.env.PORT || '3000', 10);
518
583
 
519
- startServer(agent, { port }).catch((err) => {
520
- console.error('Failed to start agent:', err);
521
- process.exit(1);
522
- });
584
+ startServer(agent, {
585
+ port${a2aConfig},
586
+ a2aConfig: {
587
+ enabled: true,
588
+ baseUrl: \`http://0.0.0.0:\${port}\`,
589
+ },
523
590
  `;
524
591
  }
525
592
 
@@ -1012,7 +1079,7 @@ function getCoreDepVersion() {
1012
1079
  const corePkg = require2("@moltium/core/package.json");
1013
1080
  return `^${corePkg.version}`;
1014
1081
  } catch {
1015
- return "^0.1.19";
1082
+ return "^0.1.20";
1016
1083
  }
1017
1084
  }
1018
1085
  var initCommand = new Command("init").description("Initialize a new Moltium agent").argument("[name]", "Agent name").action(async (name) => {
@@ -1058,6 +1125,12 @@ var initCommand = new Command("init").description("Initialize a new Moltium agen
1058
1125
  { name: "Twitter", value: "twitter" }
1059
1126
  ]
1060
1127
  },
1128
+ {
1129
+ type: "confirm",
1130
+ name: "enableA2A",
1131
+ message: "Enable A2A Protocol support? (Agent-to-Agent communication)",
1132
+ default: true
1133
+ },
1061
1134
  {
1062
1135
  type: "list",
1063
1136
  name: "deployTarget",
@@ -1238,7 +1311,7 @@ import ora2 from "ora";
1238
1311
  import { config as loadEnv } from "dotenv";
1239
1312
  import { createInterface } from "readline";
1240
1313
  import { ConfigLoader, Agent, MarkdownParser, startServer, AnthropicProvider, OpenAIProvider, buildSystemPrompt } from "@moltium/core";
1241
- var startCommand = new Command2("start").description("Start agent locally").option("-p, --port <number>", "Port to run on", "3000").option("-e, --env <file>", "Environment file", ".env").option("--debug", "Enable debug logging").option("--dry-run", "Test agent in terminal without posting to social platforms").option("--watch", "Watch for file changes (not yet implemented)").action(async (options) => {
1314
+ var startCommand = new Command2("start").description("Start agent locally").option("-p, --port <number>", "Port to run on", "3000").option("-e, --env <file>", "Environment file", ".env").option("--debug", "Enable debug logging").option("--dry-run", "Test agent in terminal without posting to social platforms").option("--no-a2a", "Disable A2A Protocol endpoints").option("--watch", "Watch for file changes (not yet implemented)").action(async (options) => {
1242
1315
  const agentDir = resolve2(process.cwd());
1243
1316
  loadEnv({ path: resolve2(agentDir, options.env) });
1244
1317
  if (options.debug) {
@@ -1275,7 +1348,11 @@ var startCommand = new Command2("start").description("Start agent locally").opti
1275
1348
  await wireMarkdownBasedAgent(agent, agentDir, spinner);
1276
1349
  }
1277
1350
  spinner.succeed(chalk2.green(`Agent "${config.name}" loaded (${type} config)`));
1278
- await startServer(agent, { port: parseInt(options.port, 10) });
1351
+ await startServer(agent, {
1352
+ port: parseInt(options.port, 10),
1353
+ enableA2A: options.a2a !== false
1354
+ // A2A enabled by default, disabled only if --no-a2a is passed
1355
+ });
1279
1356
  } catch (error) {
1280
1357
  spinner.fail(chalk2.red("Failed to start agent"));
1281
1358
  console.error(error instanceof Error ? error.message : error);
@@ -3262,7 +3339,7 @@ Failed to reach agent at ${url}`));
3262
3339
 
3263
3340
  // src/index.ts
3264
3341
  var program = new Command7();
3265
- program.name("moltium").description("Moltium Agent SDK \u2014 create and manage autonomous AI agents").version("0.1.19");
3342
+ program.name("moltium").description("Moltium Agent SDK \u2014 create and manage autonomous AI agents").version("0.1.20");
3266
3343
  program.addCommand(initCommand);
3267
3344
  program.addCommand(startCommand);
3268
3345
  program.addCommand(deployCommand);