Commit graph

532 commits

Author SHA1 Message Date
Ajax Davis
d364bea497 fix: add id-token permission to update-docs workflow 2026-01-14 04:30:43 +10:00
Ajax Davis
232980e5bc fix: remove duplicate role=menu from dropdown container 2026-01-14 04:28:59 +10:00
Ajax Davis
fefc316038 fix: wrap useSearchParams in Suspense boundary for profile page 2026-01-14 04:25:02 +10:00
Ajax Davis
77e697db56 fix: make username compulsory and improve MCP error messages
- Add profile settings page for username management
- Add username prompt in dashboard when not set
- Improve MCP endpoint to show specific error for missing user vs collection
- Make sign-up flow retry username PATCH and redirect to setup if fails
- Add backfill script for existing users without usernames
- Add Profile link to dashboard sidebar
2026-01-14 04:21:41 +10:00
Ajax Davis
0e6be48fdc fix: update tools-search and user-usage test response structures
- Fix tools-search to use results.tools instead of data
- Fix user-usage to use apiKeyClient instead of session auth
2026-01-14 03:10:34 +10:00
Ajax Davis
5aad08a3b8 fix: skip tests requiring unavailable secrets and fix stats test
- Skip conversation tests until API_KEY_ENCRYPTION_SECRET is in GitHub secrets
- Remove stats/history and stats/categories tests (endpoints don't exist)
- Add categories check to main stats test
- Skip keyword sync test (takes 2-3 minutes, times out)
2026-01-14 03:02:11 +10:00
Ajax Davis
907ac2301b fix: fix remaining integration test issues
- Fix user-profile tests to use apiKeyClient instead of session auth
- Fix stats test for new nested response structure (data.overview.*)
- Enable conversation tests with CI OpenAI key setup
- Add setup-openai-key.ts script to configure test user's OPENAI_API_KEY
- Update workflow to run OpenAI key setup before tests
2026-01-14 02:51:57 +10:00
Ajax Davis
a8a52c972c fix: update integration tests for correct API routes and skip AI tests
- Fix public agents route: use /api/public/users/:username/agents/:uid
- Fix public collections route: use /api/public/users/:username/collections/:slug
- Remove isPublic check (not returned in response, implied by endpoint)
- Skip agent conversation tests that require AI provider API keys
2026-01-14 02:41:29 +10:00
Ajax Davis
0f37e64783 fix: update integration tests for correct API response fields
- Fix MCP HTTP test to check for protocol/transport instead of protocolVersion
- Skip TPMJS API keys tests that require session auth (security requirement)
2026-01-14 02:30:46 +10:00
Ajax Davis
83e2cededa fix: use package.json script for cleanup-orphans command
Added test:cleanup-orphans script to package.json and updated
workflow to use it, fixing "None of the selected packages has a tsx script" error.
2026-01-14 02:18:16 +10:00
Ajax Davis
8219f0dde5 ci: add pre-test cleanup step to prevent hitting resource limits
Run cleanup-orphans.ts before tests to clear any leftover test data
that might cause tests to fail due to hitting the maximum agent/collection limits.
2026-01-14 02:10:03 +10:00
Ajax Davis
0fc39da6c9 fix: add unique names and fix isPublic check in integration tests
- MCP HTTP test: use unique collection name
- Public collections test: use unique collection name
- Remove isPublic assertion since public API doesn't return that field
2026-01-14 02:01:46 +10:00
Ajax Davis
56c4df74b7 fix: use unique names in integration tests to avoid collision
- Add timestamps to test agent/collection names to make them unique
- Fix duplicate UID test to verify auto-suffix behavior instead of rejection
- Use agent id instead of uid for cleanup tracking
2026-01-14 01:52:41 +10:00
Ajax Davis
6880e78f75 fix: update integration tests to use API key auth instead of session auth
Since our manually-created session tokens don't work with better-auth's
session validation, these tests now use API key authentication which
works correctly with the authenticateRequest() middleware.
2026-01-14 01:42:28 +10:00
Ajax Davis
d524d2ca16 fix: use API key auth for test factories
Session auth requires valid better-auth sessions which can't be
created programmatically. Switch factories to use API key auth
which is properly supported.
2026-01-14 01:32:06 +10:00
Ajax Davis
b6d507fcf5 feat: add API key authentication to user and resource endpoints
Update multiple endpoints to use authenticateRequest() middleware
instead of session-only authentication. This allows integration tests
to authenticate using API keys.

Endpoints updated:
- /api/user/profile
- /api/user/likes/tools, collections, agents
- /api/agents (list, create)
- /api/agents/[id] (get, update, delete)
- /api/collections (list, create)
- /api/collections/[id] (get, update, delete)
2026-01-14 01:21:58 +10:00
Ajax Davis
72ff35b333 fix: use __Secure- cookie prefix for HTTPS session auth 2026-01-14 00:59:38 +10:00
Ajax Davis
a39b68e866 feat: add comprehensive integration tests for GitHub Actions
- Add Vitest integration test config with sequential execution
- Create test helpers (auth, cleanup, SSE parser, API client)
- Create test data factories for agents and collections
- Add test context manager for unified test setup
- Create integration tests for:
  - Health and stats endpoints
  - Tools list and search
  - Collections CRUD
  - Agents CRUD and conversations
  - MCP HTTP transport
  - User profile, API keys, and usage
  - Public agents and collections
  - Sync endpoints (cron-authenticated)
- Add GitHub Actions workflow running on push to main
- Add cleanup-orphans script for test data cleanup
- Add setup-test-credentials script for generating auth tokens
2026-01-14 00:50:55 +10:00
Ajax Davis
2fb790a847 docs: update all URL references to new username/slug format
Update all documentation, code, and tests to use the new endpoint formats:

- MCP: /api/mcp/{username}/{collection-slug}/{transport}
- Agent: /api/{username}/agents/{agent-uid}/conversation/{id}

Changes include:
- Update MCP URLs in collections page, docs, and test script
- Update agent API URLs in chat page, docs, tests, and cron job
- Add API key authentication requirements to all examples
- Update ARCHITECTURE.md with correct endpoint formats
- Update discord cron job to fetch owner username for new URL format
2026-01-13 23:14:36 +10:00
Ajax Davis
2b4526ba95 fix: support collection ID in MCP URL path (not just slug) 2026-01-13 22:41:41 +10:00
Ajax Davis
3fe93b58d7 fix: use correct agent uid tpmjs-discord in workflow 2026-01-13 11:53:04 +10:00
Ajax Davis
efb30f7874 feat: add username/slug based agent API endpoints
- Add /api/[username]/agents/[agentSlug]/conversation/[conversationId]
- Add /api/[username]/agents/[agentSlug]/conversations
- Update agent dashboard API docs to use new URL format
- Include user.username in agent API response
- Update Discord summary workflow to use new endpoint format
2026-01-13 11:45:03 +10:00
Ajax Davis
cd5eaeaf59 feat: add username/slug based agent API endpoints
- Add /api/[username]/agents/[agentSlug]/conversation/[conversationId]
- Add /api/[username]/agents/[agentSlug]/conversations
- Update agent dashboard API docs to use new URL format
- Include user.username in agent API response
2026-01-13 11:39:45 +10:00
Ajax Davis
74a9de290e fix: support agent UID lookup in conversation endpoint 2026-01-13 11:31:13 +10:00
Ajax Davis
6c781c0711 fix: use correct MCP URL format /api/mcp/[username]/[slug]/[transport] 2026-01-13 11:14:54 +10:00
Ajax Davis
390194265b fix: add API key docs to collection MCP URLs section 2026-01-13 11:04:32 +10:00
Ajax Davis
bf97513a59 fix: add Authorization header to agent API docs examples 2026-01-13 10:48:04 +10:00
Ajax Davis
95cb0a96f0 feat: add fork-based ownership and fix MCP non-scoped package names
Fork-based ownership:
- Add forkedFromId, forkCount fields to Collection and Agent models
- Add fork-status API endpoints for collections and agents
- Add ForkButton and ForkedFromBadge UI components
- Update clone endpoints to set forkedFromId and increment forkCount
- Add COLLECTION_FORKED and AGENT_FORKED activity types
- Enforce owner-only access for MCP tool execution and agent chat

MCP fix:
- Fix parseToolName to handle non-scoped packages like firecrawl-aisdk
- Try both scoped (@scope/name) and literal (name-with-hyphens) interpretations
- Pass collection envVars to tool executor for API key support
2026-01-13 10:23:28 +10:00
Ajax Davis
e2bb06df60 fix: aggregate hourly usage data into daily/monthly views for dashboard 2026-01-13 06:00:13 +10:00
Ajax Davis
790a338f4d fix: add API key auth to Discord summary GitHub Action 2026-01-13 05:31:37 +10:00
Ajax Davis
a3f1f3935e feat: add API key authentication system and update documentation
API Key System:
- Add TpmjsApiKey, ApiUsageRecord, ApiUsageSummary models to schema
- Create API key utilities (generate, hash, mask with tpmjs_sk_ prefix)
- Implement dual auth middleware (session + API key)
- Add rate limiting with Vercel KV
- Create CRUD endpoints for API key management
- Add usage tracking and analytics endpoint
- Build API key management UI in dashboard
- Build usage dashboard with charts

Route Protection:
- Require auth for MCP endpoints (mcp:execute scope)
- Require auth for agent chat (agent:chat scope)
- Require auth for bridge connections (bridge:connect scope)

Documentation Updates:
- Update all curl/fetch examples with Authorization header
- Document API key format, scopes, and rate limits
- Update PRD-MCP-BRIDGE.md, MCP-AGGREGATOR-DESIGN.md
- Update API docs page with auth requirements
- Update HOW_TO_PUBLISH_A_TOOL.md
2026-01-13 04:45:52 +10:00
Ajax Davis
b663ca3e05 feat: enhance bridge diagram with animations, gradients, and visual polish
- Add gradient fills for machine, bridge, and cloud sections
- Add glow effect on bridge component
- Add drop shadows for depth
- Add animated arrows that draw on load with stagger
- Add pulse animation on connection status indicator
- Add animated data flow dots between bridge and cloud
- Add hover effects on MCP server boxes
- Add traffic light dots and icons for visual appeal
- Improve typography and spacing
2026-01-13 02:25:41 +10:00
Ajax Davis
b4be05e004 feat: replace ASCII diagram with D3.js visualization in bridge tutorial 2026-01-13 01:54:12 +10:00
Ajax Davis
c8c1a12f22 feat: complete MCP Bridge implementation
- Add @tpmjs/mcp-client package for connecting to MCP servers
- Add @tpmjs/bridge CLI for bridging local MCP servers to TPMJS
- Add @tpmjs/test-file-writer test MCP server
- Add BridgeConnection and CollectionBridgeTool database models
- Add /api/bridge endpoints for bridge communication
- Add /api/collections/[id]/bridge-tools API for managing bridge tools
- Update MCP handlers to include bridge tools in tools/list
- Add bridge status UI at /dashboard/settings/bridge
- Add interactive bridge tutorial at /docs/tutorials/bridge
2026-01-13 00:59:34 +10:00
Ajax Davis
490d76a50b feat: add reusable EnvVarsEditor component with paste .env feature
- Create EnvVarsEditor component for editing key-value env vars
- Add paste .env snippet feature with preview of parsed variables
- Refactor agent and collection pages to use the new component
- Extract shared parseEnvString utility for consistent .env parsing
- Update API keys settings page to use shared parser

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 05:04:03 +10:00
Ajax Davis
b87d5f627c fix: hardcode Discord agent ID in GitHub Action
No need to use a secret for the agent ID since it's a public identifier.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 04:39:03 +10:00
Ajax Davis
c8abfb8968 feat: add GitHub Action for daily Discord summary
- Runs daily at 9 AM UTC via cron
- Can be triggered manually via workflow_dispatch
- Uses date-based conversation ID (discord-summary-YYYY-MM-DD)
- Triggers the Discord agent to read and summarize the past 24 hours

Requires DISCORD_AGENT_ID secret to be set in GitHub repo settings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 04:35:33 +10:00
Ajax Davis
41cbeefabb fix: increase tool execution timeout to 5 minutes
Tools like discord-read that fetch data from external APIs need more time.
Previous 10-30 second timeout was causing silent failures.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 04:16:15 +10:00
Ajax Davis
8bbde047b5 fix: improve error visibility for agent tool execution
- Add structured logging for tool calls, results, and errors
- Log tool call initiation with input parameters
- Distinguish between success and error tool results
- Include isError flag in SSE tool_result events
- Improve error logging with stack traces and context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 03:08:57 +10:00
Ajax Davis
938a382aab feat: add environment variables support for agents and collections
- Add envVars field to Agent and Collection models in Prisma schema
- Add envVars to UpdateAgentSchema and UpdateCollectionSchema types
- Implement env vars merging logic (agent overrides collection)
- Pass env vars through tool executor to sandbox
- Add UI for managing env vars in agent and collection settings pages
- Update API routes to handle envVars PATCH updates
- Refactor discord tool execute functions for biome compatibility

This allows users to configure tool-specific environment variables (like
DISCORD_BOT_TOKEN) at both the collection and agent level, with agent
settings taking precedence over collection settings.
2026-01-12 01:35:29 +10:00
Ajax Davis
079c328bfc fix: remove random color highlighting and improve contrast on architecture page
- Remove accent variant from Cell component, simplify to muted boolean
- Remove primary variant from ArchBox component
- Replace all text-primary with text-foreground for consistency
- Remove blue-tinted borders from sections
- Update all cells to use consistent styling

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 04:06:40 +10:00
Ajax Davis
74c7e63b9f refactor: update architecture page to use TPMJS design system
Replaced custom lime/zinc colors with proper theme variables:
- bg-background, bg-surface, bg-surface-secondary
- text-foreground, text-foreground-secondary, text-foreground-tertiary
- border-border, border-primary
- Uses Badge component from @tpmjs/ui
- Uses Container component for layout
- Maintains the nested box layout style

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 03:09:23 +10:00
Ajax Davis
0012eba137 feat: add architecture documentation page with chip-style diagrams
Create visual architecture documentation at /docs/architecture with:
- Platform overview showing user products, API layer, infrastructure
- Tool execution pipeline flow diagram
- Executor system comparison (default vs custom)
- Collections and Agents data model
- Tool discovery and sync pipeline
- Database entity relationships

Uses NVIDIA-inspired chip diagram aesthetic with nested boxes,
grid layouts, and lime/yellow accent colors on dark background.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 02:51:05 +10:00
Ajax Davis
536b727fc6 fix: use full inputSchema for tool definitions instead of flattened parameters
The issue was that tools with complex nested parameters (like arrays of objects)
were losing their structure when converted to Zod schemas. The LLM would then
pass stringified JSON instead of actual arrays.

- Import jsonSchema from AI SDK
- Check if tool.inputSchema exists (full JSON Schema from executor)
- Use jsonSchema() wrapper to preserve nested array/object structures
- Fall back to legacy tpmjsParamsToZodSchema only if inputSchema is missing

This fixes the changelog tool and similar tools with complex parameter types.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 02:34:37 +10:00
Ajax Davis
5c0b9c5ae9 fix: show tool outputs in embedded tool calls and improve light mode styling
- Build toolCallId -> output map from TOOL messages
- Pass outputs to embedded tool calls in ASSISTANT messages
- Skip rendering separate TOOL messages (now shown with their calls)
- Improve light mode contrast for tool cards:
  - Use slate-50 background instead of gray
  - Better status badge colors (green-700, blue-700 in light mode)
  - Better error colors (red-600 in light mode)
  - Better output text colors (emerald-700, red-600 in light mode)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 02:16:56 +10:00
Ajax Davis
49af625254 fix: render embedded tool calls from ASSISTANT messages on page refresh
Previously, tool calls only rendered during streaming. Now they also
render when loading conversation history from the database, where
tool calls are embedded in ASSISTANT messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 02:08:33 +10:00
Ajax Davis
d95a7119c7 feat: add tool error rendering and JSON logs button in agent chat
- Add error detection for tool call outputs (success=false, error field)
- Display ERROR badge and red styling for failed tool calls
- Show error message preview in tool call header
- Add "JSON" button to view full conversation history as raw JSON
- Support format=json parameter in conversation API endpoint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 02:01:34 +10:00
Ajax Davis
6661957111 fix: correct test package/tool name in executor verification
- Use @tpmjs/hello instead of @anthropic-ai/tpmjs-hello
- Use helloWorldTool instead of helloWorld (correct export name)
- Increase timeout to 30s to account for npm install in sandbox
- Add detailed logging to Vercel executor template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 01:36:26 +10:00
Ajax Davis
d646e2310e feat: add API Reference and Custom Executors to developer menu
- Add /docs/api (API Reference - REST & MCP endpoints) to nav
- Add /docs/executors (Custom Executors - Deploy your own) to nav
- Updated both desktop dropdown and mobile menu
- Fix lint error in MobileMenu backdrop

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 01:08:36 +10:00
Ajax Davis
55ec58065e feat: add API getting started documentation page
- Comprehensive REST API and MCP protocol documentation
- Interactive examples with cURL commands
- Covers tools, search, collections, agents, and stats endpoints
- MCP protocol with initialize, tools/list, and tools/call examples
- Response format, error handling, and pagination docs
2026-01-11 00:49:15 +10:00