fix: use ADD_SUGGESTION_TOOL instead of ADD_SUGG_TOOL
All checks were successful
BotServer CI/CD / build (push) Successful in 3m17s
All checks were successful
BotServer CI/CD / build (push) Successful in 3m17s
This commit is contained in:
parent
efe45bb296
commit
c6a47c84ac
3 changed files with 21 additions and 46 deletions
|
|
@ -488,9 +488,9 @@ impl BasicCompiler {
|
||||||
.replace("FOR EACH", "FOR_EACH")
|
.replace("FOR EACH", "FOR_EACH")
|
||||||
.replace("EXIT FOR", "EXIT_FOR")
|
.replace("EXIT FOR", "EXIT_FOR")
|
||||||
.replace("GROUP BY", "GROUP_BY")
|
.replace("GROUP BY", "GROUP_BY")
|
||||||
.replace("ADD SUGGESTION TOOL", "ADD_SUGG_TOOL")
|
.replace("ADD SUGGESTION TOOL", "ADD_SUGGESTION_TOOL")
|
||||||
.replace("ADD SUGGESTION TEXT", "ADD_SUGG_TEXT")
|
.replace("ADD SUGGESTION TEXT", "ADD_SUGGESTION_TEXT")
|
||||||
.replace("ADD SUGGESTION", "ADD_SUGG");
|
.replace("ADD SUGGESTION", "ADD_SUGGESTION");
|
||||||
if normalized.starts_with("SET SCHEDULE") || trimmed.starts_with("SET SCHEDULE") {
|
if normalized.starts_with("SET SCHEDULE") || trimmed.starts_with("SET SCHEDULE") {
|
||||||
has_schedule = true;
|
has_schedule = true;
|
||||||
let parts: Vec<&str> = normalized.split('"').collect();
|
let parts: Vec<&str> = normalized.split('"').collect();
|
||||||
|
|
|
||||||
|
|
@ -69,17 +69,15 @@ pub fn add_suggestion_keyword(
|
||||||
) {
|
) {
|
||||||
// Each closure needs its own Arc<redis::Client> and UserSession clone
|
// Each closure needs its own Arc<redis::Client> and UserSession clone
|
||||||
let cache = state.cache.clone();
|
let cache = state.cache.clone();
|
||||||
let cache2 = state.cache.clone();
|
|
||||||
let cache3 = state.cache.clone();
|
let cache3 = state.cache.clone();
|
||||||
let cache4 = state.cache.clone();
|
let cache4 = state.cache.clone();
|
||||||
let user_session2 = user_session.clone();
|
|
||||||
let user_session3 = user_session.clone();
|
let user_session3 = user_session.clone();
|
||||||
let user_session4 = user_session.clone();
|
let user_session4 = user_session.clone();
|
||||||
|
|
||||||
// ADD_SUGG_TOOL "tool_name" AS "button text" — single-token to avoid ADD conflicts
|
// ADD_SUGGESTION_TOOL "tool_name" AS "button text"
|
||||||
engine
|
engine
|
||||||
.register_custom_syntax(
|
.register_custom_syntax(
|
||||||
["ADD_SUGG_TOOL", "$expr$", "AS", "$expr$"],
|
["ADD_SUGGESTION_TOOL", "$expr$", "AS", "$expr$"],
|
||||||
true,
|
true,
|
||||||
move |context, inputs| {
|
move |context, inputs| {
|
||||||
let tool_name = context.eval_expression_tree(&inputs[0])?.to_string();
|
let tool_name = context.eval_expression_tree(&inputs[0])?.to_string();
|
||||||
|
|
@ -98,32 +96,10 @@ pub fn add_suggestion_keyword(
|
||||||
)
|
)
|
||||||
.expect("valid syntax registration");
|
.expect("valid syntax registration");
|
||||||
|
|
||||||
// ADD_SUGGESTION_TOOL — legacy alias, same handler
|
// ADD_SUGGESTION_TEXT "text_value" AS "button text"
|
||||||
engine
|
engine
|
||||||
.register_custom_syntax(
|
.register_custom_syntax(
|
||||||
["ADD_SUGGESTION_TOOL", "$expr$", "AS", "$expr$"],
|
["ADD_SUGGESTION_TEXT", "$expr$", "AS", "$expr$"],
|
||||||
true,
|
|
||||||
move |context, inputs| {
|
|
||||||
let tool_name = context.eval_expression_tree(&inputs[0])?.to_string();
|
|
||||||
let button_text = context.eval_expression_tree(&inputs[1])?.to_string();
|
|
||||||
|
|
||||||
add_tool_suggestion(
|
|
||||||
cache2.as_ref(),
|
|
||||||
&user_session2,
|
|
||||||
&tool_name,
|
|
||||||
None,
|
|
||||||
&button_text,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(Dynamic::UNIT)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.expect("valid syntax registration");
|
|
||||||
|
|
||||||
// ADD_SUGG_TEXT "text_value" AS "button text" — single-token
|
|
||||||
engine
|
|
||||||
.register_custom_syntax(
|
|
||||||
["ADD_SUGG_TEXT", "$expr$", "AS", "$expr$"],
|
|
||||||
true,
|
true,
|
||||||
move |context, inputs| {
|
move |context, inputs| {
|
||||||
let text_value = context.eval_expression_tree(&inputs[0])?.to_string();
|
let text_value = context.eval_expression_tree(&inputs[0])?.to_string();
|
||||||
|
|
@ -136,16 +112,21 @@ pub fn add_suggestion_keyword(
|
||||||
)
|
)
|
||||||
.expect("valid syntax registration");
|
.expect("valid syntax registration");
|
||||||
|
|
||||||
// ADD_SUGG "context_name" AS "button text" — single-token
|
// ADD_SUGGESTION "context_name" AS "button text"
|
||||||
engine
|
engine
|
||||||
.register_custom_syntax(
|
.register_custom_syntax(
|
||||||
["ADD_SUGG", "$expr$", "AS", "$expr$"],
|
["ADD_SUGGESTION", "$expr$", "AS", "$expr$"],
|
||||||
true,
|
true,
|
||||||
move |context, inputs| {
|
move |context, inputs| {
|
||||||
let context_name = context.eval_expression_tree(&inputs[0])?.to_string();
|
let context_name = context.eval_expression_tree(&inputs[0])?.to_string();
|
||||||
let button_text = context.eval_expression_tree(&inputs[1])?.to_string();
|
let button_text = context.eval_expression_tree(&inputs[1])?.to_string();
|
||||||
|
|
||||||
add_context_suggestion(cache4.as_ref(), &user_session4, &context_name, &button_text)?;
|
add_context_suggestion(
|
||||||
|
cache4.as_ref(),
|
||||||
|
&user_session4,
|
||||||
|
&context_name,
|
||||||
|
&button_text,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(Dynamic::UNIT)
|
Ok(Dynamic::UNIT)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2022,14 +2022,11 @@ impl ScriptService {
|
||||||
(r#"CLEAR\s+TOOLS"#, 0, 0, vec![]),
|
(r#"CLEAR\s+TOOLS"#, 0, 0, vec![]),
|
||||||
(r#"CLEAR\s+WEBSITES"#, 0, 0, vec![]),
|
(r#"CLEAR\s+WEBSITES"#, 0, 0, vec![]),
|
||||||
|
|
||||||
// ADD family - single-token keywords to avoid ADD conflicts
|
// ADD family - single-token keywords to avoid ADD conflicts
|
||||||
(r#"ADD_SUGG_TOOL"#, 2, 2, vec!["tool", "text"]),
|
(r#"ADD_SUGGESTION_TOOL"#, 2, 2, vec!["tool", "text"]),
|
||||||
(r#"ADD_SUGG_TEXT"#, 2, 2, vec!["value", "text"]),
|
(r#"ADD_SUGGESTION_TEXT"#, 2, 2, vec!["value", "text"]),
|
||||||
(r#"ADD_SUGG(?!\s+TOOL|\s+TEXT|_)"#, 2, 2, vec!["context", "text"]),
|
(r#"ADD_SUGGESTION(?!\\s+TOOL|\\s+TEXT|_)"#, 2, 2, vec!["context", "text"]),
|
||||||
(r#"ADD_SUGGESTION_TOOL"#, 2, 2, vec!["tool", "text"]),
|
(r#"ADD\\s+MEMBER"#, 2, 2, vec!["name", "role"]),
|
||||||
(r#"ADD_SUGGESTION_TEXT"#, 2, 2, vec!["value", "text"]),
|
|
||||||
(r#"ADD_SUGGESTION(?!\s+TOOL|\s+TEXT|_)"#, 2, 2, vec!["context", "text"]),
|
|
||||||
(r#"ADD\s+MEMBER"#, 2, 2, vec!["name", "role"]),
|
|
||||||
|
|
||||||
// CREATE family
|
// CREATE family
|
||||||
(r#"CREATE\s+TASK"#, 1, 1, vec!["task"]),
|
(r#"CREATE\s+TASK"#, 1, 1, vec!["task"]),
|
||||||
|
|
@ -2057,11 +2054,8 @@ impl ScriptService {
|
||||||
// Skip lines that already use underscore-style custom syntax
|
// Skip lines that already use underscore-style custom syntax
|
||||||
// These are registered directly with Rhai and should not be converted
|
// These are registered directly with Rhai and should not be converted
|
||||||
let trimmed_upper = trimmed.to_uppercase();
|
let trimmed_upper = trimmed.to_uppercase();
|
||||||
if trimmed_upper.contains("ADD_SUGG_TOOL") ||
|
if trimmed_upper.contains("ADD_SUGGESTION_TOOL") ||
|
||||||
trimmed_upper.contains("ADD_SUGG_TEXT") ||
|
|
||||||
trimmed_upper.contains("ADD_SUGGESTION_TOOL") ||
|
|
||||||
trimmed_upper.contains("ADD_SUGGESTION_TEXT") ||
|
trimmed_upper.contains("ADD_SUGGESTION_TEXT") ||
|
||||||
trimmed_upper.starts_with("ADD_SUGG_") ||
|
|
||||||
trimmed_upper.starts_with("ADD_SUGGESTION_") ||
|
trimmed_upper.starts_with("ADD_SUGGESTION_") ||
|
||||||
trimmed_upper.starts_with("ADD_MEMBER") ||
|
trimmed_upper.starts_with("ADD_MEMBER") ||
|
||||||
(trimmed_upper.starts_with("USE_") && trimmed.contains('(')) {
|
(trimmed_upper.starts_with("USE_") && trimmed.contains('(')) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue