@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.
@@ -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}}` placeholder with the current contents of `user-info.json`. This happens at runtime on every request — the placeholder is never stored in the conversation history.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
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.')
@@ -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
  });
@@ -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.replace('{{user_info}}', userInfo);
77
+ return promptTemplate
78
+ .replace('{{session_id}}', sessionId || 'unknown')
79
+ .replace('{{user_info}}', userInfo);
78
80
  }