Global

Methods

chatgpt(bot)

Register the Mineflayer ChatGPT plugin on a bot instance.
Source:
Parameters:
Name Type Description
bot object Mineflayer bot instance.

checkConfidenceScore(confidenceScore, minimumReplyConfidenceScore, fallbackMessage) → {object}

Check if the confidence score is below the minimum threshold. If it is, returns a fallback message and flagged status. Otherwise, returns flagged false. LLM09 - Misinformation
Source:
Parameters:
Name Type Description
confidenceScore number Inferred confidence score.
minimumReplyConfidenceScore number Minimum allowed confidence.
fallbackMessage string Fallback reply.
Returns:
Type:
object
Confidence check result object.

checkLastMessageCoolDown(memory, player, coolDownInSeconds, fallbackMessage) → {object}

Check whether the player's last message is outside the configured cooldown. Returns flagged=true with fallback when the cooldown has not elapsed yet. LLM10 - Unbounded Consumption
Source:
Parameters:
Name Type Description
memory object Per-player memory store.
player string Player name or id.
coolDownInSeconds number Minimum elapsed seconds.
fallbackMessage string Fallback message returned on cooldown hit.
Returns:
Type:
object
Cooldown result object.

(async) detectJailbreakAttempt(moderationClient, message, minimumJailbreakConfidenceScoreopt, conversationHistoryopt) → {Promise.<boolean>}

Detect whether a message attempts to jailbreak instruction boundaries. LLM01 - Prompt Injection
Source:
Parameters:
Name Type Attributes Default Description
moderationClient object Client that can run the jailbreak guardrail.
message string Message text to inspect.
minimumJailbreakConfidenceScore number <optional>
0.7 Minimum confidence required to flag the message.
conversationHistory Array.<object> <optional>
[] Recent conversation messages.
Returns:
Type:
Promise.<boolean>
True when a jailbreak attempt is detected.

detectPromptLeakage(message) → {boolean}

Detect whether a message contains any security instruction text. LLM07 - System Prompt Leakage
Source:
Parameters:
Name Type Description
message string Message text to inspect.
Returns:
Type:
boolean
True when the message leaks security instructions.

(async) detectSecretsCredentials(message) → {Promise.<boolean>}

Detect whether a message contains possible secrets or credentials. LLM02 - Sensitive Information Disclosure
Source:
Parameters:
Name Type Description
message string Message text to inspect.
Returns:
Type:
Promise.<boolean>
True when secret-like content is detected.

detectSlashCommand(message) → {boolean}

Detect whether a message contains a Minecraft-style slash command. LLM05 - Improper Output Handling
Source:
Parameters:
Name Type Description
message string Message text to inspect.
Returns:
Type:
boolean
True when a slash command is present.

(async) moderateInboundReply(openAIClient, reply, fallbackMessage, confidenceScoreopt, minimumReplyConfidenceScoreopt) → {Promise.<object>}

Sanitise and moderate an inbound reply before it is sent to the player.
Source:
Parameters:
Name Type Attributes Default Description
openAIClient object Client instance that can call OpenAI moderation.
reply string Model reply.
fallbackMessage string Fallback message.
confidenceScore number <optional>
1 Reply confidence score.
minimumReplyConfidenceScore number <optional>
0 Minimum accepted confidence.
Returns:
Type:
Promise.<object>
Moderated inbound reply object.

(async) moderateOutboundMessage(openAIClient, memory, player, message, fallbackMessage, coolDownInSecondsopt, minimumJailbreakConfidenceScoreopt) → {Promise.<object>}

Sanitise and moderate an outbound message before it is sent to the model.
Source:
Parameters:
Name Type Attributes Default Description
openAIClient object Client instance that can call OpenAI moderation.
memory object Per-player memory store.
player string Player name or id.
message string Outbound message.
fallbackMessage string Fallback message.
coolDownInSeconds number <optional>
15 Minimum seconds between messages.
minimumJailbreakConfidenceScore number <optional>
0.7 Minimum confidence required to flag a jailbreak.
Returns:
Type:
Promise.<object>
Moderated outbound message object.

sanitiseProfanity(message) → {string}

Sanitise profanity in a string.
Source:
Parameters:
Name Type Description
message string Message text.
Returns:
Type:
string
Sanitised message.

validateCoolDownInSeconds(coolDownInSeconds) → {number}

Validate the minimum delay between player messages. The delay must be a finite, non-negative number of seconds.
Source:
Parameters:
Name Type Description
coolDownInSeconds number Cooldown duration to validate.
Throws:
When the duration is not finite or is negative.
Type
RangeError
Returns:
Type:
number
The validated cooldown duration.

validateEnableMessageLogging(enableMessageLogging) → {boolean}

Validate whether model reply logging is enabled.
Source:
Parameters:
Name Type Description
enableMessageLogging boolean Reply logging setting to validate.
Throws:
When the setting is not a boolean.
Type
TypeError
Returns:
Type:
boolean
The validated setting.

validateEnableModeration(enableModeration) → {boolean}

Validate whether moderation is enabled.
Source:
Parameters:
Name Type Description
enableModeration boolean Moderation setting to validate.
Throws:
When the setting is not a boolean.
Type
TypeError
Returns:
Type:
boolean
The validated setting.

validateEnableSecurityInstructions(enableSecurityInstructions) → {boolean}

Validate whether security instructions are enabled.
Source:
Parameters:
Name Type Description
enableSecurityInstructions boolean Security instruction setting to validate.
Throws:
When the setting is not a boolean.
Type
TypeError
Returns:
Type:
boolean
The validated setting.

validateFallbackMessage(fallbackMessage) → {string}

Validate the message returned when a reply cannot be provided.
Source:
Parameters:
Name Type Description
fallbackMessage string Fallback message to validate.
Throws:
When the message is not a non-empty string.
Type
TypeError
Returns:
Type:
string
The validated fallback message.

validateJailbreakConfidenceScore(minimumJailbreakConfidenceScore) → {number}

Validate the minimum confidence score used to flag jailbreak attempts. The score must be a finite number in the inclusive range from 0 to 1.
Source:
Parameters:
Name Type Description
minimumJailbreakConfidenceScore number Confidence score to validate.
Throws:
When the score is not a finite number from 0 to 1.
Type
RangeError
Returns:
Type:
number
The validated confidence score.

validateReplyConfidenceScore(minimumReplyConfidenceScore) → {number}

Validate the minimum confidence score accepted for model replies. The score must be a finite number in the inclusive range from 0 to 1.
Source:
Parameters:
Name Type Description
minimumReplyConfidenceScore number Confidence score to validate.
Throws:
When the score is not a finite number from 0 to 1.
Type
RangeError
Returns:
Type:
number
The validated confidence score.