From 74701ea6634021a8833c52db4cd7309313bcfa7c Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Thu, 21 Nov 2024 23:30:42 -0600 Subject: [PATCH] fixed string parsing, force double-quote strings --- src/agent/commands/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/agent/commands/index.js b/src/agent/commands/index.js index d6de194..6170962 100644 --- a/src/agent/commands/index.js +++ b/src/agent/commands/index.js @@ -14,8 +14,8 @@ export function getCommand(name) { return commandMap[name]; } -const commandRegex = /!(\w+)(?:\(([\s\S]*)\))?/ -const argRegex = /(?:"[^"]*"|'[^']*'|[^,])+/g; +const commandRegex = /!(\w+)(?:\(((?:\d+|true|false|"[^"]*")(?:\s*,\s*(?:\d+|true|false|"[^"]*"))*)\))?/ +const argRegex = /\d+|true|false|"[^"]*"/g; export function containsCommand(message) { const commandMatch = message.match(commandRegex); @@ -82,7 +82,7 @@ function checkInInterval(number, lowerBound, upperBound, endpointType) { * @param {string} message - A message from a player or language model containing a command. * @returns {string | Object} */ -function parseCommandMessage(message) { +export function parseCommandMessage(message) { const commandMatch = message.match(commandRegex); if (!commandMatch) return `Command is incorrectly formatted`; @@ -232,7 +232,7 @@ export function getCommandDocs() { } let docs = `\n*COMMAND DOCS\n You can use the following commands to perform actions and get information about the world. Use the commands with the syntax: !commandName or !commandName("arg1", 1.2, ...) if the command takes arguments.\n - Do not use codeblocks. Only use one command in each response, trailing commands and comments will be ignored.\n`; + Do not use codeblocks. Use double quotes for strings. Only use one command in each response, trailing commands and comments will be ignored.\n`; for (let command of commandList) { docs += command.name + ': ' + command.description + '\n'; if (command.params) {