@moltium/core 0.1.19 → 0.1.21
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/README.md +231 -0
- package/dist/index.d.cts +330 -3
- package/dist/index.d.ts +330 -3
- package/dist/index.js +903 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +891 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ npm install @moltium/core
|
|
|
18
18
|
- **Social adapters** for Moltbook and Twitter
|
|
19
19
|
- **Action system** with built-in actions, custom actions, and markdown-interpreted skills
|
|
20
20
|
- **HTTP server** (Express) with REST endpoints for monitoring and control
|
|
21
|
+
- **A2A Protocol support** for agent-to-agent communication (JSON-RPC, HTTP+JSON/REST)
|
|
21
22
|
- **Config loader** supporting both TypeScript and Markdown configurations
|
|
22
23
|
|
|
23
24
|
## Quick Start
|
|
@@ -60,6 +61,13 @@ const agent = new Agent(config);
|
|
|
60
61
|
startServer(agent, { port: 3000 });
|
|
61
62
|
```
|
|
62
63
|
|
|
64
|
+
The agent automatically exposes **A2A Protocol endpoints** for agent-to-agent communication:
|
|
65
|
+
- `/.well-known/agent-card.json` - Agent discovery
|
|
66
|
+
- `/a2a/jsonrpc` - JSON-RPC transport
|
|
67
|
+
- `/a2a/rest` - HTTP+JSON/REST transport (v0.3.0)
|
|
68
|
+
|
|
69
|
+
To enable A2A communication actions, add an `a2a` configuration section (see A2A Protocol Integration below).
|
|
70
|
+
|
|
63
71
|
## Agent Lifecycle
|
|
64
72
|
|
|
65
73
|
Agents follow a strict lifecycle: `idle` -> `initializing` -> `running` -> `stopping` -> `stopped`.
|
|
@@ -286,6 +294,220 @@ const { config, type } = await loader.load('./my-agent');
|
|
|
286
294
|
// type is 'code' or 'markdown'
|
|
287
295
|
```
|
|
288
296
|
|
|
297
|
+
## A2A Protocol Integration
|
|
298
|
+
|
|
299
|
+
Moltium includes full support for the [A2A Protocol](https://a2a.ai/) v0.3.0, enabling seamless agent-to-agent communication with automatic action registration and zero boilerplate.
|
|
300
|
+
|
|
301
|
+
### Quick Start
|
|
302
|
+
|
|
303
|
+
Add the `a2a` config section to automatically register communication actions:
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
export default {
|
|
307
|
+
name: 'My Agent',
|
|
308
|
+
// ... other config
|
|
309
|
+
|
|
310
|
+
a2a: {
|
|
311
|
+
enabled: true,
|
|
312
|
+
defaultPeerUrl: 'http://localhost:3001', // Optional default peer
|
|
313
|
+
verbose: true, // Enable detailed logging
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
actions: [
|
|
317
|
+
'talk_to_agent', // Automatically registered when a2a is enabled
|
|
318
|
+
],
|
|
319
|
+
} satisfies AgentConfig;
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Configure your server with A2A support:
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
const port = parseInt(process.env.PORT || '3000', 10);
|
|
326
|
+
|
|
327
|
+
startServer(agent, {
|
|
328
|
+
port,
|
|
329
|
+
enableA2A: true,
|
|
330
|
+
a2aConfig: {
|
|
331
|
+
enabled: true,
|
|
332
|
+
baseUrl: `http://0.0.0.0:${port}`,
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Your agent now exposes:
|
|
338
|
+
- Agent Card at `/.well-known/agent-card.json`
|
|
339
|
+
- JSON-RPC endpoint at `/a2a/jsonrpc`
|
|
340
|
+
- Auto-registered `talk_to_agent` action
|
|
341
|
+
|
|
342
|
+
### Multiple Peer Agents
|
|
343
|
+
|
|
344
|
+
Define specific peer agents for targeted communication:
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
a2a: {
|
|
348
|
+
enabled: true,
|
|
349
|
+
peers: {
|
|
350
|
+
talk_to_analyst: 'http://localhost:3001',
|
|
351
|
+
talk_to_researcher: 'http://localhost:3002',
|
|
352
|
+
talk_to_trader: 'http://localhost:3003',
|
|
353
|
+
},
|
|
354
|
+
verbose: false,
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
actions: [
|
|
358
|
+
'talk_to_analyst', // Auto-registered with pre-configured URL
|
|
359
|
+
'talk_to_researcher', // Auto-registered
|
|
360
|
+
'talk_to_trader', // Auto-registered
|
|
361
|
+
],
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Programmatic A2A Client
|
|
365
|
+
|
|
366
|
+
For custom actions or advanced use cases:
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
import { createA2AClient, A2AClient } from '@moltium/core';
|
|
370
|
+
|
|
371
|
+
// Simple usage
|
|
372
|
+
const client = createA2AClient('http://localhost:3001');
|
|
373
|
+
const response = await client.sendMessage({
|
|
374
|
+
text: 'What are your thoughts on this strategy?',
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
if (response.success) {
|
|
378
|
+
console.log('Reply:', response.reply);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Advanced usage
|
|
382
|
+
const client = new A2AClient({
|
|
383
|
+
agentUrl: 'http://localhost:3001',
|
|
384
|
+
agentCardPath: '.well-known/agent-card.json',
|
|
385
|
+
timeout: 30000,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
const response = await client.sendMessage({
|
|
389
|
+
text: 'Analyze this data',
|
|
390
|
+
contextId: 'analysis-session-123',
|
|
391
|
+
metadata: { priority: 'high' },
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Custom A2A Actions
|
|
396
|
+
|
|
397
|
+
Use action builders for maximum flexibility:
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
import { createA2ACommunicationAction, createMultipleA2AActions } from '@moltium/core';
|
|
401
|
+
|
|
402
|
+
// Single action
|
|
403
|
+
const talkToAnalyst = createA2ACommunicationAction({
|
|
404
|
+
actionName: 'consult_analyst',
|
|
405
|
+
defaultAgentUrl: 'http://localhost:3001',
|
|
406
|
+
description: 'Consult with the business analyst for strategic advice',
|
|
407
|
+
verbose: true,
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Multiple actions at once
|
|
411
|
+
const a2aActions = createMultipleA2AActions({
|
|
412
|
+
ask_technical: {
|
|
413
|
+
defaultAgentUrl: 'http://localhost:3001',
|
|
414
|
+
description: 'Ask technical engineering questions',
|
|
415
|
+
},
|
|
416
|
+
ask_business: {
|
|
417
|
+
defaultAgentUrl: 'http://localhost:3002',
|
|
418
|
+
description: 'Ask business strategy questions',
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
export default {
|
|
423
|
+
customActions: [...a2aActions, talkToAnalyst],
|
|
424
|
+
actions: ['ask_technical', 'ask_business', 'consult_analyst'],
|
|
425
|
+
};
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### A2A API Reference
|
|
429
|
+
|
|
430
|
+
#### `A2AClient`
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
class A2AClient {
|
|
434
|
+
constructor(config: A2AClientConfig)
|
|
435
|
+
sendMessage(options: A2AMessageOptions): Promise<A2AMessageResponse>
|
|
436
|
+
getAgentCard(): Promise<AgentCard>
|
|
437
|
+
getAgentUrl(): string
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
interface A2AClientConfig {
|
|
441
|
+
agentUrl: string;
|
|
442
|
+
agentCardPath?: string; // Default: .well-known/agent-card.json
|
|
443
|
+
timeout?: number; // Default: 30000ms
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
interface A2AMessageOptions {
|
|
447
|
+
text: string;
|
|
448
|
+
contextId?: string;
|
|
449
|
+
metadata?: Record<string, unknown>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
interface A2AMessageResponse {
|
|
453
|
+
success: boolean;
|
|
454
|
+
reply?: string;
|
|
455
|
+
agentUrl?: string;
|
|
456
|
+
error?: string;
|
|
457
|
+
raw?: any;
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
#### Action Builders
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
// Single action builder
|
|
465
|
+
function createA2ACommunicationAction(config: {
|
|
466
|
+
defaultAgentUrl?: string;
|
|
467
|
+
actionName?: string; // Default: 'talk_to_agent'
|
|
468
|
+
description?: string;
|
|
469
|
+
verbose?: boolean;
|
|
470
|
+
}): Action
|
|
471
|
+
|
|
472
|
+
// Multiple actions builder
|
|
473
|
+
function createMultipleA2AActions(
|
|
474
|
+
configs: Record<string, A2ACommunicationActionConfig>
|
|
475
|
+
): Action[]
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Best Practices
|
|
479
|
+
|
|
480
|
+
**Use environment variables for URLs:**
|
|
481
|
+
```typescript
|
|
482
|
+
a2a: {
|
|
483
|
+
peers: {
|
|
484
|
+
talk_to_analyst: process.env.ANALYST_URL || 'http://localhost:3001',
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Enable verbose logging during development:**
|
|
490
|
+
```typescript
|
|
491
|
+
a2a: {
|
|
492
|
+
verbose: true, // Detailed A2A logs
|
|
493
|
+
},
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**Use 0.0.0.0 for local development:**
|
|
497
|
+
```typescript
|
|
498
|
+
a2aConfig: {
|
|
499
|
+
baseUrl: `http://0.0.0.0:${port}`, // Accessible from other agents
|
|
500
|
+
},
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Handle errors gracefully:**
|
|
504
|
+
```typescript
|
|
505
|
+
const response = await client.sendMessage({ text: 'Hello' });
|
|
506
|
+
if (!response.success) {
|
|
507
|
+
console.error('Communication failed:', response.error);
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
289
511
|
## AgentConfig Reference
|
|
290
512
|
|
|
291
513
|
```typescript
|
|
@@ -329,6 +551,15 @@ interface AgentConfig {
|
|
|
329
551
|
actions: string[]; // Built-in action names
|
|
330
552
|
customActions?: Action[]; // User-defined actions
|
|
331
553
|
plugins?: Plugin[];
|
|
554
|
+
|
|
555
|
+
// A2A Protocol configuration (optional)
|
|
556
|
+
a2a?: {
|
|
557
|
+
enabled?: boolean; // Enable A2A support
|
|
558
|
+
peers?: Record<string, string>; // Peer agents: { actionName: 'url' }
|
|
559
|
+
defaultPeerUrl?: string; // Default peer URL
|
|
560
|
+
verbose?: boolean; // Enable detailed logging
|
|
561
|
+
genericActionName?: string; // Custom name for generic action
|
|
562
|
+
};
|
|
332
563
|
}
|
|
333
564
|
```
|
|
334
565
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
|
-
import {
|
|
2
|
+
import { AgentCard } from '@a2a-js/sdk';
|
|
3
|
+
import { RequestHandler, Router } from 'express';
|
|
4
|
+
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
3
5
|
import winston from 'winston';
|
|
4
6
|
|
|
5
7
|
interface MoltbookConfig {
|
|
@@ -82,6 +84,35 @@ interface AgentConfig {
|
|
|
82
84
|
systemPrompt?: string;
|
|
83
85
|
};
|
|
84
86
|
social: SocialConfig;
|
|
87
|
+
/**
|
|
88
|
+
* A2A Protocol Configuration
|
|
89
|
+
* When enabled, automatically registers A2A communication actions
|
|
90
|
+
* @optional
|
|
91
|
+
*/
|
|
92
|
+
a2a?: {
|
|
93
|
+
/**
|
|
94
|
+
* Enable A2A protocol support (defaults to true when a2a config exists)
|
|
95
|
+
*/
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Peer agents this agent can communicate with
|
|
99
|
+
* Key is the action name, value is the agent URL
|
|
100
|
+
* @example { talk_to_analyst: 'http://localhost:3001' }
|
|
101
|
+
*/
|
|
102
|
+
peers?: Record<string, string>;
|
|
103
|
+
/**
|
|
104
|
+
* Default peer agent URL (used when peers not specified)
|
|
105
|
+
*/
|
|
106
|
+
defaultPeerUrl?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Enable verbose A2A logging
|
|
109
|
+
*/
|
|
110
|
+
verbose?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Custom action name for generic A2A communication (defaults to 'talk_to_agent')
|
|
113
|
+
*/
|
|
114
|
+
genericActionName?: string;
|
|
115
|
+
};
|
|
85
116
|
behaviors: {
|
|
86
117
|
autonomous: boolean;
|
|
87
118
|
decisionMaking: 'llm-driven' | 'rule-based' | 'hybrid';
|
|
@@ -102,6 +133,15 @@ interface AgentConfig {
|
|
|
102
133
|
actions: string[];
|
|
103
134
|
customActions?: Action[];
|
|
104
135
|
scheduling?: ScheduledTask[];
|
|
136
|
+
/** World SDK integration — connect this agent to a world */
|
|
137
|
+
world?: {
|
|
138
|
+
/** URL of the world to join */
|
|
139
|
+
url: string;
|
|
140
|
+
/** Wallet address for blockchain-enabled worlds */
|
|
141
|
+
walletAddress?: string;
|
|
142
|
+
/** Auto-join the world when agent starts (default: true) */
|
|
143
|
+
autoJoin?: boolean;
|
|
144
|
+
};
|
|
105
145
|
webhooks?: {
|
|
106
146
|
onAction?: string | ((action: any, result: any) => Promise<void>);
|
|
107
147
|
onError?: string;
|
|
@@ -507,6 +547,7 @@ declare class Agent {
|
|
|
507
547
|
private scheduledPost;
|
|
508
548
|
private executeScheduledTask;
|
|
509
549
|
private logPlatformError;
|
|
550
|
+
private autoJoinWorld;
|
|
510
551
|
private startAutonomousLoop;
|
|
511
552
|
private isSleeping;
|
|
512
553
|
private gatherContext;
|
|
@@ -554,6 +595,7 @@ declare class MarkdownParser {
|
|
|
554
595
|
private parseSocial;
|
|
555
596
|
private parseBehaviors;
|
|
556
597
|
private parseMemory;
|
|
598
|
+
private parseWorld;
|
|
557
599
|
private parseSleepSchedule;
|
|
558
600
|
private parseKeyValueLines;
|
|
559
601
|
private parseScheduling;
|
|
@@ -737,17 +779,302 @@ declare function createMarkdownAction(name: string, description: string, llmProv
|
|
|
737
779
|
/** All Moltbook-specific actions */
|
|
738
780
|
declare const moltbookActions: Action[];
|
|
739
781
|
|
|
782
|
+
/**
|
|
783
|
+
* ============================================================================
|
|
784
|
+
* WORLD SDK BUILT-IN ACTIONS
|
|
785
|
+
* ============================================================================
|
|
786
|
+
*
|
|
787
|
+
* Built-in actions for agents to interact with worlds created using
|
|
788
|
+
* @moltium/world-core. These use plain HTTP to call the world's REST endpoints.
|
|
789
|
+
*/
|
|
790
|
+
/**
|
|
791
|
+
* Creates a join_world action that POSTs to a world's /world/join endpoint
|
|
792
|
+
*/
|
|
793
|
+
declare function createJoinWorldAction(config?: {
|
|
794
|
+
defaultWorldUrl?: string;
|
|
795
|
+
}): Action;
|
|
796
|
+
/**
|
|
797
|
+
* Creates a leave_world action that DELETEs from a world's /world/agents endpoint
|
|
798
|
+
*/
|
|
799
|
+
declare function createLeaveWorldAction(config?: {
|
|
800
|
+
defaultWorldUrl?: string;
|
|
801
|
+
}): Action;
|
|
802
|
+
/**
|
|
803
|
+
* Creates a query_world action that GETs world state and info
|
|
804
|
+
*/
|
|
805
|
+
declare function createQueryWorldAction(config?: {
|
|
806
|
+
defaultWorldUrl?: string;
|
|
807
|
+
}): Action;
|
|
808
|
+
/**
|
|
809
|
+
* Creates a send_world_message action for agent-to-agent messaging through a world
|
|
810
|
+
*/
|
|
811
|
+
declare function createSendWorldMessageAction(config?: {
|
|
812
|
+
defaultWorldUrl?: string;
|
|
813
|
+
}): Action;
|
|
814
|
+
/**
|
|
815
|
+
* All world actions as a convenience array
|
|
816
|
+
*/
|
|
817
|
+
declare const worldActions: {
|
|
818
|
+
createJoinWorldAction: typeof createJoinWorldAction;
|
|
819
|
+
createLeaveWorldAction: typeof createLeaveWorldAction;
|
|
820
|
+
createQueryWorldAction: typeof createQueryWorldAction;
|
|
821
|
+
createSendWorldMessageAction: typeof createSendWorldMessageAction;
|
|
822
|
+
};
|
|
823
|
+
|
|
740
824
|
declare const builtInActions: Action[];
|
|
741
825
|
|
|
826
|
+
interface A2AConfig {
|
|
827
|
+
enabled: boolean;
|
|
828
|
+
baseUrl: string;
|
|
829
|
+
port?: number;
|
|
830
|
+
pushNotifications?: boolean;
|
|
831
|
+
streaming?: boolean;
|
|
832
|
+
stateTransitionHistory?: boolean;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Builds an A2A-compliant AgentCard from a Moltium AgentConfig.
|
|
836
|
+
*/
|
|
837
|
+
declare class AgentCardBuilder {
|
|
838
|
+
/**
|
|
839
|
+
* Creates an A2A AgentCard from Moltium configuration.
|
|
840
|
+
* @param config The Moltium agent configuration
|
|
841
|
+
* @param a2aConfig A2A-specific configuration (URLs, capabilities)
|
|
842
|
+
* @returns A2A-compliant AgentCard
|
|
843
|
+
*/
|
|
844
|
+
static build(config: AgentConfig, a2aConfig: A2AConfig): AgentCard;
|
|
845
|
+
/**
|
|
846
|
+
* Converts Moltium actions to A2A skills.
|
|
847
|
+
*/
|
|
848
|
+
private static buildSkills;
|
|
849
|
+
/**
|
|
850
|
+
* Updates an agent card with runtime information.
|
|
851
|
+
*/
|
|
852
|
+
static updateWithRuntime(agentCard: AgentCard, actualPort: number, actualHost?: string): AgentCard;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Adapts a Moltium Agent to the A2A AgentExecutor interface.
|
|
857
|
+
* This allows Moltium agents to respond to A2A protocol requests.
|
|
858
|
+
*/
|
|
859
|
+
declare class MoltiumExecutor implements AgentExecutor {
|
|
860
|
+
private agent;
|
|
861
|
+
private cancelledTasks;
|
|
862
|
+
constructor(agent: Agent);
|
|
863
|
+
/**
|
|
864
|
+
* Executes an A2A request using the Moltium agent.
|
|
865
|
+
* Converts A2A messages to Moltium actions and publishes results back via the event bus.
|
|
866
|
+
*/
|
|
867
|
+
execute(requestContext: RequestContext, eventBus: ExecutionEventBus): Promise<void>;
|
|
868
|
+
/**
|
|
869
|
+
* Handles task cancellation requests.
|
|
870
|
+
*/
|
|
871
|
+
cancelTask(taskId: string, eventBus: ExecutionEventBus): Promise<void>;
|
|
872
|
+
/**
|
|
873
|
+
* Extracts text content from an A2A message.
|
|
874
|
+
*/
|
|
875
|
+
private extractMessageContent;
|
|
876
|
+
/**
|
|
877
|
+
* Determines if the user message is requesting a specific action.
|
|
878
|
+
*/
|
|
879
|
+
private isActionRequest;
|
|
880
|
+
/**
|
|
881
|
+
* Executes a chat interaction using the agent's LLM.
|
|
882
|
+
*/
|
|
883
|
+
private executeChat;
|
|
884
|
+
/**
|
|
885
|
+
* Executes an action based on the user's request.
|
|
886
|
+
*/
|
|
887
|
+
private executeAction;
|
|
888
|
+
/**
|
|
889
|
+
* Publishes a successful result as an A2A artifact.
|
|
890
|
+
*/
|
|
891
|
+
private publishResult;
|
|
892
|
+
/**
|
|
893
|
+
* Publishes an error as an A2A artifact.
|
|
894
|
+
*/
|
|
895
|
+
private publishError;
|
|
896
|
+
/**
|
|
897
|
+
* Publishes a status update event.
|
|
898
|
+
*/
|
|
899
|
+
private publishStatusUpdate;
|
|
900
|
+
/**
|
|
901
|
+
* Publishes a cancellation status.
|
|
902
|
+
*/
|
|
903
|
+
private publishCancellation;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
interface A2AServerOptions {
|
|
907
|
+
a2aConfig: A2AConfig;
|
|
908
|
+
authToken?: string;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Creates A2A-compliant Express routes for a Moltium agent.
|
|
912
|
+
* These routes implement the Agent-to-Agent (A2A) protocol.
|
|
913
|
+
*/
|
|
914
|
+
declare class A2AIntegration {
|
|
915
|
+
private agent;
|
|
916
|
+
private agentCard;
|
|
917
|
+
private requestHandler;
|
|
918
|
+
private moltiumExecutor;
|
|
919
|
+
constructor(agent: Agent, options: A2AServerOptions);
|
|
920
|
+
/**
|
|
921
|
+
* Creates Express middleware handlers for A2A endpoints.
|
|
922
|
+
* Returns an object with individual handlers that can be mounted on specific routes.
|
|
923
|
+
*/
|
|
924
|
+
getHandlers(): {
|
|
925
|
+
agentCard: RequestHandler;
|
|
926
|
+
jsonRpc: RequestHandler;
|
|
927
|
+
rest: RequestHandler;
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* Updates the agent card with actual runtime information (host/port).
|
|
931
|
+
*/
|
|
932
|
+
updateAgentCard(actualPort: number, actualHost?: string): void;
|
|
933
|
+
/**
|
|
934
|
+
* Gets the current agent card.
|
|
935
|
+
*/
|
|
936
|
+
getAgentCard(): AgentCard;
|
|
937
|
+
/**
|
|
938
|
+
* Logs A2A endpoint information.
|
|
939
|
+
*/
|
|
940
|
+
logEndpoints(host: string, port: number): void;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Helper function to create and configure A2A integration for a Moltium agent.
|
|
944
|
+
*/
|
|
945
|
+
declare function createA2AIntegration(agent: Agent, options?: Partial<A2AServerOptions>): A2AIntegration;
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Configuration for A2A client operations
|
|
949
|
+
*/
|
|
950
|
+
interface A2AClientConfig {
|
|
951
|
+
/**
|
|
952
|
+
* The base URL of the target agent
|
|
953
|
+
* @example 'http://localhost:3001'
|
|
954
|
+
*/
|
|
955
|
+
agentUrl: string;
|
|
956
|
+
/**
|
|
957
|
+
* Path to the agent card (defaults to '.well-known/agent-card.json')
|
|
958
|
+
*/
|
|
959
|
+
agentCardPath?: string;
|
|
960
|
+
/**
|
|
961
|
+
* Timeout for requests in milliseconds (optional)
|
|
962
|
+
*/
|
|
963
|
+
timeout?: number;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Options for sending messages via A2A
|
|
967
|
+
*/
|
|
968
|
+
interface A2AMessageOptions {
|
|
969
|
+
/**
|
|
970
|
+
* The text message to send
|
|
971
|
+
*/
|
|
972
|
+
text: string;
|
|
973
|
+
/**
|
|
974
|
+
* Optional context ID to group related messages
|
|
975
|
+
*/
|
|
976
|
+
contextId?: string;
|
|
977
|
+
/**
|
|
978
|
+
* Optional metadata for extensions
|
|
979
|
+
*/
|
|
980
|
+
metadata?: Record<string, unknown>;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Response from an A2A message
|
|
984
|
+
*/
|
|
985
|
+
interface A2AMessageResponse {
|
|
986
|
+
/**
|
|
987
|
+
* Whether the message was successfully sent and received
|
|
988
|
+
*/
|
|
989
|
+
success: boolean;
|
|
990
|
+
/**
|
|
991
|
+
* The reply text from the agent (if successful)
|
|
992
|
+
*/
|
|
993
|
+
reply?: string;
|
|
994
|
+
/**
|
|
995
|
+
* The agent URL that responded
|
|
996
|
+
*/
|
|
997
|
+
agentUrl?: string;
|
|
998
|
+
/**
|
|
999
|
+
* Error message (if failed)
|
|
1000
|
+
*/
|
|
1001
|
+
error?: string;
|
|
1002
|
+
/**
|
|
1003
|
+
* Raw response from the A2A protocol (for advanced use)
|
|
1004
|
+
*/
|
|
1005
|
+
raw?: any;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Wrapper around A2A Client SDK with improved developer experience
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```typescript
|
|
1012
|
+
* const client = new A2AClient({ agentUrl: 'http://localhost:3001' });
|
|
1013
|
+
* const response = await client.sendMessage({ text: 'Hello!' });
|
|
1014
|
+
* console.log(response.reply);
|
|
1015
|
+
* ```
|
|
1016
|
+
*/
|
|
1017
|
+
declare class A2AClient {
|
|
1018
|
+
private sdkClient;
|
|
1019
|
+
private config;
|
|
1020
|
+
constructor(config: A2AClientConfig);
|
|
1021
|
+
/**
|
|
1022
|
+
* Send a text message to the agent and get a response
|
|
1023
|
+
*
|
|
1024
|
+
* @param options Message options including text content
|
|
1025
|
+
* @returns Promise resolving to the agent's response
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```typescript
|
|
1029
|
+
* const response = await client.sendMessage({
|
|
1030
|
+
* text: 'What are your thoughts on AI?',
|
|
1031
|
+
* contextId: 'conversation-123'
|
|
1032
|
+
* });
|
|
1033
|
+
*
|
|
1034
|
+
* if (response.success) {
|
|
1035
|
+
* console.log('Agent replied:', response.reply);
|
|
1036
|
+
* }
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1039
|
+
sendMessage(options: A2AMessageOptions): Promise<A2AMessageResponse>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Extract text reply from A2A protocol response
|
|
1042
|
+
* Handles both Message and Task response types
|
|
1043
|
+
*/
|
|
1044
|
+
private extractReply;
|
|
1045
|
+
/**
|
|
1046
|
+
* Get the agent card information
|
|
1047
|
+
*
|
|
1048
|
+
* @returns Promise resolving to the agent card
|
|
1049
|
+
*/
|
|
1050
|
+
getAgentCard(): Promise<any>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Get the base URL of the agent
|
|
1053
|
+
*/
|
|
1054
|
+
getAgentUrl(): string;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Factory function to create A2A clients easily
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```typescript
|
|
1061
|
+
* const client = createA2AClient('http://localhost:3001');
|
|
1062
|
+
* const response = await client.sendMessage({ text: 'Hello!' });
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
declare function createA2AClient(agentUrlOrConfig: string | A2AClientConfig): A2AClient;
|
|
1066
|
+
|
|
742
1067
|
interface ServerOptions {
|
|
743
1068
|
port?: number;
|
|
744
1069
|
host?: string;
|
|
1070
|
+
enableA2A?: boolean;
|
|
1071
|
+
a2aConfig?: A2AServerOptions['a2aConfig'];
|
|
745
1072
|
}
|
|
746
|
-
declare function createApp(agent: Agent): express_serve_static_core.Express;
|
|
1073
|
+
declare function createApp(agent: Agent, options?: ServerOptions): express_serve_static_core.Express;
|
|
747
1074
|
declare function startServer(agent: Agent, options?: ServerOptions): Promise<void>;
|
|
748
1075
|
|
|
749
1076
|
declare function createRoutes(agent: Agent): Router;
|
|
750
1077
|
|
|
751
1078
|
declare function createLogger(label: string): winston.Logger;
|
|
752
1079
|
|
|
753
|
-
export { type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, type AgentConfig, type AgentState, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createApp, createLogger, createMarkdownAction, createRoutes, moltbookActions, startServer, validateConfig };
|
|
1080
|
+
export { A2AClient, type A2AClientConfig, type A2AConfig, A2AIntegration, type A2AMessageOptions, type A2AMessageResponse, type A2AServerOptions, type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, AgentCardBuilder, type AgentConfig, type AgentState, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, MoltiumExecutor, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, type ServerOptions, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createA2AClient, createA2AIntegration, createApp, createJoinWorldAction, createLeaveWorldAction, createLogger, createMarkdownAction, createQueryWorldAction, createRoutes, createSendWorldMessageAction, moltbookActions, startServer, validateConfig, worldActions };
|