Build a Time Tracking App with GitHub Copilot SDK
Source: Dev.to
Source: Dev.to

The GitHub Copilot SDK lets you embed Copilot’s agentic workflows directly into your apps. It’s available for Python, TypeScript, Go, and .NET.
TimeTrack
TimeTrack is a desktop app built with the GitHub Copilot SDK (TypeScript) and Azure Cosmos DB.
Key features:
- ⏱️ Track time – start/stop timer, projects, and tags.
- 🗣️ Natural‑language queries – ask questions about your time data in plain English; Copilot generates and runs Cosmos DB SQL queries behind the scenes.
- 📊 Reports & charts – view visualizations across multiple users.
Demo: A video of the app in action is available in the original article.
Try It Yourself
The source code is on GitHub: https://github.com/abhirockzz/cosmosdb-copilot-sdk-time-tracker.
It works with Azure Cosmos DB or the vNext emulator. To get started:
git clone https://github.com/abhirockzz/cosmosdb-copilot-sdk-time-tracker.git
cd cosmosdb-copilot-sdk-time-tracker
npm install
npm startLocal Development (No Azure Account Required)
The Cosmos DB vNext emulator runs as a Docker container, allowing you to seed sample data and start querying immediately. See the emulator docs: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux.
Behind the Scenes
What makes this interesting is the SDK’s tool‑calling. You define a tool with defineTool (schema powered by Zod), and Copilot decides when to invoke it. Below is the core of the implementation:
const queryTool = defineTool("query_time_data", {
description: "Execute a read‑only Cosmos DB SQL query against time entries",
parameters: z.object({
query: z.string().describe("Cosmos DB SQL query"),
}),
handler: async ({ query }) => {
// `query` is scoped to the user's partition key
const result = await runQuery(userId, query);
return JSON.stringify(result);
},
});
session = await client.createSession({
tools: [queryTool],
systemMessage: { mode: "replace", content: "…" },
});When a user asks “what was my most productive day this week?”, the model:
- Generates a SQL query.
- Executes it against Cosmos DB (scoped to the user’s partition key).
- Returns a conversational answer.
If the generated SQL triggers a Cosmos DB error (e.g., an unsupported ORDER BY on an aggregate alias), the error is sent back to the model as a tool result. The model reads the error, adjusts the query, and retries. This usually succeeds within 1–2 attempts without any user intervention.
Overall Flow
+--------------+ +----------------+ +-------------+
| Electron UI | --> | Copilot SDK | --> | Copilot CLI |
| (renderer) | | (main process) | | (sidecar) |
+--------------+ +----------------+ +------+------+
^ |
| tool call:
| query_time_data
| |
| +------v------+
| | Cosmos DB |
| +------+------+
| |
| result or error
| |
| +------v------+
| | Model |
| | (interpret) |
| +------+------+
| | |
| success? SQL error?
| | |
| | retry with corrected SQL
| | |
+--- AI response <---------------+ (back to Cosmos DB)Because the AI writes arbitrary SQL rather than selecting from canned reports, the range of questions is wide. A few examples:
- Do I tend to work longer hours early in the week or late in the week?
- How does my Monday workload compare to Friday?
- Compare my total hours this week vs. last week.
- Rank my projects by total hours and show the percentage each represents.
- Summarize my last two weeks in three bullet points.

The app uses GPT‑4.1 by default, but you can switch to any supported Copilot model (e.g., gpt-5, claude-sonnet-4.5) by setting COPILOT_MODEL in .env.
If you want to go beyond Copilot’s model lineup, the app supports BYOK (Bring Your Own Key). Point it at your own Azure AI Foundry deployment—set the endpoint, API key, and deployment name in .env, and the SDK will use that model.
Overview
All AI calls are routed to your model. The tool‑calling, session management, and agent runtime remain unchanged. You control the model, billing, and identity layer; the SDK supplies the agentic infrastructure.
The app also includes experimental support for local OpenAI‑compatible servers (e.g., Ollama, Foundry Local). Results may vary depending on the model’s tool‑calling capabilities and your environment setup (GPU, etc.).
Try It Yourself
The full source code is available on GitHub:
https://github.com/abhirockzz/cosmosdb-copilot-sdk-time-tracker
You can run it with the Cosmos DB vNext emulator (no Azure account required):
- Linux emulator: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux
Steps
- Seed the sample data.
- Start asking questions in natural language.
Swap in your own model via BYOK if you want full control over the AI layer.
Copilot SDK
The Copilot SDK is open source and supports TypeScript, Python, Go, and .NET.
- Explore the documentation to discover what else you can build with it:
https://github.com/github/copilot-sdk/tree/main/docs
