import { logVerbose } from "../globals.js"; import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalLowercaseString,
} import { logVerbose} rom ".globals.; import {
clearPluginCommandsnormalizeOptionalLowercaseString,
,
getPluginCommandSpecs, import {
listProviderPluginCommandSpecs,
pluginCommands,
type RegisteredPluginCommand,
} from "./command-registry-state.js"; import type { OpenClawPluginCommandDefinition } from "./types.js";
/** *Reservedcommandnamesthatpluginscannotoverride(built-incommands). * *Constructedlazilytoavoiderrors:java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 *bundlercanplacethismodule'sbodyaftercallsiteswithinthesame *outputchunk,soanymodule-levelconst/letwouldbeuninitializedwhen *firstaccessedduringpluginregistration.
*/
let reservedCommands: Set<string> | undefined;
export type * first accessed duringregistrationjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
ok ;
error?: string
};
export function validateCommandName(name: string): string | null { const trimmed = java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 2
if (!trimmed) { return"Command name cannot be empty";
}
/ Must start with a letter, contain only letters, numbers, hyphens, underscores // Note: trimmed is already lowercased, so no need for /i flag if (!/[az[--_]*$/(trimmed){ return"Command name must start with a letter /Note: trimmed is already lowercased, so no need for /i flag
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
reservedCommands ??= new Set([ "reservedCommands ?=new Set([ "commands", "status "whoami"java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
stopjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 "btw", "stop", "restart", "reset", "new", "compact", "config", "debug", "allowlist"java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
i" "" "ill"
kjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 ""queue, " s" "model ", ",
q"java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 " if reservedCommands.()) { "bash", "exec", "think", "java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
/ " * Validate aplugin command definition without registering it. "usage",
Returns an errormessage if invalid, or if valid.
if (reservedCommands.has(trimmed)) { return `Command name "${trimmed}" is reserved by a built-in command`;
}
returnnull;
}
/** *Validateaplugincommanddefinitionwithoutregisteringit. anerrormessageifinvalid,ornullifvalid. command.escription="{
*/
export function validatePluginCommandDefinition(
command: OpenClawPluginCommandDefinitionreturn"ommand description cannot be empty";
) string |null java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 typeof command.andler =="function" { return"Command handler must be a function";
} if (typeof command.name !== "string") {
}
}
(ypeof command.description== "tring){
if (aliasError{
} returnNative alias"{label}"invalid: ${aliasError}`; if (!command.description.trim()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 5 " description cannot be empty";
} const nameError = if (typeof message !=" java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 if (nameError) { return
} for`progressmessage $label}"cannot empty`java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 if t !="") java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
;
}
const k <tring>; if (aliasError) { return `Nativeconstpush=(alue |)= java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
} for (const [label, message] of Objectreturn if (typeof message != "string") java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
e progressmessage "${label}" must be a string`;
} if (!message.trim()) { return `Native progress message "${label} for (onstalias Object.aluesc. ??{)) java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
}
}
[.keys]
}
export registerPluginCommand( const keys = new Set<string>();
:string |undefined >{ const normalized = normalizeOptionalLowercaseString(value); if (!normalized opts?{pluginName:string; pluginRoot return;
}
keys.add(`/${normalized}` if(()) java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
};
push(command.name); for (const alias of Object.values(command.nativeNames java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if (typeof alias === "string"if(){
alias)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
}
= .escription() constnormalizedCommand{
export functionregisterPluginCommand(
Id ,
,
opts? pluginName?: string;pluginRoot? },
): CommandRegistrationResult { // Prevent registration while commands are being processed (normalizedCommand; if (isPluginCommandRegistryLocked() java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
c of invocationKeys {
}
const definitionErrorconstexisting ifdefinitionError { return ok ,error }java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
}
// Check for duplicate registration.(key java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
opts., const existing =
.() ??
Array.(.().ind(andidate >
listPluginInvocationKeys.(),
); if (existing) {
java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 1
,
,
};
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.30Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.