This commit is contained in:
@@ -12,6 +12,7 @@ const SEED_FILES = [
|
||||
'BOOTSTRAP.md',
|
||||
'HEARTBEAT.md',
|
||||
'TOOLS.md',
|
||||
'PERSONA.md',
|
||||
'skills/skill-creator/SKILL.md',
|
||||
];
|
||||
|
||||
@@ -60,7 +61,18 @@ export function applyAssistantName(dir, name) {
|
||||
return who;
|
||||
}
|
||||
|
||||
export function ensureAgentWorkspace({ name = 'Jarvis' } = {}) {
|
||||
export function applyAssistantPrompt(dir, prompt) {
|
||||
const notes = String(prompt || '').replace(/\0/g, '').replace(/\s+$/g, '').slice(0, 4000);
|
||||
const file = path.join(dir, 'PERSONA.md');
|
||||
const body = notes
|
||||
? `# PERSONA.md\n\n${notes}\n`
|
||||
: '# PERSONA.md\n\n';
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(file, body);
|
||||
return notes;
|
||||
}
|
||||
|
||||
export function ensureAgentWorkspace({ name = 'Jarvis', prompt = '' } = {}) {
|
||||
const dest = agentWorkspaceDir();
|
||||
fs.mkdirSync(path.join(dest, 'memory'), { recursive: true });
|
||||
fs.mkdirSync(path.join(dest, 'skills'), { recursive: true });
|
||||
@@ -68,5 +80,6 @@ export function ensureAgentWorkspace({ name = 'Jarvis' } = {}) {
|
||||
copyIfMissing(path.join(TEMPLATE_DIR, rel), path.join(dest, rel));
|
||||
}
|
||||
applyAssistantName(dest, name);
|
||||
applyAssistantPrompt(dest, prompt);
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class HarnessBridge extends EventEmitter {
|
||||
const settings = voiceSettings();
|
||||
const access = fsAccess ?? settings.fsAccess;
|
||||
const assistantName = normalizeAssistantName(settings.assistantName);
|
||||
const workspace = cwd || ensureAgentWorkspace({ name: assistantName });
|
||||
const workspace = cwd || ensureAgentWorkspace({ name: assistantName, prompt: settings.assistantPrompt });
|
||||
const roots = harnessRoots(access);
|
||||
this.options = {
|
||||
cwd: workspace,
|
||||
@@ -42,7 +42,7 @@ export class HarnessBridge extends EventEmitter {
|
||||
webFetch: true,
|
||||
permissionMode,
|
||||
origin: 'jarvis-qvac',
|
||||
system: voiceSystemPrompt(assistantName),
|
||||
system: voiceSystemPrompt(assistantName, settings.assistantPrompt),
|
||||
voice: true,
|
||||
maxTurns: settings.maxTurns,
|
||||
maxShellCalls: settings.maxShellCalls,
|
||||
|
||||
+5
-4
@@ -22,7 +22,7 @@ import { ComputerActuator } from '../computer-use/actuator.js';
|
||||
import { RuntimeTelemetry } from './telemetry.js';
|
||||
import { StateRecovery } from './recovery.js';
|
||||
import { spokenReply, voiceSystemPrompt } from '../skills/voice-prompt.js';
|
||||
import { ensureAgentWorkspace, applyAssistantName, normalizeAssistantName } from './agent-workspace.js';
|
||||
import { ensureAgentWorkspace, applyAssistantName, applyAssistantPrompt, normalizeAssistantName } from './agent-workspace.js';
|
||||
|
||||
export class JarvisDaemon extends EventEmitter {
|
||||
constructor() {
|
||||
@@ -30,7 +30,7 @@ export class JarvisDaemon extends EventEmitter {
|
||||
this.recovery = new StateRecovery(); const restored = this.recovery.load(); this.state = restored.state; this.mode = restored.mode;
|
||||
this.settings = voiceSettings();
|
||||
this.startupSettings = this.settings;
|
||||
this.workspace = ensureAgentWorkspace({ name: this.settings.assistantName });
|
||||
this.workspace = ensureAgentWorkspace({ name: this.settings.assistantName, prompt: this.settings.assistantPrompt });
|
||||
this.voice = new VoiceStateMachine({ idleMs: this.settings.idleMinutes * 60_000 });
|
||||
this.scheduler = new QvacScheduler({ concurrency: 1 });
|
||||
this.audit = new ComputerAudit();
|
||||
@@ -237,8 +237,9 @@ export class JarvisDaemon extends EventEmitter {
|
||||
this.settings = next;
|
||||
this.voice.idleMs = next.idleMinutes * 60_000;
|
||||
const who = applyAssistantName(this.workspace, next.assistantName);
|
||||
if (who !== normalizeAssistantName(previous.assistantName)) {
|
||||
this.harness.options.system = voiceSystemPrompt(who);
|
||||
applyAssistantPrompt(this.workspace, next.assistantPrompt);
|
||||
if (who !== normalizeAssistantName(previous.assistantName) || String(next.assistantPrompt || '') !== String(previous.assistantPrompt || '')) {
|
||||
this.harness.options.system = voiceSystemPrompt(who, next.assistantPrompt);
|
||||
await this.harness.resetContext();
|
||||
}
|
||||
if (['computerMode', 'computerSteps', 'computerGrantMinutes'].some(key => next[key] !== previous[key])) this.computerRevoke();
|
||||
|
||||
Reference in New Issue
Block a user