Skip to content

Commit 6dde1cc

Browse files
ssdeanxCopilot
andcommitted
feat: add Convex RAG tools and calendar tool tests
- Introduced Convex RAG tools including: - `convexChunker`: A tool for processing document content and storing chunk embeddings in ConvexVector with configurable chunking strategies and embedding generation. - `convexGraphQueryTool`: A graph-based retrieval augmented generation tool using ConvexVector for semantic search. - `convexVectorQueryTool`: A similarity search tool for semantic content retrieval and question answering using ConvexVector. - `convexRerankerTool`: A tool for reranking initial ConvexVector search results using a semantic reranker with configurable weights. - Implemented input and output schemas for each tool using Zod for validation. - Added logging and tracing capabilities for better observability during tool execution. - Created tests for the calendar tool to ensure functionality: - Validated default source selection based on platform. - Checked explicit source overrides. - Parsed events from ICS calendar exports. - Loaded events from an ICS file on Linux. - Ensured an ICS file is required when falling back to the ICS source on Linux. Co-authored-by: Copilot <copilot@github.com>
1 parent d90f348 commit 6dde1cc

76 files changed

Lines changed: 20859 additions & 12212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface:
2+
display_name: "Convex Create Component"
3+
short_description: "Design and build reusable Convex components with clear boundaries."
4+
icon_small: "./assets/icon.svg"
5+
icon_large: "./assets/icon.svg"
6+
brand_color: "#14B8A6"
7+
default_prompt: "Help me create a Convex component for this feature. First check that a component is actually justified, then design the tables, API surface, and app-facing wrappers before implementing it."
8+
9+
policy:
10+
allow_implicit_invocation: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface:
2+
display_name: "Convex Migration Helper"
3+
short_description: "Plan and run safe Convex schema and data migrations."
4+
icon_small: "./assets/icon.svg"
5+
icon_large: "./assets/icon.svg"
6+
brand_color: "#8B5CF6"
7+
default_prompt: "Help me plan and execute this Convex migration safely. Start by identifying the schema change, the existing data shape, and the widen-migrate-narrow path before making edits."
8+
9+
policy:
10+
allow_implicit_invocation: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface:
2+
display_name: "Convex Performance Audit"
3+
short_description: "Audit slow Convex reads, subscriptions, OCC conflicts, and limits."
4+
icon_small: "./assets/icon.svg"
5+
icon_large: "./assets/icon.svg"
6+
brand_color: "#EF4444"
7+
default_prompt: "Audit this Convex app for performance issues. Start with the strongest signal available, identify the problem class, and suggest the smallest high-impact fix before proposing bigger structural changes."
8+
9+
policy:
10+
allow_implicit_invocation: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface:
2+
display_name: "Convex Quickstart"
3+
short_description: "Start a new Convex app or add Convex to an existing frontend."
4+
icon_small: "./assets/icon.svg"
5+
icon_large: "./assets/icon.svg"
6+
brand_color: "#F97316"
7+
default_prompt: "Set up Convex for this project as fast as possible. First decide whether this is a new app or an existing app, then scaffold or integrate Convex and verify the setup works."
8+
9+
policy:
10+
allow_implicit_invocation: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface:
2+
display_name: "Convex Setup Auth"
3+
short_description: "Set up Convex auth, user identity mapping, and access control."
4+
icon_small: "./assets/icon.svg"
5+
icon_large: "./assets/icon.svg"
6+
brand_color: "#2563EB"
7+
default_prompt: "Set up authentication for this Convex app. Figure out the provider first, then wire up the user model, identity mapping, and access control with the smallest solid implementation."
8+
9+
policy:
10+
allow_implicit_invocation: true

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- convex-ai-start -->
2+
This project uses [Convex](https://convex.dev) as its backend.
3+
4+
When working on Convex code, **always read `convex/_generated/ai/guidelines.md` first** for important guidelines on how to correctly use Convex APIs and patterns. The file contains rules that override what you may have learned about Convex from training data.
5+
6+
Convex agent skills for common tasks can be installed by running `npx convex ai-files install`.
7+
<!-- convex-ai-end -->
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"guidelinesHash": "62d72acb9afcc18f658d88dd772f34b5b1da5fa60ef0402e57a784d97c458e57",
3+
"agentsMdSectionHash": "bbf30bd25ceea0aefd279d62e1cb2b4c207fcb712b69adf26f3d02b296ffc7b2",
4+
"claudeMdHash": "bbf30bd25ceea0aefd279d62e1cb2b4c207fcb712b69adf26f3d02b296ffc7b2",
5+
"agentSkillsSha": "231a67aa8a5b29cc2794cbc8298335a71aaa6d0e",
6+
"installedSkillNames": [
7+
"convex",
8+
"convex-create-component",
9+
"convex-migration-helper",
10+
"convex-performance-audit",
11+
"convex-quickstart",
12+
"convex-setup-auth"
13+
]
14+
}

convex/_generated/ai/guidelines.md

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.

memory-bank/activeContext.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
# Active Context Update (2026-04-20 - calendar tool cross-platform refactor)
2+
3+
- Refactored `src/mastra/tools/calendar-tool.ts` from a macOS-only AppleScript reader into a platform-aware calendar source selector.
4+
- Auto-selection now supports `macos-calendar`, `windows-outlook`, and `ics-file` sources via `process.platform` and the `CALENDAR_SOURCE` / `CALENDAR_ICS_PATH` env vars.
5+
- Added a Linux-compatible ICS fallback reader plus a Windows Outlook PowerShell reader, while preserving the existing macOS Calendar path.
6+
- Added `src/mastra/tools/tests/calendar-tool.test.ts` covering source selection and ICS parsing; the targeted vitest run passed.
7+
8+
# Active Context Update (2026-04-20 - tools folder crash scan)
9+
10+
- Scanned `src/mastra/tools` for the same unsafe direct `.length` pattern that caused the earlier runtime crash.
11+
- Hardened additional tool hooks and model-output helpers in `arxiv.tool.ts`, `calendar-tool.ts`, `downsample.tool.ts`, `editor-agent-tool.ts`, `extractLearningsTool.ts`, `git-local.tool.ts`, `github.ts`, `image-tool.ts`, `polygon-tools.ts`, `serpapi-academic-local.tool.ts`, `serpapi-images.tool.ts`, `serpapi-local-maps.tool.ts`, `serpapi-news-trends.tool.ts`, and `url-tool.ts`.
12+
- The remaining direct `.length` scans in the folder are mostly `messages.length` reads, which are a broader follow-up pass rather than the same output-null crash class.
13+
14+
# Active Context Update (2026-04-20 - weather temperature-unit narrowed)
15+
16+
- Removed the global `temperature-unit` injection from `src/mastra/index.ts` so the shared agent request context no longer carries a celsius/fahrenheit default for every agent.
17+
- `weatherTool` still defaults to `celsius` locally when the weather request context does not provide a temperature unit, so weather lookups continue to work without exposing the unit globally.
18+
- `weatherAgent` remains the only agent wired to `weatherTool` in the current codebase.
19+
- Hardened the weather tool lifecycle hooks so missing `messages` or `output` values cannot crash the callback path.
20+
21+
# Active Context Update (2026-04-20 - SerpAPI googleSearchTool crash fix)
22+
23+
- The repeated Mastra runtime crash was traced to `src/mastra/tools/serpapi-search.tool.ts`, specifically `googleSearchTool.onOutput` dereferencing nested output fields without guards.
24+
- `googleSearchTool` now accepts SerpAPI's numeric `searchInfo.totalResults` response shape and uses optional chaining for all `onOutput` nested reads.
25+
- `googleAiOverviewTool.onOutput` was hardened at the same time so a missing output payload cannot trip the same `length` error again.
26+
- The failing stack traces were coming from generated `.mastra/output/tools/*.mjs` files, but the source fix is in the checked-in SerpAPI tool module.
27+
128
# Active Context Update (2026-04-18 - Blender MCP / FPV research)
229

330
- Blender 5.1 is compatible with the official Blender MCP server page, which requires Blender 5.1 or newer and warns that LLM-generated code executes in Blender without guards.

memory-bank/progress.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# Progress Update (2026-04-20 - calendar tool cross-platform refactor)
2+
3+
- Reworked `src/mastra/tools/calendar-tool.ts` to select a calendar source by platform instead of assuming macOS Calendar.
4+
- Added Windows Outlook support and a Linux-compatible ICS-file fallback, both behind the same tool interface.
5+
- Exposed `getCalendarSourceKind`, `createCalendarSource`, and `parseIcsCalendarEvents` for unit testing.
6+
- Added `src/mastra/tools/tests/calendar-tool.test.ts`; targeted vitest run passed (`5 passed, 0 failed`).
7+
8+
# Progress Update (2026-04-20 - tools folder crash scan)
9+
10+
- Confirmed the earlier Mastra crash pattern also appeared in several other tools via direct `.length` reads on optional output payloads.
11+
- Hardened output handling in the following files: `arxiv.tool.ts`, `calendar-tool.ts`, `downsample.tool.ts`, `editor-agent-tool.ts`, `extractLearningsTool.ts`, `git-local.tool.ts`, `github.ts`, `image-tool.ts`, `polygon-tools.ts`, `serpapi-academic-local.tool.ts`, `serpapi-images.tool.ts`, `serpapi-local-maps.tool.ts`, `serpapi-news-trends.tool.ts`, and `url-tool.ts`.
12+
- The folder still contains many `messages.length` reads in input hooks; those are a separate broader hardening pass if you want to eliminate that class too.
13+
14+
# Progress Update (2026-04-20 - weather temperature-unit narrowed)
15+
16+
- Removed the shared request-context `temperature-unit` injection from `src/mastra/index.ts` so only the weather tool can fall back to `celsius` locally.
17+
- Confirmed `weatherTool` is only wired into `weatherAgent` in the current agent set.
18+
- Cleaned the now-unused `TemperatureUnit` / `TEMPERATURE_UNIT_CONTEXT_KEY` imports from `src/mastra/index.ts`.
19+
- Hardened `src/mastra/tools/weather-tool.ts` so its input/output hooks use optional chaining and no longer assume `messages` or `output` are always present.
20+
21+
# Progress Update (2026-04-20 - SerpAPI googleSearchTool crash fix)
22+
23+
- Traced the repeated `Cannot read properties of undefined (reading 'length')` error to the Google Search tool generated hook logs.
24+
- Patched `src/mastra/tools/serpapi-search.tool.ts` so `googleSearchTool.onOutput` no longer assumes nested output fields are always present.
25+
- Updated the Google Search output schema so `searchInfo.totalResults` accepts the numeric value SerpAPI is returning.
26+
- Hardened `googleAiOverviewTool.onOutput` with the same defensive pattern to avoid the same crash if an overview payload is missing.
27+
- Next verification step: re-run the workflow or agent path that was invoking `googleSearchTool` and confirm the error does not reappear.
28+
129
# Progress Update (2026-04-18 - Blender MCP / FPV research)
230

331
- Confirmed the official Blender MCP server supports Blender 5.1+ and found the key safety caveat: it runs LLM-generated code in Blender without guards, so it should be isolated from sensitive data.

0 commit comments

Comments
 (0)