@moltium/core 0.1.18 → 0.1.19
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.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +263 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +262 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -468,6 +468,8 @@ declare class Agent {
|
|
|
468
468
|
private tickTimer?;
|
|
469
469
|
private systemPrompt;
|
|
470
470
|
socialAdapters: Record<string, SocialAdapter>;
|
|
471
|
+
private recentActions;
|
|
472
|
+
private tickCount;
|
|
471
473
|
constructor(config: AgentConfig, hooks?: LifecycleHooks);
|
|
472
474
|
get name(): string;
|
|
473
475
|
getState(): AgentState;
|
|
@@ -732,6 +734,9 @@ declare class ActionHandler {
|
|
|
732
734
|
*/
|
|
733
735
|
declare function createMarkdownAction(name: string, description: string, llmProvider: LLMProvider): Action;
|
|
734
736
|
|
|
737
|
+
/** All Moltbook-specific actions */
|
|
738
|
+
declare const moltbookActions: Action[];
|
|
739
|
+
|
|
735
740
|
declare const builtInActions: Action[];
|
|
736
741
|
|
|
737
742
|
interface ServerOptions {
|
|
@@ -745,4 +750,4 @@ declare function createRoutes(agent: Agent): Router;
|
|
|
745
750
|
|
|
746
751
|
declare function createLogger(label: string): winston.Logger;
|
|
747
752
|
|
|
748
|
-
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, startServer, validateConfig };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -468,6 +468,8 @@ declare class Agent {
|
|
|
468
468
|
private tickTimer?;
|
|
469
469
|
private systemPrompt;
|
|
470
470
|
socialAdapters: Record<string, SocialAdapter>;
|
|
471
|
+
private recentActions;
|
|
472
|
+
private tickCount;
|
|
471
473
|
constructor(config: AgentConfig, hooks?: LifecycleHooks);
|
|
472
474
|
get name(): string;
|
|
473
475
|
getState(): AgentState;
|
|
@@ -732,6 +734,9 @@ declare class ActionHandler {
|
|
|
732
734
|
*/
|
|
733
735
|
declare function createMarkdownAction(name: string, description: string, llmProvider: LLMProvider): Action;
|
|
734
736
|
|
|
737
|
+
/** All Moltbook-specific actions */
|
|
738
|
+
declare const moltbookActions: Action[];
|
|
739
|
+
|
|
735
740
|
declare const builtInActions: Action[];
|
|
736
741
|
|
|
737
742
|
interface ServerOptions {
|
|
@@ -745,4 +750,4 @@ declare function createRoutes(agent: Agent): Router;
|
|
|
745
750
|
|
|
746
751
|
declare function createLogger(label: string): winston.Logger;
|
|
747
752
|
|
|
748
|
-
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, startServer, validateConfig };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
createLogger: () => createLogger,
|
|
54
54
|
createMarkdownAction: () => createMarkdownAction,
|
|
55
55
|
createRoutes: () => createRoutes,
|
|
56
|
+
moltbookActions: () => moltbookActions,
|
|
56
57
|
startServer: () => startServer,
|
|
57
58
|
validateConfig: () => validateConfig
|
|
58
59
|
});
|
|
@@ -276,12 +277,221 @@ var scheduleTaskAction = {
|
|
|
276
277
|
}
|
|
277
278
|
};
|
|
278
279
|
|
|
280
|
+
// src/actions/built-in/moltbook.ts
|
|
281
|
+
function getMoltbook(context) {
|
|
282
|
+
return context.agent?.socialAdapters?.["moltbook"] || null;
|
|
283
|
+
}
|
|
284
|
+
var checkFeedAction = {
|
|
285
|
+
name: "check_feed",
|
|
286
|
+
description: "Browse the moltbook feed (personalized or global) to find posts to engage with",
|
|
287
|
+
async execute(context) {
|
|
288
|
+
const mb = getMoltbook(context);
|
|
289
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
290
|
+
const { sort, limit, global: useGlobal } = context.parameters;
|
|
291
|
+
try {
|
|
292
|
+
const posts = useGlobal ? await mb.getGlobalFeed({ sort: sort || "hot", limit: limit || 15 }) : await mb.getFeed({ sort: sort || "new", limit: limit || 15 });
|
|
293
|
+
return { success: true, data: { posts, count: posts.length } };
|
|
294
|
+
} catch (error) {
|
|
295
|
+
return { success: false, error: error.message };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var checkDMsAction = {
|
|
300
|
+
name: "check_dms",
|
|
301
|
+
description: "Check for new DM requests and unread messages from other agents",
|
|
302
|
+
async execute(context) {
|
|
303
|
+
const mb = getMoltbook(context);
|
|
304
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
305
|
+
try {
|
|
306
|
+
const result = await mb.checkDMs();
|
|
307
|
+
return { success: true, data: result };
|
|
308
|
+
} catch (error) {
|
|
309
|
+
return { success: false, error: error.message };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
var searchMoltbookAction = {
|
|
314
|
+
name: "search_moltbook",
|
|
315
|
+
description: 'Search moltbook for posts and comments by meaning (semantic search). Params: { "query": "..." }',
|
|
316
|
+
async execute(context) {
|
|
317
|
+
const mb = getMoltbook(context);
|
|
318
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
319
|
+
const { query, limit } = context.parameters;
|
|
320
|
+
if (!query) return { success: false, error: "Missing required parameter: query" };
|
|
321
|
+
try {
|
|
322
|
+
const results = await mb.search(query, { limit: limit || 10 });
|
|
323
|
+
return { success: true, data: { results, count: results.length } };
|
|
324
|
+
} catch (error) {
|
|
325
|
+
return { success: false, error: error.message };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var commentOnPostAction = {
|
|
330
|
+
name: "comment_on_post",
|
|
331
|
+
description: 'Reply to a post with a comment. Params: { "post_id": "...", "content": "..." }',
|
|
332
|
+
async execute(context) {
|
|
333
|
+
const mb = getMoltbook(context);
|
|
334
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
335
|
+
const { post_id, content } = context.parameters;
|
|
336
|
+
if (!post_id || !content) return { success: false, error: "Missing required parameters: post_id, content" };
|
|
337
|
+
try {
|
|
338
|
+
const result = await mb.reply(post_id, content);
|
|
339
|
+
return { success: true, data: result };
|
|
340
|
+
} catch (error) {
|
|
341
|
+
return { success: false, error: error.message };
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var upvotePostAction = {
|
|
346
|
+
name: "upvote_post",
|
|
347
|
+
description: 'Upvote a post you find valuable. Params: { "post_id": "..." }',
|
|
348
|
+
async execute(context) {
|
|
349
|
+
const mb = getMoltbook(context);
|
|
350
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
351
|
+
const { post_id } = context.parameters;
|
|
352
|
+
if (!post_id) return { success: false, error: "Missing required parameter: post_id" };
|
|
353
|
+
try {
|
|
354
|
+
await mb.like(post_id);
|
|
355
|
+
return { success: true, data: { post_id, action: "upvoted" } };
|
|
356
|
+
} catch (error) {
|
|
357
|
+
return { success: false, error: error.message };
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var downvotePostAction = {
|
|
362
|
+
name: "downvote_post",
|
|
363
|
+
description: 'Downvote a post you disagree with. Params: { "post_id": "..." }',
|
|
364
|
+
async execute(context) {
|
|
365
|
+
const mb = getMoltbook(context);
|
|
366
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
367
|
+
const { post_id } = context.parameters;
|
|
368
|
+
if (!post_id) return { success: false, error: "Missing required parameter: post_id" };
|
|
369
|
+
try {
|
|
370
|
+
await mb.downvote(post_id);
|
|
371
|
+
return { success: true, data: { post_id, action: "downvoted" } };
|
|
372
|
+
} catch (error) {
|
|
373
|
+
return { success: false, error: error.message };
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
var browseSubmoltsAction = {
|
|
378
|
+
name: "browse_submolts",
|
|
379
|
+
description: "Discover moltbook communities (submolts) to subscribe to",
|
|
380
|
+
async execute(context) {
|
|
381
|
+
const mb = getMoltbook(context);
|
|
382
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
383
|
+
try {
|
|
384
|
+
const submolts = await mb.listSubmolts();
|
|
385
|
+
return { success: true, data: { submolts, count: submolts.length } };
|
|
386
|
+
} catch (error) {
|
|
387
|
+
return { success: false, error: error.message };
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var followAgentAction = {
|
|
392
|
+
name: "follow_agent",
|
|
393
|
+
description: 'Follow another agent whose posts you enjoy. Params: { "agent_name": "..." }',
|
|
394
|
+
async execute(context) {
|
|
395
|
+
const mb = getMoltbook(context);
|
|
396
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
397
|
+
const { agent_name } = context.parameters;
|
|
398
|
+
if (!agent_name) return { success: false, error: "Missing required parameter: agent_name" };
|
|
399
|
+
try {
|
|
400
|
+
await mb.follow(agent_name);
|
|
401
|
+
return { success: true, data: { agent_name, action: "followed" } };
|
|
402
|
+
} catch (error) {
|
|
403
|
+
return { success: false, error: error.message };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
var sendDMRequestAction = {
|
|
408
|
+
name: "send_dm_request",
|
|
409
|
+
description: 'Request to start a private conversation with another agent. Params: { "to": "...", "message": "..." }',
|
|
410
|
+
async execute(context) {
|
|
411
|
+
const mb = getMoltbook(context);
|
|
412
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
413
|
+
const { to, to_owner, message } = context.parameters;
|
|
414
|
+
if (!to && !to_owner || !message) return { success: false, error: "Missing required parameters: (to or to_owner), message" };
|
|
415
|
+
try {
|
|
416
|
+
const target = to || to_owner || "";
|
|
417
|
+
const byOwner = !to && !!to_owner;
|
|
418
|
+
const result = await mb.sendDMRequest(target, message, byOwner);
|
|
419
|
+
return { success: true, data: result };
|
|
420
|
+
} catch (error) {
|
|
421
|
+
return { success: false, error: error.message };
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var sendDMAction = {
|
|
426
|
+
name: "send_dm",
|
|
427
|
+
description: 'Send a message in an existing DM conversation. Params: { "conversation_id": "...", "message": "..." }',
|
|
428
|
+
async execute(context) {
|
|
429
|
+
const mb = getMoltbook(context);
|
|
430
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
431
|
+
const { conversation_id, message, needs_human_input } = context.parameters;
|
|
432
|
+
if (!conversation_id || !message) return { success: false, error: "Missing required parameters: conversation_id, message" };
|
|
433
|
+
try {
|
|
434
|
+
const result = await mb.sendDM(conversation_id, message, needs_human_input);
|
|
435
|
+
return { success: true, data: result };
|
|
436
|
+
} catch (error) {
|
|
437
|
+
return { success: false, error: error.message };
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
var approveDMRequestAction = {
|
|
442
|
+
name: "approve_dm_request",
|
|
443
|
+
description: 'Approve a pending DM request from another agent. Params: { "conversation_id": "..." }',
|
|
444
|
+
async execute(context) {
|
|
445
|
+
const mb = getMoltbook(context);
|
|
446
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
447
|
+
const { conversation_id } = context.parameters;
|
|
448
|
+
if (!conversation_id) return { success: false, error: "Missing required parameter: conversation_id" };
|
|
449
|
+
try {
|
|
450
|
+
await mb.approveDMRequest(conversation_id);
|
|
451
|
+
return { success: true, data: { conversation_id, action: "approved" } };
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return { success: false, error: error.message };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var readConversationAction = {
|
|
458
|
+
name: "read_conversation",
|
|
459
|
+
description: 'Read messages in a DM conversation (marks as read). Params: { "conversation_id": "..." }',
|
|
460
|
+
async execute(context) {
|
|
461
|
+
const mb = getMoltbook(context);
|
|
462
|
+
if (!mb) return { success: false, error: "Moltbook not connected" };
|
|
463
|
+
const { conversation_id } = context.parameters;
|
|
464
|
+
if (!conversation_id) return { success: false, error: "Missing required parameter: conversation_id" };
|
|
465
|
+
try {
|
|
466
|
+
const detail = await mb.readConversation(conversation_id);
|
|
467
|
+
return { success: true, data: detail };
|
|
468
|
+
} catch (error) {
|
|
469
|
+
return { success: false, error: error.message };
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var moltbookActions = [
|
|
474
|
+
checkFeedAction,
|
|
475
|
+
checkDMsAction,
|
|
476
|
+
searchMoltbookAction,
|
|
477
|
+
commentOnPostAction,
|
|
478
|
+
upvotePostAction,
|
|
479
|
+
downvotePostAction,
|
|
480
|
+
browseSubmoltsAction,
|
|
481
|
+
followAgentAction,
|
|
482
|
+
sendDMRequestAction,
|
|
483
|
+
sendDMAction,
|
|
484
|
+
approveDMRequestAction,
|
|
485
|
+
readConversationAction
|
|
486
|
+
];
|
|
487
|
+
|
|
279
488
|
// src/actions/built-in/index.ts
|
|
280
489
|
var builtInActions = [
|
|
281
490
|
postSocialUpdateAction,
|
|
282
491
|
respondToMentionAction,
|
|
283
492
|
dmUserAction,
|
|
284
|
-
scheduleTaskAction
|
|
493
|
+
scheduleTaskAction,
|
|
494
|
+
...moltbookActions
|
|
285
495
|
];
|
|
286
496
|
|
|
287
497
|
// src/llm/prompt.ts
|
|
@@ -308,18 +518,33 @@ ${config.llm.systemPrompt}`);
|
|
|
308
518
|
}
|
|
309
519
|
function buildDecisionPrompt(context, availableActions) {
|
|
310
520
|
const actionList = availableActions.map((a) => `- ${a.name}: ${a.description}`).join("\n");
|
|
311
|
-
|
|
521
|
+
const recent = context.recentActions || [];
|
|
522
|
+
const recentNames = recent.map((r) => r.action);
|
|
523
|
+
const lastAction = recentNames.length > 0 ? recentNames[recentNames.length - 1] : "none";
|
|
524
|
+
let varietyHint = "";
|
|
525
|
+
if (recentNames.length > 0) {
|
|
526
|
+
varietyHint = `
|
|
527
|
+
Your recent actions (most recent last): ${recentNames.join(" \u2192 ")}
|
|
528
|
+
IMPORTANT: Do NOT repeat "${lastAction}" again. Choose a DIFFERENT action to keep your behavior varied and interesting.
|
|
529
|
+
Vary between: posting content, checking your feed, replying to others, checking DMs, browsing communities, searching for topics, and following interesting agents.`;
|
|
530
|
+
}
|
|
531
|
+
return `You are an autonomous AI agent on moltbook (a social network for AI agents).
|
|
532
|
+
Decide what action to take next based on the current context and your personality.
|
|
312
533
|
|
|
313
534
|
Available actions:
|
|
314
535
|
${actionList}
|
|
315
536
|
|
|
316
537
|
Current context:
|
|
317
538
|
${JSON.stringify(context, null, 2)}
|
|
539
|
+
${varietyHint}
|
|
540
|
+
|
|
541
|
+
Think about what would be most natural and valuable right now.
|
|
542
|
+
If the action generates content (post, comment, DM), include the actual content in parameters.
|
|
318
543
|
|
|
319
544
|
Respond with a JSON object:
|
|
320
545
|
{
|
|
321
546
|
"action": "<action_name>",
|
|
322
|
-
"reasoning": "<brief explanation>",
|
|
547
|
+
"reasoning": "<brief explanation of why you chose this>",
|
|
323
548
|
"parameters": { <any parameters for the action> }
|
|
324
549
|
}`;
|
|
325
550
|
}
|
|
@@ -1195,6 +1420,8 @@ var Agent = class {
|
|
|
1195
1420
|
tickTimer;
|
|
1196
1421
|
systemPrompt;
|
|
1197
1422
|
socialAdapters = {};
|
|
1423
|
+
recentActions = [];
|
|
1424
|
+
tickCount = 0;
|
|
1198
1425
|
constructor(config, hooks) {
|
|
1199
1426
|
this.config = config;
|
|
1200
1427
|
this.hooks = hooks || {};
|
|
@@ -1329,13 +1556,29 @@ var Agent = class {
|
|
|
1329
1556
|
}
|
|
1330
1557
|
async tick() {
|
|
1331
1558
|
if (this.state !== "running") return;
|
|
1559
|
+
this.tickCount++;
|
|
1332
1560
|
try {
|
|
1333
1561
|
if (this.hooks.onTick) {
|
|
1334
1562
|
await this.hooks.onTick(this);
|
|
1335
1563
|
}
|
|
1336
|
-
if (this.isSleeping())
|
|
1564
|
+
if (this.isSleeping()) {
|
|
1565
|
+
logger4.info(`Tick #${this.tickCount}: Sleeping \u2014 skipped`);
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
logger4.info(`Tick #${this.tickCount}: Thinking...`);
|
|
1337
1569
|
const decision = await this.think();
|
|
1570
|
+
logger4.info(`Tick #${this.tickCount}: Decision \u2192 ${decision.action} | Reasoning: ${decision.reasoning}`);
|
|
1571
|
+
if (decision.parameters && Object.keys(decision.parameters).length > 0) {
|
|
1572
|
+
logger4.info(`Tick #${this.tickCount}: Parameters \u2192 ${JSON.stringify(decision.parameters)}`);
|
|
1573
|
+
}
|
|
1338
1574
|
const result = await this.act(decision.action, decision.parameters);
|
|
1575
|
+
logger4.info(`Tick #${this.tickCount}: Result \u2192 success=${result.success}${result.data ? ` data=${JSON.stringify(result.data).slice(0, 200)}` : ""}`);
|
|
1576
|
+
this.recentActions.push({
|
|
1577
|
+
action: decision.action,
|
|
1578
|
+
reasoning: decision.reasoning,
|
|
1579
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
1580
|
+
});
|
|
1581
|
+
if (this.recentActions.length > 10) this.recentActions.shift();
|
|
1339
1582
|
await this.learn({
|
|
1340
1583
|
type: "action",
|
|
1341
1584
|
action: decision.action,
|
|
@@ -1347,7 +1590,7 @@ var Agent = class {
|
|
|
1347
1590
|
await this.fireWebhook("onAction", decision, result);
|
|
1348
1591
|
}
|
|
1349
1592
|
} catch (error) {
|
|
1350
|
-
logger4.error(`Tick error: ${error instanceof Error ? error.message : error}`);
|
|
1593
|
+
logger4.error(`Tick #${this.tickCount} error: ${error instanceof Error ? error.message : error}`);
|
|
1351
1594
|
if (this.hooks.onError && error instanceof Error) {
|
|
1352
1595
|
await this.hooks.onError(error, this);
|
|
1353
1596
|
}
|
|
@@ -1380,6 +1623,15 @@ var Agent = class {
|
|
|
1380
1623
|
this.actionRegistry.register(action);
|
|
1381
1624
|
}
|
|
1382
1625
|
}
|
|
1626
|
+
const mb = this.config.social.moltbook;
|
|
1627
|
+
if (mb && mb.enabled !== false) {
|
|
1628
|
+
for (const action of moltbookActions) {
|
|
1629
|
+
if (!this.actionRegistry.has(action.name)) {
|
|
1630
|
+
this.actionRegistry.register(action);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
logger4.info(`Registered ${moltbookActions.length} Moltbook actions`);
|
|
1634
|
+
}
|
|
1383
1635
|
if (this.config.customActions) {
|
|
1384
1636
|
for (const action of this.config.customActions) {
|
|
1385
1637
|
this.actionRegistry.register(action);
|
|
@@ -1688,7 +1940,11 @@ Decide what action to take. Respond with JSON:
|
|
|
1688
1940
|
agentType: this.config.type,
|
|
1689
1941
|
currentTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1690
1942
|
state: this.state,
|
|
1691
|
-
|
|
1943
|
+
tickNumber: this.tickCount,
|
|
1944
|
+
personality: this.config.personality.traits,
|
|
1945
|
+
connectedPlatforms: Object.keys(this.socialAdapters),
|
|
1946
|
+
recentActions: this.recentActions.slice(-5),
|
|
1947
|
+
scheduledTasks: (this.config.scheduling || []).map((t) => t.name)
|
|
1692
1948
|
};
|
|
1693
1949
|
}
|
|
1694
1950
|
async fireWebhook(event, ...args) {
|
|
@@ -2417,6 +2673,7 @@ async function startServer(agent, options = {}) {
|
|
|
2417
2673
|
createLogger,
|
|
2418
2674
|
createMarkdownAction,
|
|
2419
2675
|
createRoutes,
|
|
2676
|
+
moltbookActions,
|
|
2420
2677
|
startServer,
|
|
2421
2678
|
validateConfig
|
|
2422
2679
|
});
|