Each of the five specialist agents (stellar-oracle, analysis-agent, reporter-agent, web-intel-agent, computation-agent) has an identical startup sequence:
- Load env vars, validate required ones
- Load or generate a keypair from
wallets.json
- Call
POST ${REGISTRY_URL}/register with the agent manifest
- Start the HTTP server
- Log the agent address and listening port
This is duplicated in each agent's src/server.ts. Any change (e.g., adding a heartbeat after registration, adding the USDC balance warning from issue #19) requires touching five files.
Extract this into a shared registerAgent helper in packages/common/src/agent-startup.ts:
export interface AgentStartupOptions {
manifest: AgentManifest;
walletKey: string; // key in wallets.json, e.g. "stellar_oracle"
onReady?: (keypair: Keypair) => void;
}
export async function registerAgent(opts: AgentStartupOptions): Promise<void>;
The helper handles keypair loading, registration POST with retry (3 attempts), heartbeat setup, and startup log lines. Each agent's server.ts is reduced to defining its manifest and calling registerAgent.
This change should not alter any external behavior.
Acceptance criteria
Relevant files
packages/common/src/ (new file)
packages/stellar-oracle/src/server.ts
packages/analysis-agent/src/server.ts
- Other agent server files (for reference)
packages/common/src/types.ts
Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.
Each of the five specialist agents (stellar-oracle, analysis-agent, reporter-agent, web-intel-agent, computation-agent) has an identical startup sequence:
wallets.jsonPOST ${REGISTRY_URL}/registerwith the agent manifestThis is duplicated in each agent's
src/server.ts. Any change (e.g., adding a heartbeat after registration, adding the USDC balance warning from issue #19) requires touching five files.Extract this into a shared
registerAgenthelper inpackages/common/src/agent-startup.ts:The helper handles keypair loading, registration POST with retry (3 attempts), heartbeat setup, and startup log lines. Each agent's server.ts is reduced to defining its manifest and calling
registerAgent.This change should not alter any external behavior.
Acceptance criteria
packages/common/src/agent-startup.tsexports aregisterAgentfunctionregisterAgent(the remaining three can follow as separate PRs)npm run typecheckandnpm run lintpass for all packagesRelevant files
packages/common/src/(new file)packages/stellar-oracle/src/server.tspackages/analysis-agent/src/server.tspackages/common/src/types.tsNotes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.