diff --git a/package-lock.json b/package-lock.json index 9358015..ced4e7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -396,6 +396,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -600,6 +601,7 @@ "resolved": "https://registry.npmjs.org/hono/-/hono-4.11.7.tgz", "integrity": "sha512-l7qMiNee7t82bH3SeyUCt9UF15EVmaBvsppY2zQtrbIhl/yzBTny+YUxsVjSjQ6gaqaeVtZmGocom8TzBlA4Yw==", "license": "MIT", + "peer": true, "engines": { "node": ">=16.9.0" } @@ -1170,6 +1172,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/index.ts b/src/index.ts index 064a6c8..a12c45d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ import { XMCPServer } from './mcp/server.js'; async function main() { // Redirect console.log to stderr so it doesn't conflict with // MCP StdioServerTransport which uses stdout for protocol messages - console.log = (...args: any[]) => console.error(...args); + console.log = (...args: unknown[]) => console.error(...args); console.log('═══════════════════════════════════════════════════'); console.log(' MyXstack - Autonomous AI Agent on X (Twitter)'); diff --git a/src/services/agent.ts b/src/services/agent.ts index de10ae7..b2b6841 100644 --- a/src/services/agent.ts +++ b/src/services/agent.ts @@ -102,7 +102,11 @@ export class AutonomousAgent { const excess = this.processedMentions.size - AutonomousAgent.MAX_PROCESSED_MENTIONS; const iter = this.processedMentions.values(); for (let i = 0; i < excess; i++) { - this.processedMentions.delete(iter.next().value as string); + const { value, done } = iter.next(); + if (done) { + break; + } + this.processedMentions.delete(value); } } } catch (error) { diff --git a/src/services/xapi.ts b/src/services/xapi.ts index ab6c4b5..ca139de 100644 --- a/src/services/xapi.ts +++ b/src/services/xapi.ts @@ -91,6 +91,11 @@ export class XAPIClient { return null; } + if (!Array.isArray(response.data)) { + console.warn('X API thread response data is not an array'); + return null; + } + return this.parseThread(response.data); } catch (error) { console.error('Error fetching thread:', error);