Skip to content

Commit ab10289

Browse files
Merge pull request #27 from groupthinking/copilot/sub-pr-26
Address code review feedback: strengthen type guards and remove unsafe assertions
2 parents 2407087 + 104e4a4 commit ab10289

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { XMCPServer } from './mcp/server.js';
1010
async function main() {
1111
// Redirect console.log to stderr so it doesn't conflict with
1212
// MCP StdioServerTransport which uses stdout for protocol messages
13-
console.log = (...args: any[]) => console.error(...args);
13+
console.log = (...args: unknown[]) => console.error(...args);
1414

1515
console.log('═══════════════════════════════════════════════════');
1616
console.log(' MyXstack - Autonomous AI Agent on X (Twitter)');

src/services/agent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ export class AutonomousAgent {
102102
const excess = this.processedMentions.size - AutonomousAgent.MAX_PROCESSED_MENTIONS;
103103
const iter = this.processedMentions.values();
104104
for (let i = 0; i < excess; i++) {
105-
this.processedMentions.delete(iter.next().value as string);
105+
const { value, done } = iter.next();
106+
if (done) {
107+
break;
108+
}
109+
this.processedMentions.delete(value);
106110
}
107111
}
108112
} catch (error) {

src/services/xapi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ export class XAPIClient {
9191
return null;
9292
}
9393

94+
if (!Array.isArray(response.data)) {
95+
console.warn('X API thread response data is not an array');
96+
return null;
97+
}
98+
9499
return this.parseThread(response.data);
95100
} catch (error) {
96101
console.error('Error fetching thread:', error);

0 commit comments

Comments
 (0)