Files
elizaos--eliza/packages/feed/scripts/debug-agent-data.ts
T
wehub-resource-sync 426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

208 lines
6.0 KiB
TypeScript

#!/usr/bin/env bun
/**
* Debug script to check agent data and trade records
*/
import { db } from "@feed/db";
import { agentTrades, perpPositions, users } from "@feed/db/schema";
import { getTimeAgo } from "@feed/shared";
import { desc, eq, sql } from "drizzle-orm";
async function debugAgentData() {
console.log("🔍 Debugging agent data...\n");
try {
// Check if there are ANY trades in AgentTrade table
const totalTrades = await db
.select({ count: sql<number>`count(*)::int` })
.from(agentTrades);
console.log(
`📊 Total trades in AgentTrade table: ${totalTrades[0].count}\n`,
);
if (totalTrades[0].count > 0) {
// Show sample trades
const sampleTrades = await db
.select()
.from(agentTrades)
.orderBy(desc(agentTrades.executedAt))
.limit(5);
console.log("Sample trades:");
sampleTrades.forEach((trade, idx) => {
console.log(
`${idx + 1}. Agent: ${trade.agentUserId} | Action: ${trade.action} | Ticker: ${trade.ticker} | Time: ${trade.executedAt}`,
);
});
console.log("");
}
// Check users with isAgent=true
const agentUsers = await db
.select({
id: users.id,
username: users.username,
displayName: users.displayName,
isAgent: users.isAgent,
managedBy: users.managedBy,
autonomousTrading: users.autonomousTrading,
agentStatus: users.agentStatus,
agentCount: users.agentCount,
createdAt: users.createdAt,
})
.from(users)
.where(eq(users.isAgent, true))
.limit(20);
console.log(`👤 Users with isAgent=true: ${agentUsers.length}\n`);
if (agentUsers.length > 0) {
console.log("Agent users:");
agentUsers.forEach((user, idx) => {
console.log(
`${idx + 1}. ${user.username || user.displayName || user.id} | ` +
`Status: ${user.agentStatus} | ` +
`Autonomous Trading: ${user.autonomousTrading} | ` +
`Created: ${user.createdAt.toISOString()}`,
);
});
console.log("");
// Check if these agents have any trades (using IN clause instead of ANY)
const agentIds = agentUsers.map((u) => u.id);
const tradesForAgents = await db
.select({
agentUserId: agentTrades.agentUserId,
count: sql<number>`count(*)::int`,
})
.from(agentTrades)
.where(
sql`${agentTrades.agentUserId} IN (${sql.join(
agentIds.map((id) => sql`${id}`),
sql`, `,
)})`,
)
.groupBy(agentTrades.agentUserId);
console.log("Trades by agent users:");
if (tradesForAgents.length === 0) {
console.log(" None found\n");
} else {
tradesForAgents.forEach((stat) => {
const agent = agentUsers.find((u) => u.id === stat.agentUserId);
console.log(
` ${agent?.username || stat.agentUserId}: ${stat.count} trades`,
);
});
console.log("");
}
}
// Check if there are users with autonomousTrading enabled
const autonomousUsers = await db
.select({
id: users.id,
username: users.username,
displayName: users.displayName,
isAgent: users.isAgent,
autonomousTrading: users.autonomousTrading,
agentStatus: users.agentStatus,
})
.from(users)
.where(eq(users.autonomousTrading, true))
.limit(20);
console.log(
`🤖 Users with autonomousTrading=true: ${autonomousUsers.length}\n`,
);
if (autonomousUsers.length > 0) {
console.log("Users with autonomous trading enabled:");
autonomousUsers.forEach((user, idx) => {
console.log(
`${idx + 1}. ${user.username || user.displayName || user.id} | ` +
`isAgent: ${user.isAgent} | ` +
`Status: ${user.agentStatus}`,
);
});
console.log("");
}
// Check PerpPositions for any recent trading activity
const recentPositions = await db
.select({
userId: perpPositions.userId,
ticker: perpPositions.ticker,
side: perpPositions.side,
size: perpPositions.size,
openedAt: perpPositions.openedAt,
closedAt: perpPositions.closedAt,
})
.from(perpPositions)
.orderBy(desc(perpPositions.openedAt))
.limit(10);
console.log(
`📈 Recent perp positions (last 10): ${recentPositions.length}\n`,
);
if (recentPositions.length > 0) {
console.log("Recent positions:");
recentPositions.forEach((pos, idx) => {
const status = pos.closedAt ? "CLOSED" : "OPEN";
const timeAgo = getTimeAgo(pos.openedAt);
console.log(
`${idx + 1}. User: ${pos.userId.slice(0, 8)}... | ` +
`${pos.ticker} ${pos.side} | ` +
`Size: ${pos.size} | ` +
`Status: ${status} | ` +
`Opened: ${timeAgo}`,
);
});
console.log("");
// Check if these users are agents (using IN clause instead of ANY)
const userIds = [...new Set(recentPositions.map((p) => p.userId))];
const usersData = await db
.select({
id: users.id,
username: users.username,
isAgent: users.isAgent,
autonomousTrading: users.autonomousTrading,
})
.from(users)
.where(
sql`${users.id} IN (${sql.join(
userIds.map((id) => sql`${id}`),
sql`, `,
)})`,
);
console.log("Are these users agents?");
usersData.forEach((user) => {
console.log(
` ${user.username || user.id.slice(0, 8)}: ` +
`isAgent=${user.isAgent}, autonomousTrading=${user.autonomousTrading}`,
);
});
console.log("");
}
} catch (error) {
console.error("Error debugging:", error);
throw error;
}
}
// Run the debug check
debugAgentData()
.then(() => {
console.log("✅ Debug complete");
process.exit(0);
})
.catch((error) => {
console.error("❌ Debug failed:", error);
process.exit(1);
});