@@ -1293,7 +1293,10 @@ const registerHandlerTool = defineTool("register_handler", {
12931293 "The code is compiled but NOT executed — call execute_javascript to run it." ,
12941294 "" ,
12951295 "REQUIRED: Code must define `function handler(event) { ... return result; }`" ,
1296+ "Use `async function handler(event)` only when the handler contains await." ,
12961297 "The function MUST be named exactly 'handler' — not Handler, handle, main." ,
1298+ "The parameter name is flexible; use 'event' by convention, or omit it if unused." ,
1299+ "Do NOT use arrow handlers such as `const handler = (event) => { ... }`." ,
12971300 "" ,
12981301 "⚠️ TO UPDATE EXISTING CODE: Use get_handler_source first!" ,
12991302 "When fixing errors, call get_handler_source(name) to get current code," ,
@@ -1332,8 +1335,9 @@ const registerHandlerTool = defineTool("register_handler", {
13321335 code : {
13331336 type : "string" ,
13341337 description :
1335- "JavaScript source code. Simple mode: use `return` for output. " +
1336- "Module mode: define `function handler(event) { ... }`." ,
1338+ "JavaScript source code. Define `function handler(event) { ... return result; }`, " +
1339+ "`function handler() { ... return result; }` if no input is needed, " +
1340+ "or `async function handler(event) { ... return result; }` if using await." ,
13371341 } ,
13381342 } ,
13391343 required : [ "name" , "code" ] ,
@@ -2893,9 +2897,10 @@ const HELP_TOPICS: Record<string, string> = {
28932897 "- Handlers CANNOT call other handlers — they are isolated modules" ,
28942898 "- YOU orchestrate: pass handler A's result as handler B's event" ,
28952899 "" ,
2896- "TWO CODE STYLES (auto-detected):" ,
2897- "- Simple: no 'function handler' → wrapped as function body, locals reset each call" ,
2898- "- Module: defines 'function handler(event)' → module-level state persists" ,
2900+ "HANDLER CODE STYLE:" ,
2901+ "- Every handler must define function handler(event) or async function handler(event)" ,
2902+ "- The function name is mandatory; parameter names are flexible, and zero parameters are allowed" ,
2903+ "- Module-level state persists across execute_javascript calls" ,
28992904 "" ,
29002905 "COMMON MISTAKES:" ,
29012906 "- Function must be named exactly 'handler' (not Handler, handle, main)" ,
@@ -2949,7 +2954,7 @@ const HELP_TOPICS: Record<string, string> = {
29492954 debugging : [
29502955 "DEBUGGING TIPS:" ,
29512956 "- 'not a function' = you guessed a method name. Call module_info/plugin_info to verify." ,
2952- "- register_handler returns codeSize and mode (module/simple) — check these" ,
2957+ "- register_handler returns codeSize and mode — check these" ,
29532958 "- If handler errors, try a minimal version first" ,
29542959 "- Build up complexity gradually — add one feature at a time" ,
29552960 "- Use try/catch inside handlers to catch runtime errors cleanly" ,
0 commit comments