titan-agent 5.0.3 → 5.1.1
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/agent/agent.js +9 -8
- package/dist/agent/agent.js.map +1 -1
- package/dist/eval/harness.js +280 -0
- package/dist/eval/harness.js.map +1 -1
- package/dist/gateway/server.js +43 -3
- package/dist/gateway/server.js.map +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/safety.js +25 -0
- package/dist/utils/safety.js.map +1 -0
- package/package.json +1 -1
package/dist/agent/agent.js
CHANGED
|
@@ -30,6 +30,7 @@ import { spawnSubAgent, SUB_AGENT_TEMPLATES } from "./subAgent.js";
|
|
|
30
30
|
import { logTrajectory } from "./trajectoryLogger.js";
|
|
31
31
|
import { processTrajectoryForSkills, getSkillGuidance } from "./autoSkillGen.js";
|
|
32
32
|
import { getAgent } from "./multiAgent.js";
|
|
33
|
+
import { isDangerous } from "../utils/safety.js";
|
|
33
34
|
import { registerTool } from "./toolRunner.js";
|
|
34
35
|
import { runAgentLoop } from "./agentLoop.js";
|
|
35
36
|
import { startTrace } from "./tracer.js";
|
|
@@ -859,7 +860,7 @@ ${weatherParts.join("\n")}`;
|
|
|
859
860
|
addMessage(session, "user", message);
|
|
860
861
|
initGraph();
|
|
861
862
|
addEpisode(`[${channel}/${userId}] ${message}`, channel).catch((e) => logger.debug("Agent", `Background op failed: ${e.message}`));
|
|
862
|
-
const
|
|
863
|
+
const dangerous = isDangerous(message);
|
|
863
864
|
let systemPrompt;
|
|
864
865
|
if (voiceFastPath) {
|
|
865
866
|
const voiceGraphCtx = message ? await getGraphContext(message) : "";
|
|
@@ -915,7 +916,7 @@ ${voiceMemCtx}
|
|
|
915
916
|
systemPrompt += '\n\nREMINDER: Your communication style is always formal, measured, and inspired by Andrew Martin. Say "Sir". No contractions. Never say "I am an AI assistant" \u2014 you are TITAN.';
|
|
916
917
|
}
|
|
917
918
|
logger.info("Agent", `Voice prompt: ${systemPrompt.length} chars, memory: ${memoryBlock.length} chars, graph: ${voiceGraphCtx.length} chars`);
|
|
918
|
-
if (
|
|
919
|
+
if (dangerous) {
|
|
919
920
|
systemPrompt += "\n\n\u26A0\uFE0F SAFETY OVERRIDE: The user message contains a potentially destructive or privileged command. You MUST refuse to execute it. Respond with a polite refusal explaining why. Do NOT use any tools for this request.";
|
|
920
921
|
}
|
|
921
922
|
} else {
|
|
@@ -948,22 +949,22 @@ Continue executing this task NOW using the appropriate tools. Do NOT re-explain,
|
|
|
948
949
|
logger.info(COMPONENT, `[TaskContinuation] Injected context for short confirmation: "${message}"`);
|
|
949
950
|
}
|
|
950
951
|
}
|
|
951
|
-
if (
|
|
952
|
+
if (dangerous) {
|
|
952
953
|
systemPrompt += "\n\n\u26A0\uFE0F SAFETY OVERRIDE: The user message contains a potentially destructive or privileged command. You MUST refuse to execute it. Respond with a polite refusal explaining why. Do NOT use any tools for this request.";
|
|
953
954
|
}
|
|
954
|
-
if (!
|
|
955
|
+
if (!dangerous && /\b(write|save|create|generate|output|produce|make)\b.{0,60}\b(file|doc|report|md|txt|json|csv|log|notes?|summary|readme)\b/i.test(message)) {
|
|
955
956
|
systemPrompt += "\n\nWhen the user asks you to write or create a file, you MUST use write_file or edit_file to save it. Do NOT just type the content in your reply \u2014 the user expects an actual file on disk.";
|
|
956
957
|
taskEnforcementActive = true;
|
|
957
958
|
}
|
|
958
|
-
if (!
|
|
959
|
+
if (!dangerous && /\b(read|show|display|view|open|cat|get)\b.{0,60}\b(file|content|text|readme|md|txt|json|csv|log|code|source)\b/i.test(message) && !/\b(?:write|save|create|edit|modify)\b/i.test(message)) {
|
|
959
960
|
systemPrompt += "\n\nWhen the user asks you to read or show a file, you MUST use read_file to fetch its contents. Do NOT use shell or other tools \u2014 read_file is the correct tool for viewing file contents.";
|
|
960
961
|
taskEnforcementActive = true;
|
|
961
962
|
}
|
|
962
|
-
if (!
|
|
963
|
+
if (!dangerous && /\b(research|search|find|look ?up|what is|what are|current|latest|today|news|price|stock|score|update)\b/i.test(message) && !/weather/i.test(message)) {
|
|
963
964
|
systemPrompt += "\n\nWhen the user asks for current information, news, or research, you MUST search the web to get up-to-date results. Do NOT rely only on what you already know.";
|
|
964
965
|
taskEnforcementActive = true;
|
|
965
966
|
}
|
|
966
|
-
if (!
|
|
967
|
+
if (!dangerous && /\b(run|execute|install|check|build|compile|start|stop|restart|deploy|test)\b.{0,40}\b(command|script|package|service|server|process|app)\b/i.test(message)) {
|
|
967
968
|
systemPrompt += "\n\nWhen the user asks you to run a command, install something, or start/stop a service, you MUST use the shell tool to actually execute it. Do NOT just describe what the command would do.";
|
|
968
969
|
taskEnforcementActive = true;
|
|
969
970
|
}
|
|
@@ -1111,7 +1112,7 @@ Do NOT just describe it \u2014 actually create the widget on the canvas.`;
|
|
|
1111
1112
|
}
|
|
1112
1113
|
logger.info(COMPONENT, `[ToolSearch] Compact mode: ${allToolsBackup.length} \u2192 ${activeTools.length} tools (${allToolsBackup.length - activeTools.length} discoverable via tool_search)`);
|
|
1113
1114
|
}
|
|
1114
|
-
if (
|
|
1115
|
+
if (dangerous) {
|
|
1115
1116
|
activeTools = [];
|
|
1116
1117
|
logger.info(COMPONENT, "[Safety] Stripped all tools \u2014 dangerous command detected");
|
|
1117
1118
|
}
|