kernelbot 1.0.37 → 1.0.39
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/bin/kernel.js +499 -249
- package/config.example.yaml +17 -0
- package/knowledge_base/active_inference_foraging.md +126 -0
- package/knowledge_base/index.md +1 -1
- package/package.json +3 -1
- package/src/agent.js +355 -82
- package/src/bot.js +724 -12
- package/src/character.js +406 -0
- package/src/characters/builder.js +174 -0
- package/src/characters/builtins.js +421 -0
- package/src/conversation.js +17 -2
- package/src/dashboard/agents.css +469 -0
- package/src/dashboard/agents.html +184 -0
- package/src/dashboard/agents.js +873 -0
- package/src/dashboard/dashboard.css +281 -0
- package/src/dashboard/dashboard.js +579 -0
- package/src/dashboard/index.html +366 -0
- package/src/dashboard/server.js +521 -0
- package/src/dashboard/shared.css +700 -0
- package/src/dashboard/shared.js +218 -0
- package/src/life/engine.js +115 -26
- package/src/life/evolution.js +7 -5
- package/src/life/journal.js +5 -4
- package/src/life/memory.js +12 -9
- package/src/life/share-queue.js +7 -5
- package/src/prompts/orchestrator.js +76 -14
- package/src/prompts/workers.js +22 -0
- package/src/self.js +17 -5
- package/src/services/linkedin-api.js +190 -0
- package/src/services/stt.js +8 -2
- package/src/services/tts.js +32 -2
- package/src/services/x-api.js +141 -0
- package/src/swarm/worker-registry.js +7 -0
- package/src/tools/categories.js +4 -0
- package/src/tools/index.js +6 -0
- package/src/tools/linkedin.js +264 -0
- package/src/tools/orchestrator-tools.js +337 -2
- package/src/tools/x.js +256 -0
- package/src/utils/config.js +190 -139
- package/src/utils/display.js +165 -52
- package/src/utils/temporal-awareness.js +24 -10
package/src/tools/x.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { XApi } from '../services/x-api.js';
|
|
2
|
+
import { getLogger } from '../utils/logger.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get a configured X API client from the tool context.
|
|
6
|
+
*/
|
|
7
|
+
function getClient(context) {
|
|
8
|
+
const cfg = context.config.x;
|
|
9
|
+
if (!cfg?.consumer_key || !cfg?.consumer_secret || !cfg?.access_token || !cfg?.access_token_secret) {
|
|
10
|
+
throw new Error('X (Twitter) not connected. Use /x link to connect your account.');
|
|
11
|
+
}
|
|
12
|
+
return new XApi({
|
|
13
|
+
consumerKey: cfg.consumer_key,
|
|
14
|
+
consumerSecret: cfg.consumer_secret,
|
|
15
|
+
accessToken: cfg.access_token,
|
|
16
|
+
accessTokenSecret: cfg.access_token_secret,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function handle403(err) {
|
|
21
|
+
if (err.response?.status === 403) {
|
|
22
|
+
return { error: 'Access denied (403). Your X Access Token may be Read-only. Go to the X Developer Portal → App Settings → change permissions to "Read and Write", then regenerate your Access Token.' };
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const definitions = [
|
|
28
|
+
{
|
|
29
|
+
name: 'x_post_tweet',
|
|
30
|
+
description: 'Post a new tweet on X (Twitter).',
|
|
31
|
+
input_schema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
text: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'The tweet text (max 280 characters)',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['text'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'x_reply_to_tweet',
|
|
44
|
+
description: 'Reply to an existing tweet on X (Twitter).',
|
|
45
|
+
input_schema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
text: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'The reply text',
|
|
51
|
+
},
|
|
52
|
+
reply_to_id: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'The tweet ID to reply to',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
required: ['text', 'reply_to_id'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'x_get_my_tweets',
|
|
62
|
+
description: 'Get the authenticated user\'s recent tweets on X (Twitter).',
|
|
63
|
+
input_schema: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
count: {
|
|
67
|
+
type: 'number',
|
|
68
|
+
description: 'Number of tweets to fetch (default 10, max 100)',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'x_get_tweet',
|
|
75
|
+
description: 'Get a specific tweet by its ID.',
|
|
76
|
+
input_schema: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
tweet_id: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'The tweet ID',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['tweet_id'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'x_search_tweets',
|
|
89
|
+
description: 'Search recent tweets on X (Twitter). Returns tweets from the last 7 days.',
|
|
90
|
+
input_schema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
query: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'Search query (supports X search operators)',
|
|
96
|
+
},
|
|
97
|
+
count: {
|
|
98
|
+
type: 'number',
|
|
99
|
+
description: 'Number of results (default 10, max 100)',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
required: ['query'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'x_like_tweet',
|
|
107
|
+
description: 'Like a tweet on X (Twitter).',
|
|
108
|
+
input_schema: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
tweet_id: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
description: 'The tweet ID to like',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
required: ['tweet_id'],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'x_retweet',
|
|
121
|
+
description: 'Retweet a tweet on X (Twitter).',
|
|
122
|
+
input_schema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
tweet_id: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'The tweet ID to retweet',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ['tweet_id'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'x_delete_tweet',
|
|
135
|
+
description: 'Delete one of your own tweets on X (Twitter).',
|
|
136
|
+
input_schema: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
tweet_id: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
description: 'The tweet ID to delete',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
required: ['tweet_id'],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'x_get_profile',
|
|
149
|
+
description: 'Get the authenticated X (Twitter) profile info.',
|
|
150
|
+
input_schema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
export const handlers = {
|
|
158
|
+
x_post_tweet: async (params, context) => {
|
|
159
|
+
try {
|
|
160
|
+
const client = getClient(context);
|
|
161
|
+
const tweet = await client.postTweet(params.text);
|
|
162
|
+
return { success: true, message: 'Tweet posted', tweet };
|
|
163
|
+
} catch (err) {
|
|
164
|
+
getLogger().error(`x_post_tweet failed: ${err.message}`);
|
|
165
|
+
return handle403(err) || { error: err.response?.data?.detail || err.message };
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
x_reply_to_tweet: async (params, context) => {
|
|
170
|
+
try {
|
|
171
|
+
const client = getClient(context);
|
|
172
|
+
const tweet = await client.replyToTweet(params.text, params.reply_to_id);
|
|
173
|
+
return { success: true, message: 'Reply posted', tweet };
|
|
174
|
+
} catch (err) {
|
|
175
|
+
getLogger().error(`x_reply_to_tweet failed: ${err.message}`);
|
|
176
|
+
return handle403(err) || { error: err.response?.data?.detail || err.message };
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
x_get_my_tweets: async (params, context) => {
|
|
181
|
+
try {
|
|
182
|
+
const client = getClient(context);
|
|
183
|
+
const tweets = await client.getMyTweets(params.count || 10);
|
|
184
|
+
return { tweets, count: tweets.length };
|
|
185
|
+
} catch (err) {
|
|
186
|
+
getLogger().error(`x_get_my_tweets failed: ${err.message}`);
|
|
187
|
+
return { error: err.response?.data?.detail || err.message };
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
x_get_tweet: async (params, context) => {
|
|
192
|
+
try {
|
|
193
|
+
const client = getClient(context);
|
|
194
|
+
const tweet = await client.getTweet(params.tweet_id);
|
|
195
|
+
return { tweet };
|
|
196
|
+
} catch (err) {
|
|
197
|
+
getLogger().error(`x_get_tweet failed: ${err.message}`);
|
|
198
|
+
return { error: err.response?.data?.detail || err.message };
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
x_search_tweets: async (params, context) => {
|
|
203
|
+
try {
|
|
204
|
+
const client = getClient(context);
|
|
205
|
+
const tweets = await client.searchRecentTweets(params.query, params.count || 10);
|
|
206
|
+
return { tweets, count: tweets.length, query: params.query };
|
|
207
|
+
} catch (err) {
|
|
208
|
+
getLogger().error(`x_search_tweets failed: ${err.message}`);
|
|
209
|
+
return { error: err.response?.data?.detail || err.message };
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
x_like_tweet: async (params, context) => {
|
|
214
|
+
try {
|
|
215
|
+
const client = getClient(context);
|
|
216
|
+
const result = await client.likeTweet(params.tweet_id);
|
|
217
|
+
return { success: true, message: 'Tweet liked', result };
|
|
218
|
+
} catch (err) {
|
|
219
|
+
getLogger().error(`x_like_tweet failed: ${err.message}`);
|
|
220
|
+
return handle403(err) || { error: err.response?.data?.detail || err.message };
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
x_retweet: async (params, context) => {
|
|
225
|
+
try {
|
|
226
|
+
const client = getClient(context);
|
|
227
|
+
const result = await client.retweet(params.tweet_id);
|
|
228
|
+
return { success: true, message: 'Retweeted', result };
|
|
229
|
+
} catch (err) {
|
|
230
|
+
getLogger().error(`x_retweet failed: ${err.message}`);
|
|
231
|
+
return handle403(err) || { error: err.response?.data?.detail || err.message };
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
x_delete_tweet: async (params, context) => {
|
|
236
|
+
try {
|
|
237
|
+
const client = getClient(context);
|
|
238
|
+
const result = await client.deleteTweet(params.tweet_id);
|
|
239
|
+
return { success: true, message: 'Tweet deleted', result };
|
|
240
|
+
} catch (err) {
|
|
241
|
+
getLogger().error(`x_delete_tweet failed: ${err.message}`);
|
|
242
|
+
return handle403(err) || { error: err.response?.data?.detail || err.message };
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
x_get_profile: async (params, context) => {
|
|
247
|
+
try {
|
|
248
|
+
const client = getClient(context);
|
|
249
|
+
const profile = await client.getMe();
|
|
250
|
+
return { profile };
|
|
251
|
+
} catch (err) {
|
|
252
|
+
getLogger().error(`x_get_profile failed: ${err.message}`);
|
|
253
|
+
return { error: err.response?.data?.detail || err.message };
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
};
|