Mintplex-Labs/anything-llm · error · Error

type requires <text> argument

Error message

type requires <text> argument

What it means

Thrown by the 'type' branch of cdp-input.js when process.argv[3] is falsy. The script needs a non-empty text string to iterate over and dispatch per-character keyDown/keyUp events, so an absent argument aborts before any CDP call.

Source

Thrown at open-computer/services/interface-service/utils/cdp-input.js:147

      }, sessionId);
      await sleep(50);

      // Press
      await cdpSend(ws, "Input.dispatchMouseEvent", {
        type: "mousePressed", x, y, button: "left", clickCount: 1
      }, sessionId);
      await sleep(30 + Math.floor(Math.random() * 40));

      // Release
      await cdpSend(ws, "Input.dispatchMouseEvent", {
        type: "mouseReleased", x, y, button: "left", clickCount: 1
      }, sessionId);

      process.stdout.write(`clicked at (${x}, ${y})`);

    } else if (action === "type") {
      const text = process.argv[3];
      if (!text) throw new Error("type requires <text> argument");

      // Type each character individually with realistic delays
      for (let i = 0; i < text.length; i++) {
        const char = text[i];

        // dispatchKeyEvent with char sends the character as a trusted keyboard input
        await cdpSend(ws, "Input.dispatchKeyEvent", {
          type: "keyDown",
          text: char,
          key: char,
          code: charToCode(char),
          unmodifiedText: char,
        }, sessionId);

        await cdpSend(ws, "Input.dispatchKeyEvent", {
          type: "keyUp",
          key: char,
          code: charToCode(char),

View on GitHub (pinned to 526360e320)

Solutions

  1. Pass the text as the third argument: `node cdp-input.js type "hello world"`.
  2. Quote multi-word text so the shell delivers it as one argv entry.
  3. In the caller, assert the text is a non-empty string before spawning.

Example fix

// before
spawn('node', ['cdp-input.js', 'type']);
// after
spawn('node', ['cdp-input.js', 'type', 'hello world']);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof text !== 'string' || text.length === 0) {
  throw new Error('A non-empty text string is required for type action');
}

Prevention

When it happens

Trigger: Running `node cdp-input.js type` with no third argument, or with an argument that the shell expanded to an empty string. Note argv[4] is the optional target_url for type, not the text.

Common situations: The text was stored in a variable that resolved to undefined and String()-coerced to 'undefined'-less empty; shell quoting dropped the value; the caller reused the click argument layout (which shifts positions).

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/038487d3f9824447. Report an issue: GitHub.