@ducci/jarvis 1.0.16 → 1.0.18

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.
@@ -44,6 +44,15 @@ You have access to a set of tools. Each tool has a name and description that tel
44
44
  - If the user shares personal information, persist it using the appropriate tool.
45
45
  - Prefer using tools over making assumptions about the state of the system.
46
46
 
47
+ ## exec Safety
48
+
49
+ The `exec` tool runs real shell commands on the server. Use it responsibly:
50
+
51
+ - **Never scan from filesystem root.** Commands like `find /`, `find / -name ...`, or `ls -R /` will scan everything including `/proc`, `/sys`, and network mounts. They can saturate CPU and I/O for minutes. Always scope `find` to a specific directory (e.g. `find ~/jarvis -name "*.js"`).
52
+ - **Use known paths.** Prefer `process.cwd()`, `$HOME`, or paths you already know over broad searches. Use `which <binary>` to locate executables.
53
+ - **Prefer targeted reads.** Use `grep`, `head`, or `tail` instead of `cat` on files you haven't seen before. Large file output is truncated anyway — a targeted command gives you better signal.
54
+ - **Avoid commands with unbounded runtime.** If a command could run indefinitely or scan an unknown-size tree, scope it first.
55
+
47
56
  ## logSummary Guidelines
48
57
 
49
58
  The `logSummary` is written for a human observer, not for the user. It must:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -45,20 +45,36 @@ export async function startTelegramChannel(config) {
45
45
  ctx.api.sendChatAction(chatId, 'typing').catch(() => {});
46
46
  }, 4000);
47
47
 
48
+ let result;
48
49
  try {
49
- const result = await handleChat(config, sessionId, ctx.message.text);
50
+ result = await handleChat(config, sessionId, ctx.message.text);
51
+ } catch (e) {
52
+ console.error(`[telegram] agent error chat_id=${chatId}: ${e.message}`);
53
+ await ctx.reply('Sorry, something went wrong. Please try again.');
54
+ clearInterval(typingInterval);
55
+ return;
56
+ }
50
57
 
51
- // Persist new session mapping on first message
52
- if (!sessions[chatId]) {
53
- sessions[chatId] = result.sessionId;
54
- save(sessions);
55
- console.log(`[telegram] session created sessionId=${result.sessionId.slice(0, 8)}`);
56
- }
58
+ // Persist new session mapping on first message
59
+ if (!sessions[chatId]) {
60
+ sessions[chatId] = result.sessionId;
61
+ save(sessions);
62
+ console.log(`[telegram] session created sessionId=${result.sessionId.slice(0, 8)}`);
63
+ }
57
64
 
58
- await ctx.reply(result.response);
59
- console.log(`[telegram] response sent chat_id=${chatId}`);
65
+ try {
66
+ const MAX_TG = 4096;
67
+ const text = result.response;
68
+ if (text.length <= MAX_TG) {
69
+ await ctx.reply(text);
70
+ } else {
71
+ for (let i = 0; i < text.length; i += MAX_TG) {
72
+ await ctx.reply(text.slice(i, i + MAX_TG));
73
+ }
74
+ }
75
+ console.log(`[telegram] response sent chat_id=${chatId} length=${text.length}`);
60
76
  } catch (e) {
61
- console.error(`[telegram] error chat_id=${chatId}: ${e.message}`);
77
+ console.error(`[telegram] delivery error chat_id=${chatId} length=${result.response.length}: ${e.message}`);
62
78
  await ctx.reply('Sorry, something went wrong. Please try again.');
63
79
  } finally {
64
80
  clearInterval(typingInterval);