@yahaha-studio/focus-forwarder 0.0.1-alpha.7 → 0.0.1-alpha.8
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 +11 -10
- package/package.json +1 -1
- package/skills/focus-forwarder/SKILL.md +1 -1
- package/src/service.ts +1 -1
package/index.ts
CHANGED
|
@@ -95,7 +95,7 @@ function loadSkillsConfig(): SkillsConfig {
|
|
|
95
95
|
if (stat.mtimeMs !== cachedConfigMtime || !cachedConfig) {
|
|
96
96
|
const raw = fs.readFileSync(SKILLS_CONFIG_PATH, "utf-8");
|
|
97
97
|
updateCachedSkillsConfig(normalizeSkillsConfig(JSON.parse(raw)));
|
|
98
|
-
pluginApi?.logger.
|
|
98
|
+
pluginApi?.logger.debug(`[focus] Loaded skills config`);
|
|
99
99
|
}
|
|
100
100
|
return cachedConfig!;
|
|
101
101
|
}
|
|
@@ -216,7 +216,7 @@ async function pickActionWithLLM(context: string): Promise<ActionResult> {
|
|
|
216
216
|
const provider = typeof primary === "string" ? primary.split("/")[0] : undefined;
|
|
217
217
|
const model = typeof primary === "string" ? primary.split("/").slice(1).join("/") : undefined;
|
|
218
218
|
|
|
219
|
-
pluginApi?.logger.
|
|
219
|
+
pluginApi?.logger.debug(`[focus] LLM params: provider=${provider} model=${model} primary=${primary}`);
|
|
220
220
|
|
|
221
221
|
// Get auth profile (e.g., "synthetic:default")
|
|
222
222
|
const authProfiles = pluginApi?.config?.auth?.profiles || {};
|
|
@@ -336,6 +336,7 @@ function applyLlmEnabledChange(enabled: boolean): SkillsConfig {
|
|
|
336
336
|
...current,
|
|
337
337
|
llm: { ...current.llm, enabled },
|
|
338
338
|
}));
|
|
339
|
+
pluginApi?.logger.info(`[focus] Automatic LLM action picking ${enabled ? "enabled" : "disabled"}`);
|
|
339
340
|
for (const state of agentStates.values()) {
|
|
340
341
|
state.pendingLLM = false;
|
|
341
342
|
if (!enabled) {
|
|
@@ -361,7 +362,7 @@ function sendFallbackInternal(context: string, agentId: string) {
|
|
|
361
362
|
|
|
362
363
|
function syncStatus(context: string, agentId: string) {
|
|
363
364
|
if (!service?.isConnected()) {
|
|
364
|
-
pluginApi?.logger.
|
|
365
|
+
pluginApi?.logger.debug(`[focus] skipped: not connected`);
|
|
365
366
|
return;
|
|
366
367
|
}
|
|
367
368
|
|
|
@@ -378,17 +379,17 @@ function syncStatus(context: string, agentId: string) {
|
|
|
378
379
|
const inCooldown = state.cooldownActive;
|
|
379
380
|
const llmEnabled = isLlmEnabled();
|
|
380
381
|
|
|
381
|
-
pluginApi?.logger.
|
|
382
|
+
pluginApi?.logger.debug(`[focus] syncStatus: agent=${agentId} elapsed=${elapsed}ms inCooldown=${inCooldown} pendingLLM=${state.pendingLLM} llmEnabled=${llmEnabled}`);
|
|
382
383
|
|
|
383
384
|
if (!llmEnabled) {
|
|
384
|
-
pluginApi?.logger.
|
|
385
|
+
pluginApi?.logger.debug(`[focus] LLM disabled, using fallback mapping for agent ${agentId}`);
|
|
385
386
|
sendFallbackInternal(context, agentId);
|
|
386
387
|
return;
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
// In cooldown OR LLM pending: send fallback
|
|
390
391
|
if (inCooldown || state.pendingLLM) {
|
|
391
|
-
pluginApi?.logger.
|
|
392
|
+
pluginApi?.logger.debug(`[focus] sending fallback (inCooldown=${inCooldown} pendingLLM=${state.pendingLLM})`);
|
|
392
393
|
sendFallbackInternal(context, agentId);
|
|
393
394
|
return;
|
|
394
395
|
}
|
|
@@ -399,7 +400,7 @@ function syncStatus(context: string, agentId: string) {
|
|
|
399
400
|
state.llmCancelled = false;
|
|
400
401
|
const requestId = state.llmRequestId + 1;
|
|
401
402
|
state.llmRequestId = requestId;
|
|
402
|
-
pluginApi?.logger.
|
|
403
|
+
pluginApi?.logger.debug(`[focus] calling LLM for agent ${agentId}`);
|
|
403
404
|
|
|
404
405
|
pickActionWithLLM(context)
|
|
405
406
|
.then((action) => {
|
|
@@ -545,13 +546,13 @@ const plugin = {
|
|
|
545
546
|
|
|
546
547
|
// sendWithLLM: use LLM with cooldown
|
|
547
548
|
const sendWithLLM = (context: string, agentId: string) => {
|
|
548
|
-
pluginApi?.logger.
|
|
549
|
+
pluginApi?.logger.debug(`[focus] hook fired: agent=${agentId} context="${context.slice(0, 50)}" hasIdentity=${service?.hasValidIdentity()}`);
|
|
549
550
|
if (service?.hasValidIdentity()) syncStatus(context, agentId);
|
|
550
551
|
};
|
|
551
552
|
|
|
552
553
|
// sendFallback: always use fallback, no LLM (for after_tool_call)
|
|
553
554
|
const sendFallback = (context: string, agentId: string) => {
|
|
554
|
-
pluginApi?.logger.
|
|
555
|
+
pluginApi?.logger.debug(`[focus] fallback: agent=${agentId} context="${context.slice(0, 50)}"`);
|
|
555
556
|
if (service?.hasValidIdentity()) sendFallbackInternal(context, agentId);
|
|
556
557
|
};
|
|
557
558
|
|
|
@@ -567,7 +568,7 @@ const plugin = {
|
|
|
567
568
|
});
|
|
568
569
|
api.on("before_tool_call", (event: any, ctx?: { agentId?: string; sessionKey?: string }) => {
|
|
569
570
|
const agentId = ctx?.agentId || ctx?.sessionKey || "main";
|
|
570
|
-
pluginApi?.logger.
|
|
571
|
+
pluginApi?.logger.debug(`[focus] before_tool_call ctx: ${JSON.stringify(ctx)}`);
|
|
571
572
|
const params = event.params ? JSON.stringify(event.params) : "";
|
|
572
573
|
sendWithLLM(`[${agentId}] Tool: ${event.toolName}${params ? ` ${params}` : ""}`, agentId);
|
|
573
574
|
});
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ Before installing the plugin, save `userId` to the `identity.json` file under th
|
|
|
25
25
|
Then install and enable the plugin:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
openclaw plugins install @yahaha-studio/focus-forwarder@0.0.1-alpha.
|
|
28
|
+
openclaw plugins install @yahaha-studio/focus-forwarder@0.0.1-alpha.8
|
|
29
29
|
openclaw plugins enable focus-forwarder
|
|
30
30
|
```
|
|
31
31
|
|
package/src/service.ts
CHANGED
|
@@ -54,7 +54,7 @@ export class FocusForwarderService {
|
|
|
54
54
|
// Automatically send rejoin when a valid identity is available.
|
|
55
55
|
if (this.identity?.userId && this.identity?.authKey) {
|
|
56
56
|
this.ws?.send(JSON.stringify({ type: "rejoin", userId: this.identity.userId, authKey: this.identity.authKey }));
|
|
57
|
-
this.logger.
|
|
57
|
+
this.logger.debug(`Sent rejoin for ${this.identity.userId}`);
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
this.ws.on("message", (data) => this.handleMessage(data.toString()));
|