moeru-ai/airi · warning

Unknown X command: ${input}. Supported commands: "post tweet

Error message

Unknown X command: ${input}. Supported commands: "post tweet: <text>", "search tweets: <query>", "like tweet: <tweetId>", "retweet: <tweetId>", "get user: <username>", "get timeline [count: N]"

What it means

Thrown by handleInput when parseTwitterCommand(input) returns null, meaning the raw input did not match any recognised X command prefix ('post tweet:', 'search tweets:', 'like tweet:', 'retweet:', 'get user:', 'get timeline'). This is a plain Error listing all supported commands, raised before any handler dispatch.

Source

Thrown at integrations/twitter-services/src/adapters/airi-adapter.ts:229

      data: {
        text: `Latest ${tweets.length} tweets from your timeline:
${tweets.map((t: Tweet) => `- ${t.author.displayName}: ${t.text.substring(0, 80)}...`).join('\n')}`,
      },
    })
    return true
  }

  private async handleInput(input: string): Promise<void> {
    let responseSent = false
    try {
      // Parse and handle X commands
      logger.main.log('Processing X command:', input)

      // Parse the command using the dedicated parsing function
      const parsedCommand = parseTwitterCommand(input)

      if (!parsedCommand) {
        throw new Error(`Unknown X command: ${input}. Supported commands: "post tweet: <text>", "search tweets: <query>", "like tweet: <tweetId>", "retweet: <tweetId>", "get user: <username>", "get timeline [count: N]"`)
      }

      // Execute the appropriate command handler based on the parsed command
      switch (parsedCommand.command) {
        case 'post tweet':
          await this.handlePostTweet(parsedCommand.content)
          break

        case 'search tweets':
          responseSent = await this.handleSearchTweets(parsedCommand.content)
          break

        case 'like tweet':
          await this.handleLikeTweet(parsedCommand.content)
          break

        case 'retweet':
          await this.handleRetweet(parsedCommand.content)

View on GitHub (pinned to 27111382b4)

Solutions

  1. Use one of the exact supported command prefixes, e.g. 'post tweet: hello'.
  2. Improve parseTwitterCommand to be case-insensitive and whitespace-tolerant.
  3. Have the adapter reply with the supported-commands list instead of throwing, so the user can self-correct.

Example fix

// before
const parsedCommand = parseTwitterCommand(input)
if (!parsedCommand) {
  throw new Error(`Unknown X command: ${input}. Supported commands: ...`)
}

// after — surface usage instead of throwing
const parsedCommand = parseTwitterCommand(input)
if (!parsedCommand) {
  this.client.send({ type: 'input:text', data: { text: 'Unknown command. Try: post tweet: <text>, search tweets: <query>, like tweet: <id>, retweet: <id>, get user: <name>, get timeline' } })
  return
}
Defensive patterns

Strategy: type-guard

Validate before calling

const parsedCommand = parseTwitterCommand(input)
if (!parsedCommand) {
  // surface the supported-commands list instead of throwing
  this.client.send({ type: 'input:text', data: { text: 'Supported X commands: post tweet:, search tweets:, like tweet:, retweet:, get user:, get timeline' } })
  return
}

Type guard

function isUnknownCommandError(e: unknown): boolean {
  return e instanceof Error && /Unknown X command:/.test(e.message)
}

Try / catch

try {
  await this.handleInput(input)
} catch (e) {
  if (e instanceof Error && /Unknown X command:/.test(e.message)) {
    // already lists supported commands; optionally reprompt the user
  } else throw e
}

Prevention

When it happens

Trigger: User sends free text that isn't a command, e.g. 'hello' or 'tweet hello' (missing the colon); uses an unsupported verb like 'delete tweet:'; casing/spacing differs from the parser's expected prefixes; the input is a partial command.

Common situations: User unfamiliar with the command grammar; LLM generated a paraphrase instead of the exact prefix; locale/casing differences; extra leading whitespace the parser does not normalise.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/95d38c22b6e2ba61. Report an issue: GitHub.