osborn 0.9.242 → 0.9.244
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/claude-llm.d.ts +0 -4
- package/dist/claude-llm.js +40 -3
- package/package.json +1 -1
package/dist/claude-llm.d.ts
CHANGED
|
@@ -125,10 +125,6 @@ export declare const VERIFIER_CHAIN: Record<string, {
|
|
|
125
125
|
parallelAtStart?: string[];
|
|
126
126
|
afterReminder?: string;
|
|
127
127
|
}>;
|
|
128
|
-
/**
|
|
129
|
-
* Claude LLM - Wraps Claude Agent SDK for LiveKit
|
|
130
|
-
* Research mode: reads anything, writes only to session workspace
|
|
131
|
-
*/
|
|
132
128
|
export declare class ClaudeLLM extends llm.LLM {
|
|
133
129
|
#private;
|
|
134
130
|
constructor(opts?: ClaudeLLMOptions);
|
package/dist/claude-llm.js
CHANGED
|
@@ -17,7 +17,7 @@ import { getEmbedder } from './embedder.js';
|
|
|
17
17
|
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, statSync } from 'node:fs';
|
|
18
18
|
import { join, dirname, resolve, basename } from 'node:path';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
|
-
import { homedir } from 'node:os';
|
|
20
|
+
import { homedir, loadavg, totalmem, freemem, cpus } from 'node:os';
|
|
21
21
|
// Directory of this module — used to locate co-located prompt files (e.g., turn-shape reminder).
|
|
22
22
|
const __claudeLlmDir = dirname(fileURLToPath(import.meta.url));
|
|
23
23
|
const TURN_SHAPE_REMINDER_PATH = join(__claudeLlmDir, 'prompts', 'turn-shape-reminder.md');
|
|
@@ -994,6 +994,39 @@ class MessageChannel {
|
|
|
994
994
|
* Claude LLM - Wraps Claude Agent SDK for LiveKit
|
|
995
995
|
* Research mode: reads anything, writes only to session workspace
|
|
996
996
|
*/
|
|
997
|
+
/**
|
|
998
|
+
* Lightweight machine-load nudge for the MAIN agent's UserPromptSubmit context.
|
|
999
|
+
* Pure in-memory/synchronous reads (os load average + memory + live sub-agent
|
|
1000
|
+
* dispatch count) — NO embedder, DB, or network — so it stays reliable even when
|
|
1001
|
+
* the box is starving, which is exactly when it matters. ADVISORY ONLY: it never
|
|
1002
|
+
* refuses, caps, or blocks a dispatch — the agent reads it and decides. Returns
|
|
1003
|
+
* '' on any error so it can never break the turn.
|
|
1004
|
+
*/
|
|
1005
|
+
function buildMachineNudge() {
|
|
1006
|
+
try {
|
|
1007
|
+
const ncpu = Math.max(1, cpus().length);
|
|
1008
|
+
const cpuPct = Math.round((loadavg()[0] / ncpu) * 100); // 1-min load ÷ cores
|
|
1009
|
+
const memPct = Math.round((1 - freemem() / totalmem()) * 100);
|
|
1010
|
+
const subagents = statusManager.getActiveDispatchIds().length;
|
|
1011
|
+
// Recommended concurrent heavy sub-agents, adapted to live headroom. This is a
|
|
1012
|
+
// concrete DEFAULT the agent should follow unless a task genuinely warrants
|
|
1013
|
+
// otherwise — surfaced as an actual number/target, never enforced.
|
|
1014
|
+
const recMax = (cpuPct >= 80 || memPct >= 90) ? Math.max(1, ncpu - 1) // hot: pull back below cores
|
|
1015
|
+
: (cpuPct >= 60) ? ncpu // busy: ~cores
|
|
1016
|
+
: ncpu + 1; // calm: a little headroom
|
|
1017
|
+
const over = subagents > recMax;
|
|
1018
|
+
const warn = over || cpuPct >= 80;
|
|
1019
|
+
const head = `[MACHINE${warn ? ' ⚠️' : ''}] CPU ~${cpuPct}% · MEM ${memPct}% · sub-agents ${subagents}/${recMax} recommended`;
|
|
1020
|
+
if (over)
|
|
1021
|
+
return `${head} — over the recommended concurrency; wind down to ≤${recMax} (finish or stop in-flight sub-agents) unless a task must continue. (recommendation — the agent decides, not enforced)`;
|
|
1022
|
+
if (cpuPct >= 80)
|
|
1023
|
+
return `${head} — load high; hold new sub-agents beyond ${recMax} unless needed. (recommendation — the agent decides, not enforced)`;
|
|
1024
|
+
return head;
|
|
1025
|
+
}
|
|
1026
|
+
catch {
|
|
1027
|
+
return '';
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
997
1030
|
export class ClaudeLLM extends llm.LLM {
|
|
998
1031
|
#opts;
|
|
999
1032
|
#sessionId = null;
|
|
@@ -2028,8 +2061,12 @@ class ClaudeLLMStream extends llm.LLMStream {
|
|
|
2028
2061
|
buildRecallInjection(sid, this.#opts.workingDirectory, String(input?.prompt || '')),
|
|
2029
2062
|
new Promise((res) => setTimeout(() => res(''), 6000)),
|
|
2030
2063
|
]);
|
|
2031
|
-
|
|
2032
|
-
|
|
2064
|
+
// Lightweight machine-load nudge (main agent only). Cheap synchronous
|
|
2065
|
+
// snapshot, prepended so it's present even when recall degrades under load.
|
|
2066
|
+
// Advisory only — never caps/refuses a dispatch.
|
|
2067
|
+
const machineNudge = fromSubagent ? '' : buildMachineNudge();
|
|
2068
|
+
const additionalContext = [machineNudge, reminder, recalled].filter(Boolean).join('\n\n');
|
|
2069
|
+
console.log(`📌 UserPromptSubmit: injected turn-shape reminder (${reminder.length} chars)${recalled ? ` + recall (${recalled.length} chars)` : ''}${machineNudge ? ` + machine(${machineNudge.includes('⚠️') ? 'HOT' : 'ok'})` : ''} for prompt="${promptPreview}..." [tool budget reset to 0/${TOOL_CALL_BUDGET}]`);
|
|
2033
2070
|
return {
|
|
2034
2071
|
hookSpecificOutput: {
|
|
2035
2072
|
hookEventName: 'UserPromptSubmit',
|