### Start Development Server with Package Managers Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/getting-started.md This snippet demonstrates how to start the development server using different package managers: bun, pnpm, yarn, and npm. After installation, these commands are used to run the application locally for development purposes. ```bash bun run dev ``` ```bash pnpm dev ``` ```bash yarn dev ``` ```bash npm run dev ``` -------------------------------- ### Copy Environment Example File (Bash) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/getting-started.md Copies the example environment file to a new file, serving as a template for configuring project-specific environment variables. This is a common first step in setting up a new project. ```bash cp apps/app/.env.example apps/app/.env ``` -------------------------------- ### Quick Start: Create Savoir instance and generate text with tools Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md A quick start example showing how to initialize the Savoir SDK with API credentials and then use it with the AI SDK's generateText function. It demonstrates passing Savoir's tools to the AI model for querying content. ```typescript import { createSavoir } from '@savoir/sdk' import { generateText } from 'ai' const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY, }) const { text } = await generateText({ model: 'google/gemini-3-flash', tools: savoir.tools, maxSteps: 10, prompt: 'How do I configure authentication?', }) console.log(text) ``` -------------------------------- ### Self-hosting Knowledge Agent Template (Bash) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/README.md Provides bash commands to clone the repository, install dependencies using bun, configure environment variables by copying an example file, and start the development server. It highlights the need to edit the `.env` file with specific configurations. ```bash # Clone the repository git clone https://github.com/vercel-labs/knowledge-agent-template.git cd knowledge-agent-template # Install dependencies bun install # Configure environment variables cp apps/app/.env.example apps/app/.env # Edit .env with your configuration # Start the app bun run dev ``` -------------------------------- ### Install Dependencies with Package Managers Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/getting-started.md This snippet shows how to install project dependencies using various package managers: bun, pnpm, yarn, and npm. These commands are essential for setting up the project environment before running the application. ```bash bun install ``` ```bash pnpm install ``` ```bash yarn install ``` ```bash npm install ``` -------------------------------- ### Full example: Ask question and report usage Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md A comprehensive example demonstrating how to initialize the Savoir SDK, generate text using an AI model with Savoir tools, and report usage analytics. This showcases a complete interaction flow. ```typescript import { generateText } from 'ai' import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY!, source: 'my-app', }) async function ask(question: string) { const startTime = Date.now() const result = await generateText({ model: yourModel, tools: savoir.tools, maxSteps: 10, prompt: question, }) await savoir.reportUsage(result, { startTime }) return result.text } ``` -------------------------------- ### Install @savoir/sdk using npm, bun, or pnpm Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Demonstrates how to install the @savoir/sdk package using different package managers like npm, bun, and pnpm. This is the first step to integrating the SDK into your project. ```bash npm install @savoir/sdk # or bun add @savoir/sdk # or pnpm add @savoir/sdk ``` -------------------------------- ### Development Commands for Knowledge Agent Template Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/README.md Provides essential commands for developing the Knowledge Agent Template project. These include installing dependencies, starting the development server, building packages, running tests, and linting the code. ```bash bun install bun run dev bun run build bun run test bun run lint:fix ``` -------------------------------- ### Install @savoir/sdk using package managers Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md Installs the @savoir/sdk package using different package managers like bun, pnpm, yarn, and npm. This is the first step to using the SDK in your project. ```bash bun add @savoir/sdk ``` ```bash pnpm add @savoir/sdk ``` ```bash yarn add @savoir/sdk ``` ```bash npm install @savoir/sdk ``` -------------------------------- ### GitHub Bot Mention Trigger Example Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/bot-setup.md This example shows how to trigger the GitHub bot by mentioning it in an issue comment. The bot will then process the request and reply. ```markdown @your-bot-name How do I configure SSO? ``` -------------------------------- ### List Content Sources via API Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt This GET request retrieves a list of all configured content sources, categorized by type (e.g., GitHub repositories, YouTube channels). It includes synchronization status and details about each source, such as repository name, branch, and content paths. ```bash curl -X GET https://your-app.com/api/sources \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Initialize SavoirClient for direct API access Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Provides an example of initializing the `SavoirClient` for direct, low-level HTTP access to the API. This is an alternative to the higher-level `createSavoir` function and is useful for specific API interactions. ```typescript import { SavoirClient } from '@savoir/sdk' const client = new SavoirClient({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY, }) ``` -------------------------------- ### Custom GitHub Bot Trigger Configuration Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/bot-setup.md This example demonstrates how to configure a custom trigger name for the GitHub bot using environment variables. Users can then mention this custom name instead of the default app name. ```bash NUXT_PUBLIC_GITHUB_APP_NAME=your-bot-name NUXT_PUBLIC_GITHUB_BOT_TRIGGER=ask-ai # Users will @ask-ai instead of @your-bot-name ``` -------------------------------- ### Create a New Chat via API Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Initiates a new chat session with the AI agent. Requires API key for authentication and accepts a message to start the conversation. Returns the chat ID and other metadata. ```bash curl -X POST https://your-app.com/api/chats \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "id": "chat_abc123", \ "mode": "chat", \ "message": { \ "id": "msg_1", \ "role": "user", \ "parts": [{ "type": "text", "text": "How do I configure routing in Nuxt?" }] \ } \ }' ``` -------------------------------- ### Handle GitHub Webhooks in API Route Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Provides an example of an API route handler that processes incoming GitHub webhook requests using the initialized GitHub adapter. This allows the bot to receive and respond to events from GitHub. ```typescript // Handle webhooks (in your API route) export default defineEventHandler(async (event) => { const request = toWebRequest(event) return await githubAdapter.handleWebhook(request) }) ``` -------------------------------- ### Savoir SDK Initialization and Usage (TypeScript) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/ARCHITECTURE.md Demonstrates how to initialize and use the Savoir SDK to interact with an AI agent. It shows how to create a client instance with API credentials and session information, and highlights available methods for executing tools and retrieving agent configuration. ```typescript import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiUrl: 'https://your-savoir-instance.com', apiKey: 'your-api-key', // Better Auth API key sessionId: 'optional', // Reuse sandbox session onToolCall: (info) => {}, // Tool execution callback }) // Returns: // savoir.tools.bash - Execute single bash command in sandbox // savoir.tools.bash_batch - Execute multiple commands in one request // savoir.client - Low-level SavoirClient for direct API access // savoir.getAgentConfig() - Fetch agent configuration ``` -------------------------------- ### Define a Custom AI Tool with Generator Function Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/CUSTOMIZATION.md Create custom AI tools using generator functions (`async function*`) in TypeScript. These tools must yield status updates for frontend display. The example demonstrates yielding 'loading' and 'done' statuses, including success and error states with command output. ```typescript import { tool } from 'ai' import { z } from 'zod' export const myTool = tool({ description: 'Description of what this tool does', inputSchema: z.object({ query: z.string().describe('The input query'), }), execute: async function* ({ query }) { // Yield loading — frontend shows a spinner yield { status: 'loading' as const } const start = Date.now() try { const result = await doSomething(query) // Yield done — frontend displays the output yield { status: 'done' as const, durationMs: Date.now() - start, text: result, commands: [{ title: `My tool: "${query}"`, command: '', stdout: result, stderr: '', exitCode: 0, success: true, }], } } catch (error) { yield { status: 'done' as const, durationMs: Date.now() - start, text: '', commands: [{ title: `My tool: "${query}"`, command: '', stdout: '', stderr: error instanceof Error ? error.message : 'Failed', exitCode: 1, success: false, }], } } }, }) ``` -------------------------------- ### Execute bash command using Savoir client Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md Shows how to execute a single bash command directly against the documentation sandbox using the savoir.client.bash method. The standard output of the command is logged to the console. ```typescript // Execute bash command const result = await savoir.client.bash('grep -rl "authentication" docs/') console.log(result.stdout) ``` -------------------------------- ### Create Savoir Instance and Use with AI SDK Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Demonstrates how to create a Savoir instance using the `@savoir/sdk` and integrate it with Vercel AI SDK's `generateText` function. This allows AI models to utilize bash and bash_batch tools for knowledge retrieval. It also shows how to access the underlying client for direct API operations. ```typescript import { createSavoir } from '@savoir/sdk' import { generateText } from 'ai' // Create a Savoir instance const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, // Required: Base URL of your Savoir API apiKey: process.env.SAVOIR_API_KEY, // Optional: API key for authentication sessionId: 'optional-session-id', // Optional: Reuse existing sandbox session source: 'my-app', // Optional: Usage source identifier sourceId: 'request-123', // Optional: Tracking ID for usage reporting }) // Use with AI SDK generateText const { text } = await generateText({ model: 'google/gemini-3-flash', tools: savoir.tools, // Includes bash and bash_batch tools maxSteps: 10, prompt: 'How do I configure authentication in Nuxt?', }) console.log(text) // Access the underlying client const sources = await savoir.client.getSources() console.log(`Found ${sources.total} sources`) // Get current session ID (for sandbox reuse) const sessionId = savoir.getSessionId() ``` -------------------------------- ### Get Specific Chat with Messages via API Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Fetches a specific chat conversation, including all its messages. Requires the chat ID and API key. ```bash curl -X GET https://your-app.com/api/chats/chat_abc123 \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Configure and Initialize GitHub Bot Adapter Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Sets up the GitHub adapter for the AI agent, configuring authentication with GitHub App credentials and webhook secrets. It then initializes the adapter with the Chat SDK, enabling it to process GitHub events. ```typescript import { SavoirGitHubAdapter } from './server/utils/bot/adapters/github' import { Chat } from 'chat' // Configure the GitHub adapter const githubAdapter = new SavoirGitHubAdapter({ appId: process.env.GITHUB_APP_ID!, privateKey: process.env.GITHUB_APP_PRIVATE_KEY!, webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!, userName: 'my-bot', // GitHub App name replyToNewIssues: false, // Only reply when mentioned }) // Initialize with Chat SDK const chat = new Chat({ adapters: [githubAdapter], onMessage: async (adapter, threadId, message) => { // Process message with your AI agent const response = await generateAIResponse(message.text) await adapter.postMessage(threadId, { markdown: response }) }, }) await githubAdapter.initialize(chat) ``` -------------------------------- ### Get agent configuration using Savoir client Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md Fetches the current agent configuration settings using the savoir.client.getAgentConfig() method. This provides insight into the agent's operational parameters. ```typescript // Get agent configuration const config = await savoir.client.getAgentConfig() ``` -------------------------------- ### Required Environment Variables for Self-hosting (Bash) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/README.md Lists essential environment variables required for self-hosting the Knowledge Agent Template. It includes variables for authentication (secret, GitHub OAuth credentials), AI gateway API key (optional for local dev), and sandbox configurations (GitHub snapshot repo, token). ```bash # Authentication BETTER_AUTH_SECRET=your-secret # Secret for signing sessions/tokens GITHUB_CLIENT_ID=... GITHUB_CLIENT_SECRET=... # AI (optional — only needed for local dev, Vercel uses OIDC automatically) # AI_GATEWAY_API_KEY=... # Sandbox # NUXT_GITHUB_SNAPSHOT_REPO=org/repo # NUXT_GITHUB_TOKEN=ghp_... ``` -------------------------------- ### Create Savoir instance with configuration options Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Illustrates the creation of a Savoir instance using the `createSavoir` function, showcasing various configuration options. This includes setting the API URL, API key, an optional session ID for sandbox reuse, and a callback for tool execution states. ```typescript import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY, sessionId: 'optional-session-id', // For sandbox reuse onToolCall: (info) => { // Optional callback for tool execution states console.log(`Tool ${info.toolName}: ${info.state}`) }, }) ``` -------------------------------- ### Handle NetworkError in TypeScript Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Demonstrates how to catch and handle a NetworkError when interacting with the Savoir SDK. This error is thrown when API requests fail due to network issues. The example shows accessing the error message and the original cause. ```typescript import { NetworkError } from '@savoir/sdk' try { await client.bash('some-command') } catch (error) { if (error instanceof NetworkError) { console.log(error.message) console.log(error.cause) // Original error } } ``` -------------------------------- ### Execute multiple bash commands using Savoir client Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md Demonstrates executing multiple bash commands efficiently in a single request using savoir.client.bashBatch. This method is more performant for sequential command execution. ```typescript // Execute multiple commands const batchResult = await savoir.client.bashBatch([ 'find docs/ -name "*.md" | head -10', 'cat docs/my-framework/getting-started/installation.md', ]) ``` -------------------------------- ### Initialize Savoir SDK and Use Tools in AI Application Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/ARCHITECTURE.md This JavaScript snippet demonstrates how to initialize the Savoir SDK with an API key and URL, and then integrate its tools (like bash and bash_batch) into an AI SDK's generateText function. It requires the 'ai' and '@savoir/sdk' packages. ```javascript import { generateText } from 'ai' import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiKey, apiUrl }) const { text } = await generateText({ model: yourModel, tools: savoir.tools // bash, bash_batch }) ``` -------------------------------- ### Auto-Reply to New Issues Configuration (TypeScript) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/bot-setup.md This TypeScript code snippet shows how to enable the auto-reply feature for new issues in the `nuxt.config.ts` file. When enabled, the bot will automatically respond to every new issue. ```typescript runtimeConfig: { github: { replyToNewIssues: true, }, } ``` -------------------------------- ### Generate Text with AI SDK and Savoir Tools (TypeScript) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/README.md Demonstrates how to use the AI SDK with Savoir tools to generate text. It initializes the Savoir SDK with API credentials and then uses the `generateText` function with a specified model, Savoir tools, and a prompt. The output text is then logged to the console. ```typescript import { generateText } from 'ai' import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY, }) const { text } = await generateText({ model: yourModel, // any AI SDK compatible model tools: savoir.tools, // bash and bash_batch tools maxSteps: 10, prompt: 'How do I configure authentication?', }) console.log(text) ``` -------------------------------- ### Customize UI Theme with Nuxt UI Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/CUSTOMIZATION.md Modify the UI theme by editing the `apps/app/app/app.config.ts` file. This allows customization of primary and neutral colors using Tailwind CSS color names. Further theming options are available in the Nuxt UI documentation. ```typescript export default defineAppConfig({ // ... ui: { colors: { primary: 'blue', // Any Tailwind color neutral: 'slate', }, // Override component slots as needed } }) ``` -------------------------------- ### SavoirClient: Execute bash commands and manage API resources Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Demonstrates various operations using the `SavoirClient`, including executing single and batched bash commands, retrieving source configurations, triggering sync operations, and reporting usage data. ```typescript // Execute bash command const result = await client.bash('ls -la') console.log(result.stdout) // Execute multiple commands const batchResult = await client.bashBatch(['pwd', 'ls', 'cat README.md']) // Get sources configuration const sources = await client.getSources() // Trigger sync await client.sync({ reset: false, push: true }) // Get agent configuration const config = await client.getAgentConfig() // Report usage from an AI SDK generate result await client.reportUsage(result, { startTime: Date.now() }) ``` -------------------------------- ### Fetch Public Agent Configuration via API Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt This GET request retrieves the active agent configuration settings. This information is intended for SDK and bot integrations, providing details on prompt customization, response style, language, default models, and other operational parameters. ```bash curl -X GET https://your-app.com/api/agent-config/public \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Configure Savoir SDK client Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/apps/app/app/content/docs/sdk.md Initializes the Savoir SDK client with essential configuration options such as the API URL and API key. The API key is used for authentication and can be better managed via an API key. ```typescript import { createSavoir } from '@savoir/sdk' const savoir = createSavoir({ apiUrl: process.env.SAVOIR_API_URL!, apiKey: process.env.SAVOIR_API_KEY!, // Better Auth API key }) ``` -------------------------------- ### Configure App Branding and Description Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/CUSTOMIZATION.md Modify the application's name, description, and icon by editing the `app.config.ts` file. This impacts the UI, login page, shared chats, and SEO meta tags. Ensure the icon path is updated if a custom SVG is used. ```typescript export default defineAppConfig({ app: { name: 'My Assistant', description: 'Open source file-system and knowledge based agent template.', icon: 'i-custom-savoir', // Replace with your own icon }, // ... }) ``` -------------------------------- ### Use Schema Section Dividers for Data Structures (TypeScript) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/CODING-GUIDELINES.md This example illustrates the exception to the 'no section dividers' rule: using comments to divide sections within data structures like schema definitions. This improves readability by grouping related fields, as shown with common, GitHub, and YouTube fields in a `sqliteTable` definition. ```typescript export const sources = sqliteTable('sources', { // Common fields label: text('label'), // GitHub fields repo: text('repo'), branch: text('branch'), // YouTube fields channelId: text('channel_id'), }) ``` -------------------------------- ### SavoirClient: Direct API Access and Command Execution Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Illustrates the usage of the `SavoirClient` for direct interaction with the Savoir API. This includes executing single bash commands, batching multiple commands for efficiency, managing content sources, triggering sync operations, retrieving agent configuration, and handling potential API and network errors. ```typescript import { SavoirClient, SavoirError, NetworkError } from '@savoir/sdk' const client = new SavoirClient({ apiUrl: 'https://your-savoir-instance.com', apiKey: 'your-api-key', }) // Execute a single bash command const result = await client.bash('grep -rl "useAsyncData" docs/ --include="*.md" | head -5') console.log(result.stdout) // File paths matching the search console.log(result.exitCode) // 0 for success // Execute multiple commands in batch (more efficient) const batchResult = await client.bashBatch([ 'find docs/ -name "*.md" -type f | head -10', 'grep -rl "authentication" docs/ --include="*.md" | head -5', 'head -50 docs/getting-started/index.md', ]) batchResult.results.forEach(r => { console.log(`Command: ${r.command}`) console.log(`Output: ${r.stdout}`) }) // Get configured sources const sources = await client.getSources() console.log(`GitHub sources: ${sources.github.count}`) console.log(`YouTube sources: ${sources.youtube.count}`) // Trigger content sync await client.sync({ reset: false, push: true }) // Sync a specific source await client.syncSource('my-framework-docs', { push: true }) // Get agent configuration const config = await client.getAgentConfig() console.log(`Response style: ${config.responseStyle}`) // Error handling try { await client.bash('some-command') } catch (error) { if (error instanceof SavoirError) { console.log(`API Error ${error.statusCode}: ${error.message}`) if (error.isAuthError()) console.log('Authentication failed') if (error.isRateLimitError()) console.log('Rate limited') } else if (error instanceof NetworkError) { console.log(`Network error: ${error.message}`) } } ``` -------------------------------- ### GitHub Adapter Integration Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Documentation for integrating the GitHub adapter for bot functionalities. ```APIDOC ## GitHub Adapter Integration ### Description This section details how to integrate and use the GitHub adapter for handling GitHub webhook events and interacting with AI agents. ### Initialization ```typescript import { SavoirGitHubAdapter } from './server/utils/bot/adapters/github' import { Chat } from 'chat' const githubAdapter = new SavoirGitHubAdapter({ appId: process.env.GITHUB_APP_ID!, privateKey: process.env.GITHUB_APP_PRIVATE_KEY!, webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!, userName: 'my-bot', replyToNewIssues: false, }) const chat = new Chat({ adapters: [githubAdapter], onMessage: async (adapter, threadId, message) => { const response = await generateAIResponse(message.text) await adapter.postMessage(threadId, { markdown: response }) }, }) await githubAdapter.initialize(chat) ``` ### Handling Webhooks ```typescript import { toWebRequest } from 'h3' // Assuming h3 framework export default defineEventHandler(async (event) => { const request = toWebRequest(event) return await githubAdapter.handleWebhook(request) }) ``` ### Thread ID Encoding ```typescript const threadId = githubAdapter.encodeThreadId({ owner: 'vercel', repo: 'next.js', issueNumber: 12345, }) ``` ### Fetching Thread Context ```typescript const context = await githubAdapter.fetchThreadContext(threadId) console.log(context) /* { platform: 'github', number: 12345, title: 'Issue title', body: 'Issue description', labels: ['bug', 'documentation'], state: 'open', source: 'vercel/next.js', previousComments: [...] } */ ``` ``` -------------------------------- ### Avoid In-Memory Caches in Serverless Environments (TypeScript) Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/docs/CODING-GUIDELINES.md This snippet highlights a critical point for serverless development: never use in-memory caches. It shows an incorrect example using `new Map()` and provides the correct alternative using NuxtHub KV for persistent caching. This ensures data is available across serverless function invocations. ```typescript // ❌ Doesn't work in serverless const cache = new Map() // ✅ Use NuxtHub KV const kv = hubKV() const cached = await kv.get('my-key') await kv.set('my-key', data) ``` -------------------------------- ### Execute a single bash command using the 'bash' tool Source: https://github.com/vercel-labs/knowledge-agent-template/blob/main/packages/sdk/README.md Demonstrates how to use the `bash` tool provided by the Savoir SDK to execute a single bash command within the documentation sandbox. This is useful for simple command-line operations. ```typescript const { text } = await generateText({ model, tools: { bash: savoir.tools.bash }, prompt: 'List all markdown files in the docs folder', }) ``` -------------------------------- ### List Content Sources Source: https://context7.com/vercel-labs/knowledge-agent-template/llms.txt Retrieves a list of all configured content sources, including GitHub repositories and YouTube channels, along with their synchronization status. ```APIDOC ## GET /api/sources ### Description Lists all configured content sources, grouped by type (GitHub, YouTube), and provides their synchronization status. ### Method GET ### Endpoint /api/sources ### Parameters No parameters required. ### Response #### Success Response (200) - **total** (integer) - The total number of configured sources. - **lastSyncAt** (integer) - Timestamp of the last synchronization. - **youtubeEnabled** (boolean) - Indicates if YouTube synchronization is enabled. - **snapshotRepo** (string) - The repository used for content snapshots. - **snapshotBranch** (string) - The branch used for content snapshots. - **snapshotRepoUrl** (string) - The URL of the snapshot repository. - **github** (object) - Information about GitHub sources. - **count** (integer) - Number of GitHub sources. - **sources** (array of objects) - Details of each GitHub source. - **id** (string) - Unique identifier for the source. - **type** (string) - Type of the source (e.g., "github"). - **label** (string) - Display name for the source. - **repo** (string) - GitHub repository name (e.g., "nuxt/nuxt"). - **branch** (string) - The branch to sync from. - **contentPath** (string) - Path within the repository to sync. - **outputPath** (string) - Path where content will be stored. - **readmeOnly** (boolean) - Whether to only sync the README file. - **youtube** (object) - Information about YouTube sources. - **count** (integer) - Number of YouTube sources. - **sources** (array of objects) - Details of each YouTube source. - **id** (string) - Unique identifier for the source. - **type** (string) - Type of the source (e.g., "youtube"). - **label** (string) - Display name for the source. - **channelId** (string) - YouTube channel ID. - **handle** (string) - YouTube channel handle. - **maxVideos** (integer) - Maximum number of videos to sync. #### Response Example ```json { "total": 5, "lastSyncAt": 1704067200000, "youtubeEnabled": true, "snapshotRepo": "org/content-snapshot", "snapshotBranch": "main", "snapshotRepoUrl": "https://github.com/org/content-snapshot", "github": { "count": 3, "sources": [ { "id": "nuxt-docs", "type": "github", "label": "Nuxt Documentation", "repo": "nuxt/nuxt", "branch": "main", "contentPath": "docs", "outputPath": "nuxt", "readmeOnly": false } ] }, "youtube": { "count": 2, "sources": [ { "id": "alex-lichter", "type": "youtube", "label": "Alex Lichter", "channelId": "UCxxxxxxx", "handle": "@TheAlexLichter", "maxVideos": 50 } ] } } ``` ```