Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "vitest run"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.39.0",
"@mariozechner/pi-agent-core": "^0.66.1",
"@mariozechner/pi-ai": "^0.66.1",
"@sinclair/typebox": "^0.34.49",
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export async function chat(

// Execute each tool_use block
const toolUseBlocks = response.content.filter(
(b): b is Anthropic.ContentBlockParam & { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> } =>
(b: Anthropic.ContentBlock): b is Anthropic.ContentBlock & { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> } =>
b.type === 'tool_use'
)

Expand Down Expand Up @@ -321,7 +321,7 @@ export async function* chatStream(

// Tool loop — extract tool_use blocks, execute, and continue
const toolUseBlocks = finalMsg.content.filter(
(b): b is Anthropic.ContentBlockParam & { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> } =>
(b: Anthropic.ContentBlock): b is Anthropic.ContentBlock & { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> } =>
b.type === 'tool_use'
)

Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/coordination/activity-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function attachLogger(bus: EventBus): void {
type: event.type.split(':')[1] ?? event.type,
title: formatTitle(event),
detail: JSON.stringify(event.data),
wallet: event.wallet ?? null,
wallet: event.wallet ?? undefined,
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ export function getPaymentLinkStats(): PaymentLinkStatsResult {
for (const row of rows) {
stats.total += row.count
if (row.status in stats) {
(stats as Record<string, number>)[row.status] = row.count
(stats as unknown as Record<string, number>)[row.status] = row.count
}
}
return stats
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/like-tweet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const likeTweetTool: Tool = {
},
},
required: ['tweet_id'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeLikeTweet(params: LikeTweetParams): Promise<LikeTweetResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/post-tweet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const postTweetTool: Tool = {
},
},
required: ['text'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/read-dms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const readDMsTool: Tool = {
},
},
required: [],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeReadDMs(params: ReadDMsParams = {}): Promise<ReadDMsResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/read-mentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const readMentionsTool: Tool = {
},
},
required: [],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeReadMentions(params: ReadMentionsParams = {}): Promise<ReadMentionsResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/read-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const readUserProfileTool: Tool = {
},
},
required: ['username'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeReadUserProfile(params: ReadUserProfileParams): Promise<ReadUserProfileResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/reply-tweet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const replyTweetTool: Tool = {
},
},
required: ['tweet_id', 'text'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeReplyTweet(params: ReplyTweetParams): Promise<ReplyTweetResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/schedule-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const schedulePostTool: Tool = {
},
},
required: ['text', 'scheduled_at'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeSchedulePost(params: SchedulePostParams): Promise<SchedulePostResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/search-posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const searchPostsTool: Tool = {
},
},
required: ['query'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeSearchPosts(params: SearchPostsParams): Promise<SearchPostsResult> {
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/herald/tools/send-dm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const sendDMTool: Tool = {
},
},
required: ['user_id', 'text'],
} as Tool['parameters'],
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON Schema ↔ TypeBox TSchema bridge
} as any,
}

export async function executeSendDM(params: SendDMParams): Promise<SendDMResult> {
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ app.post('/api/chat/stream', verifyJwt, async (req, res) => {
const BLOCKED_TOOLS = new Set(['send', 'deposit', 'refund', 'sweep', 'consolidate', 'swap', 'splitSend', 'scheduleSend', 'drip', 'recurring'])

app.post('/api/tools/:name', verifyJwt, async (req, res) => {
const { name } = req.params
const name = req.params.name as string

if (BLOCKED_TOOLS.has(name)) {
res.status(403).json({ success: false, error: `tool '${name}' requires confirmation flow — use /api/command instead` })
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/src/pi/tool-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type { Tool } from '@mariozechner/pi-ai'

export interface AnthropicTool {
name: string
description: string
description?: string
input_schema: Record<string, unknown>
}

export function adaptTool(anthropicTool: AnthropicTool): Tool {
return {
name: anthropicTool.name,
description: anthropicTool.description,
description: anthropicTool.description ?? '',
parameters: anthropicTool.input_schema as any, // Both use JSON Schema format
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/routes/confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const confirmRouter = Router()
* Body: { action: 'confirm' | 'cancel' }
*/
confirmRouter.post('/:id', (req: Request, res: Response) => {
const { id } = req.params
const id = req.params.id as string
const { action } = req.body as { action?: 'confirm' | 'cancel' }

const entry = pending.get(id)
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/routes/herald-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ heraldRouter.get('/', (_req: Request, res: Response) => {

// POST /api/herald/approve/:id — approve, reject, or edit a queued post
heraldRouter.post('/approve/:id', (req: Request, res: Response) => {
const { id } = req.params
const id = req.params.id as string
const { action, content } = req.body as { action?: string; content?: string }

const post = getDb()
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/sentinel/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export async function scanWallet(
let rpcCalls = 0

// Build connection — local only, no RPC call consumed
const network = (process.env.SOLANA_NETWORK ?? 'mainnet-beta') as 'devnet' | 'mainnet-beta' | 'testnet'
const envNetwork = process.env.SOLANA_NETWORK ?? 'mainnet-beta'
const network = (envNetwork === 'devnet' ? 'devnet' : 'mainnet-beta') as 'devnet' | 'mainnet-beta'
const connection = createConnection(network)

// ── Step 1: Vault balance ──────────────────────────────────────────────────
Expand Down
Loading
Loading