@yeego/yeego-openclaw 1.3.2 → 1.3.4
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/index.ts +1 -1
- package/package.json +5 -2
- package/src/channel.ts +29 -108
- package/src/monitor.ts +15 -9
- package/src/tools/index.ts +8 -2
- package/src/tools/profileTools.ts +13 -11
- package/src/types.ts +22 -15
package/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
17
17
|
import { yeegoPlugin } from "./src/channel.js";
|
|
18
18
|
import { createYeegoTools } from "./src/tools/index.js";
|
|
19
19
|
import { setYeegoRuntime } from "./src/runtime.js";
|
|
20
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
20
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
21
21
|
import { join } from 'path';
|
|
22
22
|
import { homedir } from 'os';
|
|
23
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeego/yeego-openclaw",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Yeego plugin for OpenClaw - Connect your AI personas to Yeego messaging platform",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,10 @@
|
|
|
31
31
|
"pocketbase": "^0.26.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@
|
|
34
|
+
"@mariozechner/pi-agent-core": "latest",
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"openclaw": "latest",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
35
38
|
},
|
|
36
39
|
"engines": {
|
|
37
40
|
"node": ">=18.0.0"
|
package/src/channel.ts
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yeego OpenClaw Channel Plugin
|
|
3
|
-
*
|
|
4
|
-
* Integrates Yeego with OpenClaw by:
|
|
5
|
-
* - Starting a realtime listener subprocess (poller.ts) via gateway
|
|
6
|
-
* - Sending AI responses back to Yeego conversations via PocketBase
|
|
7
|
-
* - Resolving conversation IDs for message targeting
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
import type {
|
|
11
2
|
ChannelPlugin,
|
|
12
|
-
|
|
3
|
+
ChannelOutboundContext,
|
|
4
|
+
ChannelGatewayContext,
|
|
5
|
+
OpenClawConfig,
|
|
13
6
|
} from "openclaw/plugin-sdk";
|
|
14
|
-
import {
|
|
7
|
+
import { ChildProcess } from "child_process";
|
|
15
8
|
import { join } from "path";
|
|
16
|
-
import { fileURLToPath } from "url";
|
|
17
|
-
import { dirname } from "path";
|
|
18
9
|
import PocketBase from 'pocketbase';
|
|
19
10
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
20
11
|
import { homedir } from 'os';
|
|
21
|
-
import { createYeegoTools } from "./tools/index.js";
|
|
22
12
|
import {
|
|
23
13
|
setSessionConversation,
|
|
24
14
|
getSessionConversation,
|
|
25
15
|
} from "./sessionMapping.js";
|
|
16
|
+
import type { YeegoAccount } from "./types.js";
|
|
26
17
|
|
|
27
18
|
// ============================================================================
|
|
28
19
|
// Types
|
|
@@ -34,7 +25,6 @@ interface YeegoConfig {
|
|
|
34
25
|
profileId: string;
|
|
35
26
|
baseUrl: string;
|
|
36
27
|
sidecarUrl: string;
|
|
37
|
-
connectUrl: string;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
interface YeegoInternalConfig {
|
|
@@ -46,6 +36,7 @@ interface YeegoInternalConfig {
|
|
|
46
36
|
|
|
47
37
|
interface PeerEntry {
|
|
48
38
|
id: string;
|
|
39
|
+
kind: "user" | "group" | "channel";
|
|
49
40
|
name: string;
|
|
50
41
|
handle: string;
|
|
51
42
|
}
|
|
@@ -69,50 +60,20 @@ let pollerProcess: ChildProcess | null = null;
|
|
|
69
60
|
// Helper Functions
|
|
70
61
|
// ============================================================================
|
|
71
62
|
|
|
72
|
-
async function
|
|
63
|
+
async function writePollerConfig(ctx: ChannelGatewayContext<YeegoAccount>) {
|
|
73
64
|
try {
|
|
74
|
-
// Read config directly from file
|
|
75
65
|
const configPath = join(homedir(), '.openclaw', 'openclaw.json');
|
|
76
66
|
if (!existsSync(configPath)) {
|
|
77
|
-
ctx.log?.warn(`[yeego] OpenClaw config file not found: ${configPath}`);
|
|
78
67
|
return;
|
|
79
68
|
}
|
|
80
69
|
|
|
81
70
|
const fullConfig = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
82
71
|
const yeegoConfig = fullConfig?.channels?.yeego?.config;
|
|
83
72
|
|
|
84
|
-
if (!yeegoConfig || !yeegoConfig.
|
|
85
|
-
ctx.log?.warn(`[yeego] Missing config for connect endpoint:`, {
|
|
86
|
-
hasConnectUrl: !!yeegoConfig?.connectUrl,
|
|
87
|
-
hasToken: !!yeegoConfig?.token,
|
|
88
|
-
hasProfileId: !!yeegoConfig?.profileId,
|
|
89
|
-
expectedPath: 'channels.yeego.config in ~/.openclaw/openclaw.json',
|
|
90
|
-
});
|
|
91
|
-
ctx.log?.warn(`[yeego] Config must be under channels.yeego.config, NOT plugins.entries.yeego-openclaw.config`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
ctx.log?.info(`[yeego] Calling connect endpoint: ${yeegoConfig.connectUrl}`);
|
|
96
|
-
|
|
97
|
-
const response = await fetch(yeegoConfig.connectUrl, {
|
|
98
|
-
method: "POST",
|
|
99
|
-
headers: {
|
|
100
|
-
"Authorization": `Bearer ${yeegoConfig.token}`,
|
|
101
|
-
"Content-Type": "application/json",
|
|
102
|
-
},
|
|
103
|
-
body: JSON.stringify({ profile_id: yeegoConfig.profileId }),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
if (!response.ok) {
|
|
107
|
-
const errorText = await response.text();
|
|
108
|
-
ctx.log?.error(`[yeego] Connect endpoint failed: ${response.status} ${errorText}`);
|
|
73
|
+
if (!yeegoConfig || !yeegoConfig.token || !yeegoConfig.profileId) {
|
|
109
74
|
return;
|
|
110
75
|
}
|
|
111
76
|
|
|
112
|
-
const result = await response.json();
|
|
113
|
-
ctx.log?.info(`[yeego] Successfully connected:`, result);
|
|
114
|
-
|
|
115
|
-
// Write config to ~/.yeego/config.json for poller (using underscore format)
|
|
116
77
|
mkdirSync(YEEGO_CONFIG_DIR, { recursive: true });
|
|
117
78
|
|
|
118
79
|
const pollerConfig: YeegoInternalConfig = {
|
|
@@ -125,7 +86,7 @@ async function callConnectEndpoint(ctx: any) {
|
|
|
125
86
|
writeFileSync(YEEGO_CONFIG_FILE, JSON.stringify(pollerConfig, null, 2), 'utf-8');
|
|
126
87
|
ctx.log?.info(`[yeego] Saved poller config to ${YEEGO_CONFIG_FILE}`);
|
|
127
88
|
} catch (error) {
|
|
128
|
-
ctx.log?.error(`[yeego] Error
|
|
89
|
+
ctx.log?.error(`[yeego] Error writing poller config: ${String(error)}`);
|
|
129
90
|
}
|
|
130
91
|
}
|
|
131
92
|
|
|
@@ -189,19 +150,23 @@ function filterPeers(peers: PeerEntry[], query?: string, limit?: number): PeerEn
|
|
|
189
150
|
// Plugin Definition
|
|
190
151
|
// ============================================================================
|
|
191
152
|
|
|
192
|
-
export const yeegoPlugin: ChannelPlugin<
|
|
153
|
+
export const yeegoPlugin: ChannelPlugin<YeegoAccount> = {
|
|
193
154
|
id: "yeego",
|
|
194
|
-
|
|
155
|
+
|
|
195
156
|
meta: {
|
|
196
|
-
|
|
197
|
-
provider: "yeego",
|
|
157
|
+
id: "yeego",
|
|
198
158
|
label: "Yeego",
|
|
159
|
+
selectionLabel: "Yeego",
|
|
160
|
+
docsPath: "/channels/yeego",
|
|
161
|
+
blurb: "Yeego chat channel integration for OpenClaw",
|
|
162
|
+
order: 1000,
|
|
199
163
|
},
|
|
200
164
|
|
|
201
165
|
configSchema: {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
166
|
+
schema: {
|
|
167
|
+
type: "object" as const,
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
properties: {
|
|
205
170
|
token: {
|
|
206
171
|
type: "string" as const,
|
|
207
172
|
description: "Yeego authentication token",
|
|
@@ -218,12 +183,9 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
218
183
|
type: "string" as const,
|
|
219
184
|
description: "Yeego sidecar URL",
|
|
220
185
|
},
|
|
221
|
-
connectUrl: {
|
|
222
|
-
type: "string" as const,
|
|
223
|
-
description: "Yeego connect endpoint URL",
|
|
224
186
|
},
|
|
187
|
+
required: ["token", "profileId", "baseUrl", "sidecarUrl"],
|
|
225
188
|
},
|
|
226
|
-
required: ["token", "profileId", "baseUrl", "sidecarUrl", "connectUrl"],
|
|
227
189
|
},
|
|
228
190
|
|
|
229
191
|
config: {
|
|
@@ -238,7 +200,6 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
238
200
|
profileId: yeegoConfig.profileId || "",
|
|
239
201
|
baseUrl: yeegoConfig.baseUrl || "",
|
|
240
202
|
sidecarUrl: yeegoConfig.sidecarUrl || "",
|
|
241
|
-
connectUrl: yeegoConfig.connectUrl || "",
|
|
242
203
|
};
|
|
243
204
|
},
|
|
244
205
|
isConfigured: (account) => {
|
|
@@ -270,7 +231,7 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
270
231
|
defaultRuntime: {
|
|
271
232
|
accountId: "default",
|
|
272
233
|
running: true,
|
|
273
|
-
lastStartAt:
|
|
234
|
+
lastStartAt: Date.now(),
|
|
274
235
|
lastStopAt: null,
|
|
275
236
|
lastError: null,
|
|
276
237
|
lastInboundAt: null,
|
|
@@ -294,7 +255,8 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
294
255
|
outbound: {
|
|
295
256
|
deliveryMode: "direct",
|
|
296
257
|
|
|
297
|
-
sendText: async (
|
|
258
|
+
sendText: async (ctx: ChannelOutboundContext) => {
|
|
259
|
+
const { to, text } = ctx;
|
|
298
260
|
console.log(`[Yeego] Sending message to: ${to}`);
|
|
299
261
|
|
|
300
262
|
const conversationId = parseConversationId(to);
|
|
@@ -324,8 +286,8 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
324
286
|
|
|
325
287
|
return {
|
|
326
288
|
channel: "yeego",
|
|
327
|
-
|
|
328
|
-
|
|
289
|
+
messageId: message.id,
|
|
290
|
+
conversationId: conversationId,
|
|
329
291
|
};
|
|
330
292
|
} catch (error) {
|
|
331
293
|
console.error(`[Yeego] Failed to send message:`, error);
|
|
@@ -353,6 +315,7 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
353
315
|
|
|
354
316
|
const allPeers = Array.from(conversationIds).map(id => ({
|
|
355
317
|
id,
|
|
318
|
+
kind: "user" as const,
|
|
356
319
|
name: id,
|
|
357
320
|
handle: id,
|
|
358
321
|
}));
|
|
@@ -402,19 +365,9 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
402
365
|
|
|
403
366
|
ctx.log?.info(`[yeego] Starting polling channel for account: ${account.accountId}`);
|
|
404
367
|
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
await callConnectEndpoint(ctx);
|
|
408
|
-
ctx.log?.info(`[yeego] Connect endpoint called successfully`);
|
|
409
|
-
} catch (error) {
|
|
410
|
-
ctx.log?.error(`[yeego] Failed to call connect endpoint:`, error);
|
|
411
|
-
throw error;
|
|
412
|
-
}
|
|
368
|
+
// Write poller config on startup
|
|
369
|
+
await writePollerConfig(ctx);
|
|
413
370
|
|
|
414
|
-
if (ctx.runtime) {
|
|
415
|
-
ctx.runtime.running = true;
|
|
416
|
-
ctx.runtime.lastStartAt = new Date().toISOString();
|
|
417
|
-
}
|
|
418
371
|
|
|
419
372
|
ctx.log?.info(`[yeego] Starting message monitor...`);
|
|
420
373
|
|
|
@@ -432,38 +385,6 @@ export const yeegoPlugin: ChannelPlugin<YeegoConfig> = {
|
|
|
432
385
|
},
|
|
433
386
|
},
|
|
434
387
|
|
|
435
|
-
// --------------------------------------------------------------------------
|
|
436
|
-
// Legacy Methods
|
|
437
|
-
// --------------------------------------------------------------------------
|
|
438
|
-
|
|
439
|
-
async sendMessage(identity, text, _options, ctx) {
|
|
440
|
-
console.error("[Yeego] Legacy sendMessage is deprecated, use outbound.sendText instead");
|
|
441
|
-
return {
|
|
442
|
-
success: false,
|
|
443
|
-
error: "Legacy sendMessage is deprecated"
|
|
444
|
-
};
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
async resolveIdentity(identifier): Promise<ChannelIdentity | null> {
|
|
448
|
-
return {
|
|
449
|
-
channelId: "yeego",
|
|
450
|
-
chatId: identifier,
|
|
451
|
-
chatType: "direct",
|
|
452
|
-
displayName: `Yeego Chat ${identifier}`,
|
|
453
|
-
};
|
|
454
|
-
},
|
|
455
|
-
|
|
456
|
-
async cleanup() {
|
|
457
|
-
console.log("[Yeego] Cleaning up channel plugin");
|
|
458
|
-
|
|
459
|
-
if (pollerProcess) {
|
|
460
|
-
console.log(`[Yeego] Stopping poller subprocess (PID: ${pollerProcess.pid})`);
|
|
461
|
-
pollerProcess.kill();
|
|
462
|
-
pollerProcess = null;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return { success: true };
|
|
466
|
-
},
|
|
467
388
|
};
|
|
468
389
|
|
|
469
390
|
// Re-export session mapping functions
|
package/src/monitor.ts
CHANGED
|
@@ -61,7 +61,7 @@ export async function monitorYeegoProvider(opts: MonitorYeegoOpts): Promise<void
|
|
|
61
61
|
|
|
62
62
|
// Load config
|
|
63
63
|
if (!existsSync(CONFIG_FILE)) {
|
|
64
|
-
logger.error('[Yeego] Configuration not found:', CONFIG_FILE);
|
|
64
|
+
logger.error('[Yeego] Configuration not found:', { path: CONFIG_FILE });
|
|
65
65
|
throw new Error('Yeego config not found. Please configure channels.yeego first.');
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -143,10 +143,10 @@ async function pollForNewMessages(params: PollForNewMessagesParams): Promise<voi
|
|
|
143
143
|
.substring(0, 19);
|
|
144
144
|
|
|
145
145
|
try {
|
|
146
|
-
const messages = await pb.collection('profile_chat_messages').getList
|
|
146
|
+
const messages = await pb.collection('profile_chat_messages').getList(1, 50, {
|
|
147
147
|
filter: `created >= "${tenSecondsAgo}" && by = "user" && is_ai_generated = false`,
|
|
148
148
|
sort: '-created',
|
|
149
|
-
});
|
|
149
|
+
}) as { items: PocketBaseMessage[] };
|
|
150
150
|
|
|
151
151
|
for (const message of messages.items) {
|
|
152
152
|
if (!processedMessages.has(message.id) && message.conversation) {
|
|
@@ -192,7 +192,7 @@ async function processMessage(params: ProcessMessageParams): Promise<void> {
|
|
|
192
192
|
// Get conversation details
|
|
193
193
|
const conversation = await pb
|
|
194
194
|
.collection('profile_chat_conversations')
|
|
195
|
-
.getOne
|
|
195
|
+
.getOne(message.conversation) as PocketBaseConversation;
|
|
196
196
|
|
|
197
197
|
// Verify it's for our profile
|
|
198
198
|
if (conversation.profile !== config.profile_id) {
|
|
@@ -202,10 +202,10 @@ async function processMessage(params: ProcessMessageParams): Promise<void> {
|
|
|
202
202
|
// Get last message to ensure we process the most recent user message
|
|
203
203
|
const lastMessages = await pb
|
|
204
204
|
.collection('profile_chat_messages')
|
|
205
|
-
.getList
|
|
205
|
+
.getList(1, 1, {
|
|
206
206
|
filter: `conversation="${message.conversation}"`,
|
|
207
207
|
sort: '-created',
|
|
208
|
-
});
|
|
208
|
+
}) as { items: PocketBaseMessage[] };
|
|
209
209
|
|
|
210
210
|
if (lastMessages.items.length === 0) {
|
|
211
211
|
return;
|
|
@@ -225,6 +225,11 @@ async function processMessage(params: ProcessMessageParams): Promise<void> {
|
|
|
225
225
|
setSessionConversation(`agent:main:${conversation.id}`, conversation.id);
|
|
226
226
|
setSessionConversation(`yeego:${conversation.id}`, conversation.id);
|
|
227
227
|
|
|
228
|
+
// Build system prompt hint for Yeego context
|
|
229
|
+
const yeegoSystemHint = `[Yeego Context]
|
|
230
|
+
Current Yeego conversation ID: ${conversation.id}
|
|
231
|
+
When creating cron jobs to deliver messages to this user, use: channel="yeego", to="${conversation.id}"`;
|
|
232
|
+
|
|
228
233
|
// Create inbound context using OpenClaw SDK
|
|
229
234
|
const ctxPayload = core.channel.reply.finalizeInboundContext({
|
|
230
235
|
Body: lastMessage.message,
|
|
@@ -241,12 +246,13 @@ async function processMessage(params: ProcessMessageParams): Promise<void> {
|
|
|
241
246
|
Provider: 'yeego' as const,
|
|
242
247
|
Surface: 'yeego' as const,
|
|
243
248
|
MessageSid: lastMessage.id,
|
|
249
|
+
GroupSystemPrompt: yeegoSystemHint,
|
|
244
250
|
});
|
|
245
251
|
|
|
246
252
|
// Create reply dispatcher
|
|
247
253
|
const { dispatcher, replyOptions, markDispatchIdle } =
|
|
248
254
|
core.channel.reply.createReplyDispatcherWithTyping({
|
|
249
|
-
deliver: async (payload:
|
|
255
|
+
deliver: async (payload: { text?: string; mediaUrl?: string }) => {
|
|
250
256
|
// Send reply back to Yeego
|
|
251
257
|
try {
|
|
252
258
|
await pb.collection('profile_chat_messages').create({
|
|
@@ -263,8 +269,8 @@ async function processMessage(params: ProcessMessageParams): Promise<void> {
|
|
|
263
269
|
throw error;
|
|
264
270
|
}
|
|
265
271
|
},
|
|
266
|
-
onError: (err:
|
|
267
|
-
logger.error(`[Yeego] ${info.kind} reply failed:`, err);
|
|
272
|
+
onError: (err: Error, info: { kind: string }) => {
|
|
273
|
+
logger.error(`[Yeego] ${info.kind} reply failed:`, { error: err.message, stack: err.stack });
|
|
268
274
|
},
|
|
269
275
|
});
|
|
270
276
|
|
package/src/tools/index.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
6
|
-
import type { OpenClawPluginToolContext } from "openclaw/plugin-sdk";
|
|
7
6
|
import {
|
|
8
7
|
createUpdateProfileFieldTool,
|
|
9
8
|
createViewProfileFieldTool,
|
|
@@ -11,11 +10,18 @@ import {
|
|
|
11
10
|
createGetYeegoTargetIdTool,
|
|
12
11
|
} from "./profileTools.js";
|
|
13
12
|
|
|
13
|
+
export interface YeegoToolContext {
|
|
14
|
+
sessionKey?: string;
|
|
15
|
+
config?: unknown;
|
|
16
|
+
workspaceDir?: string;
|
|
17
|
+
agentDir?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* Create Yeego tools with context
|
|
16
22
|
* This function is called per-session by the tool factory
|
|
17
23
|
*/
|
|
18
|
-
export function createYeegoTools(ctx:
|
|
24
|
+
export function createYeegoTools(ctx: YeegoToolContext): AgentTool[] {
|
|
19
25
|
return [
|
|
20
26
|
createGetYeegoTargetIdTool(ctx),
|
|
21
27
|
createUpdateProfileFieldTool(ctx),
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { Type } from "@sinclair/typebox";
|
|
6
6
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
7
|
-
import type { OpenClawPluginToolContext } from "openclaw/plugin-sdk";
|
|
8
7
|
import { getProfileFromConversation } from "./pocketbase.js";
|
|
9
8
|
import { getSessionConversation } from "../sessionMapping.js";
|
|
9
|
+
import type { YeegoToolContext } from "./index.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Tool to get the current Yeego conversation ID (target ID)
|
|
13
13
|
* This allows OpenClaw to know where to send proactive messages
|
|
14
14
|
*/
|
|
15
|
-
export function createGetYeegoTargetIdTool(ctx:
|
|
15
|
+
export function createGetYeegoTargetIdTool(ctx: YeegoToolContext): AgentTool {
|
|
16
16
|
return {
|
|
17
17
|
name: "get_yeego_target_id",
|
|
18
18
|
label: "Get Yeego Target ID",
|
|
@@ -46,7 +46,7 @@ export function createGetYeegoTargetIdTool(ctx: OpenClawPluginToolContext): Agen
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function createUpdateProfileFieldTool(ctx:
|
|
49
|
+
export function createUpdateProfileFieldTool(ctx: YeegoToolContext): AgentTool {
|
|
50
50
|
return {
|
|
51
51
|
name: "update_profile_field",
|
|
52
52
|
label: "Update Profile Field",
|
|
@@ -72,13 +72,14 @@ export function createUpdateProfileFieldTool(ctx: OpenClawPluginToolContext): Ag
|
|
|
72
72
|
throw new Error(`No conversation context for session: ${ctx.sessionKey}`);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const typedParams = params as { field: string; value: string };
|
|
75
76
|
const { pb, profile } = await getProfileFromConversation(conversationId);
|
|
76
77
|
await pb.collection("user_profiles").update(profile.id, {
|
|
77
|
-
[
|
|
78
|
+
[typedParams.field]: typedParams.value,
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
return {
|
|
81
|
-
content: [{ type: "text", text: `✓ Updated ${
|
|
82
|
+
content: [{ type: "text", text: `✓ Updated ${typedParams.field} to "${typedParams.value}"` }],
|
|
82
83
|
details: { success: true },
|
|
83
84
|
};
|
|
84
85
|
} catch (error) {
|
|
@@ -91,7 +92,7 @@ export function createUpdateProfileFieldTool(ctx: OpenClawPluginToolContext): Ag
|
|
|
91
92
|
};
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
export function createViewProfileFieldTool(ctx:
|
|
95
|
+
export function createViewProfileFieldTool(ctx: YeegoToolContext): AgentTool {
|
|
95
96
|
return {
|
|
96
97
|
name: "view_user_profile_data",
|
|
97
98
|
label: "Get User Profile Data",
|
|
@@ -135,12 +136,13 @@ export function createViewProfileFieldTool(ctx: OpenClawPluginToolContext): Agen
|
|
|
135
136
|
const { profile } = await getProfileFromConversation(conversationId);
|
|
136
137
|
console.error(`[view_profile_field] Profile fetched successfully:`, profile.id);
|
|
137
138
|
|
|
138
|
-
const
|
|
139
|
-
|
|
139
|
+
const typedParams = params as { field: string };
|
|
140
|
+
const value = profile[typedParams.field] || "(not set)";
|
|
141
|
+
console.error(`[view_profile_field] Field value: ${typedParams.field} = ${value}`);
|
|
140
142
|
|
|
141
143
|
return {
|
|
142
|
-
content: [{ type: "text", text: `${
|
|
143
|
-
details: { field:
|
|
144
|
+
content: [{ type: "text", text: `${typedParams.field}: ${value}` }],
|
|
145
|
+
details: { field: typedParams.field, value },
|
|
144
146
|
};
|
|
145
147
|
} catch (error) {
|
|
146
148
|
console.error(`[view_profile_field] EXCEPTION CAUGHT:`, error);
|
|
@@ -153,7 +155,7 @@ export function createViewProfileFieldTool(ctx: OpenClawPluginToolContext): Agen
|
|
|
153
155
|
};
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
export function createViewFullProfileTool(ctx:
|
|
158
|
+
export function createViewFullProfileTool(ctx: YeegoToolContext): AgentTool {
|
|
157
159
|
return {
|
|
158
160
|
name: "view_full_profile",
|
|
159
161
|
label: "View Full Profile",
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Type definitions for Yeego OpenClaw Plugin
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { PluginRuntime } from "openclaw/plugin-sdk";
|
|
5
|
+
import type { PluginRuntime, OpenClawConfig, RuntimeLogger } from "openclaw/plugin-sdk";
|
|
6
|
+
import type PocketBase from "pocketbase";
|
|
6
7
|
|
|
7
8
|
// ============================================================================
|
|
8
9
|
// PocketBase Types
|
|
@@ -42,7 +43,6 @@ export interface YeegoConfig {
|
|
|
42
43
|
profileId: string;
|
|
43
44
|
baseUrl: string;
|
|
44
45
|
sidecarUrl: string;
|
|
45
|
-
connectUrl: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface YeegoAccount {
|
|
@@ -52,7 +52,6 @@ export interface YeegoAccount {
|
|
|
52
52
|
profileId: string;
|
|
53
53
|
baseUrl: string;
|
|
54
54
|
sidecarUrl: string;
|
|
55
|
-
connectUrl: string;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
// ============================================================================
|
|
@@ -60,33 +59,33 @@ export interface YeegoAccount {
|
|
|
60
59
|
// ============================================================================
|
|
61
60
|
|
|
62
61
|
export interface MonitorYeegoOpts {
|
|
63
|
-
runtime:
|
|
62
|
+
runtime: unknown;
|
|
64
63
|
abortSignal?: AbortSignal;
|
|
65
64
|
accountId: string;
|
|
66
65
|
core: PluginRuntime;
|
|
67
|
-
cfg:
|
|
66
|
+
cfg: OpenClawConfig;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
export interface ProcessMessageParams {
|
|
71
70
|
message: PocketBaseMessage;
|
|
72
|
-
pb:
|
|
71
|
+
pb: PocketBase;
|
|
73
72
|
config: PocketBaseConfig;
|
|
74
73
|
processedMessages: Set<string>;
|
|
75
74
|
core: PluginRuntime;
|
|
76
|
-
cfg:
|
|
77
|
-
runtime:
|
|
78
|
-
logger:
|
|
75
|
+
cfg: OpenClawConfig;
|
|
76
|
+
runtime: unknown;
|
|
77
|
+
logger: RuntimeLogger;
|
|
79
78
|
accountId: string;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
export interface PollForNewMessagesParams {
|
|
83
|
-
pb:
|
|
82
|
+
pb: PocketBase;
|
|
84
83
|
config: PocketBaseConfig;
|
|
85
84
|
processedMessages: Set<string>;
|
|
86
85
|
core: PluginRuntime;
|
|
87
|
-
cfg:
|
|
88
|
-
runtime:
|
|
89
|
-
logger:
|
|
86
|
+
cfg: OpenClawConfig;
|
|
87
|
+
runtime: unknown;
|
|
88
|
+
logger: RuntimeLogger;
|
|
90
89
|
accountId: string;
|
|
91
90
|
}
|
|
92
91
|
|
|
@@ -100,10 +99,18 @@ export interface YeegoToolContext {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
export interface ProfileData {
|
|
103
|
-
|
|
102
|
+
id: string;
|
|
103
|
+
handle?: string;
|
|
104
|
+
first_name?: string;
|
|
105
|
+
last_name?: string;
|
|
106
|
+
email?: string;
|
|
107
|
+
profile_bio?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
linkedin_url?: string;
|
|
110
|
+
[key: string]: unknown;
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
export interface UpdateProfileFieldArgs {
|
|
107
114
|
field: string;
|
|
108
|
-
value:
|
|
115
|
+
value: string;
|
|
109
116
|
}
|