@ducci/jarvis 1.0.12 → 1.0.14
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/docs/system-prompt.md +5 -1
- package/package.json +1 -1
- package/src/index.js +24 -0
- package/src/server/agent.js +1 -1
- package/src/server/config.js +4 -2
package/docs/system-prompt.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This is the authoritative system prompt sent to the model at the start of every session. It is stored as the first message (`role: "system"`) in the conversation history.
|
|
4
4
|
|
|
5
|
-
Before sending to the model, the server replaces the `{{user_info}}`
|
|
5
|
+
Before sending to the model, the server replaces the `{{user_info}}` and `{{session_id}}` placeholders at runtime on every request — these are never stored in the conversation history.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
You are Jarvis, a fully autonomous agent running on a local server. You have access to tools and can execute shell commands on the machine you run on.
|
|
11
11
|
|
|
12
|
+
## Session
|
|
13
|
+
|
|
14
|
+
Current session ID: {{session_id}}
|
|
15
|
+
|
|
12
16
|
## Known User Context
|
|
13
17
|
|
|
14
18
|
{{user_info}}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -180,6 +180,30 @@ program
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
+
program
|
|
184
|
+
.command('restart')
|
|
185
|
+
.description('Restart the Jarvis server (starts it if not running).')
|
|
186
|
+
.action(async () => {
|
|
187
|
+
preflight();
|
|
188
|
+
try {
|
|
189
|
+
await connectPm2();
|
|
190
|
+
const desc = await pm2Describe().catch(() => []);
|
|
191
|
+
const isRunning = desc.length > 0 && desc[0].pm2_env?.status === 'online';
|
|
192
|
+
if (isRunning) {
|
|
193
|
+
await pm2Restart();
|
|
194
|
+
console.log('Jarvis server restarted.');
|
|
195
|
+
} else {
|
|
196
|
+
await pm2Start();
|
|
197
|
+
console.log('Jarvis server started.');
|
|
198
|
+
}
|
|
199
|
+
pm2.disconnect();
|
|
200
|
+
} catch (e) {
|
|
201
|
+
console.error('Failed to restart Jarvis server:', e.message);
|
|
202
|
+
pm2.disconnect();
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
183
207
|
program
|
|
184
208
|
.command('status')
|
|
185
209
|
.description('Display the status of the Jarvis server.')
|
package/src/server/agent.js
CHANGED
|
@@ -330,7 +330,7 @@ export async function handleChat(config, requestSessionId, userMessage) {
|
|
|
330
330
|
function prepareMessages(messages) {
|
|
331
331
|
return messages.map((msg, i) => {
|
|
332
332
|
if (i === 0 && msg.role === 'system') {
|
|
333
|
-
return { ...msg, content: resolveSystemPrompt(msg.content) };
|
|
333
|
+
return { ...msg, content: resolveSystemPrompt(msg.content, sessionId) };
|
|
334
334
|
}
|
|
335
335
|
return msg;
|
|
336
336
|
});
|
package/src/server/config.js
CHANGED
|
@@ -63,7 +63,7 @@ export function loadSystemPrompt() {
|
|
|
63
63
|
return match[1].trim();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function resolveSystemPrompt(promptTemplate) {
|
|
66
|
+
export function resolveSystemPrompt(promptTemplate, sessionId) {
|
|
67
67
|
let userInfo = '(none yet)';
|
|
68
68
|
try {
|
|
69
69
|
const raw = fs.readFileSync(PATHS.userInfoFile, 'utf8');
|
|
@@ -74,5 +74,7 @@ export function resolveSystemPrompt(promptTemplate) {
|
|
|
74
74
|
} catch {
|
|
75
75
|
// File doesn't exist yet
|
|
76
76
|
}
|
|
77
|
-
return promptTemplate
|
|
77
|
+
return promptTemplate
|
|
78
|
+
.replace('{{session_id}}', sessionId || 'unknown')
|
|
79
|
+
.replace('{{user_info}}', userInfo);
|
|
78
80
|
}
|