Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix paths

Rahul Tarakea7913f558c4
diff --git a/fern/docs.yml b/fern/docs.yml
index 870891b48..9c8ea94ef 100644
--- a/fern/docs.yml
+++ b/fern/docs.yml
@@ -123,71 +123,71 @@ navigation:
skip-slug: true
contents:
- page: Welcome
- path: pages/dist/welcome.mdx
+ path: pages/dist/get-started/welcome.mdx
slug: welcome
- page: Quickstart
- path: pages/dist/quickstart.mdx
+ path: pages/dist/get-started/quickstart.mdx
slug: quickstart
- page: IDE and Agent Setup
- path: pages/dist/dev-setup.mdx
+ path: pages/dist/get-started/dev-setup.mdx
slug: dev-setup
- page: Providers
- path: pages/dist/providers.mdx
+ path: pages/dist/get-started/providers.mdx
slug: providers
- section: Tools
icon: tools
skip-slug: true
contents:
- page: Executing Tools
- path: pages/dist/executing-tools.mdx
+ path: pages/dist/tool-calling/executing-tools.mdx
slug: executing-tools
- page: Authenticating Tools
- path: pages/dist/authenticating-tools.mdx
+ path: pages/dist/tool-calling/authenticating-tools.mdx
slug: authenticating-tools
- page: Fetch and Filter Tools
- path: pages/dist/fetching-tools.mdx
+ path: pages/dist/tool-calling/fetching-tools.mdx
slug: fetching-tools
- section: Modifiers
slug: modifiers
contents:
- page: Schema Modifiers
- path: pages/dist/schema-modifiers.mdx
+ path: pages/dist/tool-calling/schema-modifiers.mdx
slug: schema-modifiers
- page: Before Tool Execution
- path: pages/dist/before-execution-modifiers.mdx
+ path: pages/dist/tool-calling/before-execution-modifiers.mdx
slug: before-execution
- page: After Tool Execution
- path: pages/dist/after-execution-modifiers.mdx
+ path: pages/dist/tool-calling/after-execution-modifiers.mdx
slug: after-execution
- page: Custom tools
- path: pages/dist/custom-tools.mdx
+ path: pages/dist/tool-calling/custom-tools.mdx
slug: custom-tools
- section: Authentication
icon: lock
skip-slug: true
contents:
- page: Custom Auth Configs
- path: pages/dist/custom-auth-configs.mdx
+ path: pages/dist/authentication/custom-auth-configs.mdx
slug: custom-auth-configs
- page: Programmatic Auth Configs
- path: pages/dist/programmatic-auth-configs.mdx
+ path: pages/dist/authentication/programmatic-auth-configs.mdx
slug: programmatic-auth-configs
- page: Custom Auth Parameters
- path: pages/dist/custom-auth-params.mdx
+ path: pages/dist/authentication/custom-auth-params.mdx
slug: custom-auth-params
- section: Triggers
icon: bolt
skip-slug: true
contents:
- page: Using Triggers
- path: pages/dist/using-triggers.mdx
+ path: pages/dist/triggers/using-triggers.mdx
slug: using-triggers
- section: MCP
icon: server
skip-slug: true
contents:
- page: Introduction
- path: pages/dist/introduction.mdx
+ path: pages/dist/mcp/introduction.mdx
slug: mcp-introduction
- section: Resources
icon: book
@@ -203,27 +203,27 @@ navigation:
skip-slug: true
contents:
- page: Hello World
- path: pages/dist/hello-world.mdx
+ path: pages/dist/examples/hello-world.mdx
slug: examples/hello-world
- page: Sample Script
- path: pages/dist/sample-script.mdx
+ path: pages/dist/examples/sample-script.mdx
slug: examples/sample-script
- page: Basic Hono Server
- path: pages/dist/sample-webserver.mdx
+ path: pages/dist/examples/sample-webserver/sample-webserver.mdx
slug: examples/sample-webserver
- section: Full Stack Applications
icon: globe
skip-slug: true
contents:
- page: Full Stack Chat App
- path: pages/dist/vercel-composio.mdx
+ path: pages/dist/examples/vercel-composio.mdx
slug: examples/chat-app
- section: Productivity & Automation
icon: zap
skip-slug: true
contents:
- page: Gmail Reaper
- path: pages/dist/gmail-filterer.mdx
+ path: pages/dist/examples/gmail-filterer.mdx
slug: examples/gmail-reaper
- tab: providers
layout:
@@ -231,23 +231,23 @@ navigation:
icon: code
contents:
- page: OpenAI Provider
- path: pages/dist/openai.mdx
+ path: pages/dist/providers/openai.mdx
- page: Anthropic Provider
- path: pages/dist/anthropic.mdx
+ path: pages/dist/providers/anthropic.mdx
- page: LangChain Provider
- path: pages/dist/langchain.mdx
+ path: pages/dist/providers/langchain.mdx
- page: CrewAI Provider
- path: pages/dist/crewai.mdx
+ path: pages/dist/providers/crewai.mdx
- page: Vercel AI SDK Provider
- path: pages/dist/vercel.mdx
+ path: pages/dist/providers/vercel.mdx
- page: Google ADK Provider
- path: pages/dist/google-adk.mdx
+ path: pages/dist/providers/google-adk.mdx
- page: OpenAI Agents Provider
- path: pages/dist/openai-agents.mdx
+ path: pages/dist/providers/openai-agents.mdx
- page: Mastra Provider
- path: pages/dist/mastra.mdx
+ path: pages/dist/providers/mastra.mdx
- page: Custom Provider
- path: pages/dist/custom.mdx
+ path: pages/dist/providers/custom.mdx
- tab: tools
layout:
- section: Tools
diff --git a/fern/package.json b/fern/package.json
index 2ec17e522..f285385c0 100644
--- a/fern/package.json
+++ b/fern/package.json
@@ -44,6 +44,7 @@
"hono": "^4.7.11",
"next": "^15.3.3",
"only-allow": "^1.2.1",
+ "openai": "^4.94.0",
"react": "^18.3.1",
"tailwindcss": "^3.4.17",
"typedoc": "^0.28.5",
diff --git a/fern/pages/src/authentication/custom-auth-configs.mdx b/fern/pages/src/authentication/custom-auth-configs.mdx
index bdb26f565..c5838e371 100644
--- a/fern/pages/src/authentication/custom-auth-configs.mdx
+++ b/fern/pages/src/authentication/custom-auth-configs.mdx
@@ -20,7 +20,7 @@ You'll need to customize the auth config in cases where you want to add in a dif
<Tab title="Example: PostHog">
You may change the subdomain for the PostHog toolkit to match your own instance.
<Frame background="subtle" title="PostHog Auth Config Settings">
-<img src="../../assets/images/custom-auth-posthog.png" />
+<img src="../../../assets/images/custom-auth-posthog.png" />
</Frame>
</Tab>
<Tab title="Example: Hubspot">
@@ -29,7 +29,7 @@ For Hubspot you may customize everything here. For each auth scheme there is a d
If you choose to use your own developer app for OAuth2 scheme, you will have to provide the client ID and client secret.
<Frame background="subtle" title="Hubspot Auth Config Settings">
-<img src="../../assets/images/custom-auth-hubspot.png" />
+<img src="../../../assets/images/custom-auth-hubspot.png" />
</Frame>
</Tab>
</Tabs>
@@ -56,12 +56,12 @@ Examples for Google and GitHub:
<Tabs>
<Tab title="Google">
<Frame background="subtle" caption="Google OAuth Configuration">
- <img src="../../assets/images/google-oauth-config.png" />
+ <img src="../../../assets/images/google-oauth-config.png" />
</Frame>
</Tab>
<Tab title="GitHub">
<Frame background="subtle" caption="GitHub OAuth Configuration">
- <img src="../../assets/images/github-oauth-config.png" />
+ <img src="../../../assets/images/github-oauth-config.png" />
</Frame>
</Tab>
</Tabs>
@@ -84,7 +84,7 @@ Once you have the OAuth credentials, you can add them to the auth config in the
4. Click **"Create Integration"** once done!
<Frame background="subtle" title="Auth Config Settings">
- <img src="../../assets/images/integration-step-3-0.png" />
+ <img src="../../../assets/images/integration-step-3-0.png" />
</Frame>
As usual, copy and use the auth config ID starting with `ac_` in your application code via a secret manager.
@@ -127,7 +127,7 @@ print(connected_account)
By default the users will see an OAuth screen like the one below:
<Frame background="subtle" caption="Composio's Domain in OAuth Consent Screen">
- <img src="../../assets/images/oauth-branding.png" />
+ <img src="../../../assets/images/oauth-branding.png" />
</Frame>
The OAuth redirect URL is surfaced in the some OAuth providers' consent screens. This may cause confusion for some users as that URL is not of the same domain as the application.
@@ -206,7 +206,7 @@ def authorize_app(toolkit: str):
Specify the your custom redirect URI in the auth config settings!
<Frame background="subtle" title="Auth Config Settings">
-<img src="../../assets/images/custom-redirect-uri.png" />
+<img src="../../../assets/images/custom-redirect-uri.png" />
</Frame>
</Step>
</Steps>
diff --git a/fern/snippets/typescript/sample-webserver/index.ts b/fern/pages/src/examples/sample-webserver/index.ts
similarity index 100%
rename from fern/snippets/typescript/sample-webserver/index.ts
rename to fern/pages/src/examples/sample-webserver/index.ts
diff --git a/fern/pages/src/examples/sample-webserver.mdx b/fern/pages/src/examples/sample-webserver/sample-webserver.mdx
similarity index 91%
rename from fern/pages/src/examples/sample-webserver.mdx
rename to fern/pages/src/examples/sample-webserver/sample-webserver.mdx
index b0018b10d..ef481c8d2 100644
--- a/fern/pages/src/examples/sample-webserver.mdx
+++ b/fern/pages/src/examples/sample-webserver/sample-webserver.mdx
@@ -35,7 +35,7 @@ In this tutorial, we will create an auth config, initiate a connection, and send
Basic scaffolding for the server.
<SnippetCode
- src="fern/snippets/typescript/sample-webserver/index.ts"
+ src="./index.ts"
startLine={1}
endLine={10}
title="Setup"
@@ -53,7 +53,7 @@ For this example, we will create a basic GMAIL auth config.
You are recommend to store these config ids, so that you can reuse them later.
<SnippetCode
- src="fern/snippets/typescript/sample-webserver/index.ts"
+ src="./index.ts"
startLine={12}
endLine={16}
title="Auth Configs"
@@ -69,7 +69,7 @@ they will be redirected to the auth flow.
Once they have authorized the connection, you can use the `id` to get and execute the tools as the user.
<SnippetCode
- src="fern/snippets/typescript/sample-webserver/index.ts"
+ src="./index.ts"
startLine={16}
endLine={27}
title="Initiating a connection"
@@ -90,7 +90,7 @@ curl -X POST http://localhost:3000/create-connection \
Now let's send that email.
<SnippetCode
- src="fern/snippets/typescript/sample-webserver/index.ts"
+ src="./index.ts"
startLine={29}
endLine={59}
title="Sending an email"
@@ -109,7 +109,7 @@ curl -X POST http://localhost:3000/send-email \
### Full Code
-You can see the full code [here](https://github.com/ComposioHQ/composio/blob/next/fern/snippets/typescript/sample-webserver/index.ts).
+You can see the full code [here](https://github.com/ComposioHQ/composio/blob/next/fern/pages/src/examples/sample-webserver/index.ts).
### What just happened?
diff --git a/fern/pages/src/examples/vercel-composio.mdx b/fern/pages/src/examples/vercel-composio.mdx
index e805a411d..fec4e96fd 100644
--- a/fern/pages/src/examples/vercel-composio.mdx
+++ b/fern/pages/src/examples/vercel-composio.mdx
@@ -27,7 +27,7 @@ Learn how to create auth configs [here](/docs/authenticating-tools#creating-an-a
Once done, your auth configs will be available in the [Composio dashboard](https://app.composio.dev/integrations).
<Frame>
- <img src="../../assets/images/examples/auth-configs.png" alt="Auth configs" />
+ <img src="../../../assets/images/examples/auth-configs.png" alt="Auth configs" />
</Frame>
### Save auth config IDs to environment variables
@@ -62,7 +62,7 @@ The Composio SDK is meant to be used only in server-side code. For client-side f
In order to list the toolkits and their connection status, we create a Next.js API route to fetch the toolkits using Composio SDK.
<Frame>
- <img src="../../assets/images/examples/toolkits.png" />
+ <img src="../../../assets/images/examples/toolkits.png" />
</Frame>
### 1. Listing connected accounts
@@ -128,7 +128,7 @@ Users need to connect and disconnect their accounts from the chatbot to enable t
When a user wants to connect their account, we create a connection request that redirects them to the OAuth provider:
<Frame>
- <img src="../../assets/images/examples/create-connection.png" />
+ <img src="../../../assets/images/examples/create-connection.png" />
</Frame>
```typescript app/api/connections/initiate/route.ts
@@ -155,7 +155,7 @@ export async function POST(request: Request) {
After initiating a connection, we need to wait for the OAuth flow to complete. We check the connection status to know when it's ready to use:
<Frame>
- <img src="../../assets/images/examples/connection-status.png" />
+ <img src="../../../assets/images/examples/connection-status.png" />
</Frame>
```typescript app/api/connections/status/route.ts
@@ -260,7 +260,7 @@ export async function POST(request: Request) {
By default, tool calls appear as raw JSON in the chat interface. To create a better user experience, we can build custom components that display tool calls with proper formatting and loading states.
<Frame>
- <img src="../../assets/images/examples/custom-tool-component.png" />
+ <img src="../../../assets/images/examples/custom-tool-component.png" />
</Frame>
You can find the `ToolCall` component at `components/tool-call.tsx`. Here's how to integrate it into your message rendering:
diff --git a/fern/pages/src/get-started/dev-setup.mdx b/fern/pages/src/get-started/dev-setup.mdx
index e4f03af74..a7093ce10 100644
--- a/fern/pages/src/get-started/dev-setup.mdx
+++ b/fern/pages/src/get-started/dev-setup.mdx
@@ -15,7 +15,7 @@ This guide explains how to setup your IDE, and coding agents to help you ship fa
To optimize your experience building with Composio, you can add instructions to Cursor's system settings.
<Frame>
- <img src="../../assets/images/cursor-settings.png" alt="Cursor settings" />
+ <img src="../../../assets/images/cursor-settings.png" alt="Cursor settings" />
</Frame>
Add the following to your Cursor "Rules for AI":
diff --git a/fern/pages/src/get-started/providers.mdx b/fern/pages/src/get-started/providers.mdx
index 162c144e4..d06918002 100644
--- a/fern/pages/src/get-started/providers.mdx
+++ b/fern/pages/src/get-started/providers.mdx
@@ -9,7 +9,7 @@ Every LLM framework and provider essentially does the same thing - **tool callin
<Frame>
<img
- src="../../assets/images/providers-and-toolsets.png"
+ src="../../../assets/images/providers-and-toolsets.png"
alt="Providers and Toolsets"
width="400px"
height="auto"
@@ -121,21 +121,21 @@ composio = Composio(provider=OpenAIAgentsProvider())
<CardGroup cols={3}>
<Card
title="OpenAI Provider"
- icon={<img src="../../assets/images/openai-logo.svg" width="24" height="24" />}
+ icon={<img src="../../../assets/images/openai-logo.svg" width="24" height="24" />}
href="/providers/openai"
>
Integrate with OpenAI's tool calling and agents.
</Card>
<Card
title="Anthropic Provider"
- icon={<img src="../../assets/images/anthropic-logo.svg" width="24" height="24" />}
+ icon={<img src="../../../assets/images/anthropic-logo.svg" width="24" height="24" />}
href="/providers/anthropic"
>
Use Anthropic's Claude models with Composio tools.
</Card>
<Card
title="Gemini Provider"
- icon={<img src="../../assets/images/google-logo.svg" width="24" height="24" />}
+ icon={<img src="../../../assets/images/google-logo.svg" width="24" height="24" />}
href="/providers/google-adk"
>
Integrate with Google's Gemini models.
@@ -146,7 +146,7 @@ composio = Composio(provider=OpenAIAgentsProvider())
<CardGroup cols={3}>
<Card
title="LangGraph Provider"
- icon={<img src="../../assets/images/langgraph-logo.svg"/>}
+ icon={<img src="../../../assets/images/langgraph-logo.svg"/>}
href="/providers/langgraph"
>
Add tools to LangGraph agent flows.
@@ -160,7 +160,7 @@ composio = Composio(provider=OpenAIAgentsProvider())
</Card>
<Card
title="Vercel AI SDK Provider"
- icon={<img src="../../assets/images/vercel-logo.svg" width="24" height="24" />}
+ icon={<img src="../../../assets/images/vercel-logo.svg" width="24" height="24" />}
href="/providers/vercel"
>
Use Composio tools with Vercel's AI SDK.
diff --git a/fern/pages/src/get-started/welcome.mdx b/fern/pages/src/get-started/welcome.mdx
index 153c41ba9..c0b6fba64 100644
--- a/fern/pages/src/get-started/welcome.mdx
+++ b/fern/pages/src/get-started/welcome.mdx
@@ -7,7 +7,7 @@ hide-nav-links: false
---
<Frame>
- <img src="../../assets/images/hero.png" alt="Composio introduction image" />
+ <img src="../../../assets/images/hero.png" alt="Composio introduction image" />
</Frame>
<Tip>
Give your AI IDE access to Composio's documentation using our llms.txt files: ([short
diff --git a/fern/pages/src/tool-calling/after-execution-modifiers.mdx b/fern/pages/src/tool-calling/after-execution-modifiers.mdx
index 2f5a71a42..575fe9c9a 100644
--- a/fern/pages/src/tool-calling/after-execution-modifiers.mdx
+++ b/fern/pages/src/tool-calling/after-execution-modifiers.mdx
@@ -18,7 +18,7 @@ These modifiers are called after the tool is executed by the LLM. This allows yo
- Convert the output to a different format before returning it to the agent.
<Frame>
- <img src="../../assets/images/after-execute.png" alt="After Execution Modifier" />
+ <img src="../../../assets/images/after-execute.png" alt="After Execution Modifier" />
</Frame>
<Note>
diff --git a/fern/pages/src/tool-calling/authenticating-tools.mdx b/fern/pages/src/tool-calling/authenticating-tools.mdx
index eada51343..97a1ea551 100644
--- a/fern/pages/src/tool-calling/authenticating-tools.mdx
+++ b/fern/pages/src/tool-calling/authenticating-tools.mdx
@@ -29,13 +29,13 @@ Once created, it's reusable across multiple users.
<Step title="Select App">
Navigate to the [Apps page](https://app.composio.dev/apps) and choose the app you want to integrate (for example, Google Sheets).
<Frame background="subtle" title="Application Selection Screen">
- <img src="../../assets/images/integration-step-1-0.png" />
+ <img src="../../../assets/images/integration-step-1-0.png" />
</Frame>
</Step>
<Step title="Initiate Setup">
Click the **"Setup Integration"** button.
<Frame background="subtle" title="Auth Config Setup Interface">
- <img src="../../assets/images/integration-step-2-0.png" />
+ <img src="../../../assets/images/integration-step-2-0.png" />
</Frame>
</Step>
<Step title="Configure Auth Config Settings">
@@ -48,7 +48,7 @@ Once created, it's reusable across multiple users.
</Note>
<Frame background="subtle" title="Auth Config Settings">
- <img src="../../assets/images/auth-config-creation.png" />
+ <img src="../../../assets/images/auth-config-creation.png" />
</Frame>
</Step>
<Step title="Create and Get ID">
diff --git a/fern/pages/src/tool-calling/before-execution-modifiers.mdx b/fern/pages/src/tool-calling/before-execution-modifiers.mdx
index 7ad6bd9f2..65412064f 100644
--- a/fern/pages/src/tool-calling/before-execution-modifiers.mdx
+++ b/fern/pages/src/tool-calling/before-execution-modifiers.mdx
@@ -18,7 +18,7 @@ These modifiers are called before the tool is executed by the LLM. This allows y
- Overriding the arguments emitted by the LLM.
<Frame>
- <img src="../../assets/images/before-execute.png" alt="Before Execution Modifier" />
+ <img src="../../../assets/images/before-execute.png" alt="Before Execution Modifier" />
</Frame>
<Note>
diff --git a/fern/pages/src/tool-calling/schema-modifiers.mdx b/fern/pages/src/tool-calling/schema-modifiers.mdx
index 69d631d54..bccabd306 100644
--- a/fern/pages/src/tool-calling/schema-modifiers.mdx
+++ b/fern/pages/src/tool-calling/schema-modifiers.mdx
@@ -13,7 +13,7 @@ Schema modifiers are part of Composio SDK's powerful middleware capabilities tha
Schema modifiers transform a tool's schema before the tool is seen by an agent.
<Frame>
- <img src="../../assets/images/schema-modifier.png" alt="Schema Modifier" />
+ <img src="../../../assets/images/schema-modifier.png" alt="Schema Modifier" />
</Frame>
**Useful for:** - Adding arguments to the tool. For example, adding a `thought` argument to the tool
to prompt the agent to explain the reasoning. - Hiding arguments from the tool. In cases where the
diff --git a/fern/pages/src/triggers/using-triggers.mdx b/fern/pages/src/triggers/using-triggers.mdx
index 8e5c5f131..284f3dc5e 100644
--- a/fern/pages/src/triggers/using-triggers.mdx
+++ b/fern/pages/src/triggers/using-triggers.mdx
@@ -11,7 +11,7 @@ Triggers act as a notification system for your AI applications, enabling your ag
When these events take place, triggers capture relevant information and deliver structured payloads directly to your system, facilitating timely and context-aware responses.
<Frame caption="Triggers through Composio" background="subtle">
- ![Triggers Overview](../../assets/images/triggers.png)
+ ![Triggers Overview](../../../assets/images/triggers.png)
</Frame>
<Tip title="Prerequisites">
@@ -24,7 +24,7 @@ When these events take place, triggers capture relevant information and deliver
Head to the any app that supports triggers, eg [Slack](https://app.composio.dev/app/slack) in the dashboard and enable the trigger of choice.
<video
- src="../../assets/videos/enabling-triggers.mp4"
+ src="../../../assets/videos/enabling-triggers.mp4"
width="854"
height="480"
autoplay
@@ -36,7 +36,7 @@ Head to the any app that supports triggers, eg [Slack](https://app.composio.dev/
The [triggers page](https://app.composio.dev/active_triggers?page=1) will show you all the triggers that are enabled for your account.
<Frame caption="Triggers page" background="subtle">
- <img src="../../assets/images/manage-triggers.png" alt="Manage triggers" />
+ <img src="../../../assets/images/manage-triggers.png" alt="Manage triggers" />
</Frame>
You create triggers through the SDK as well.
@@ -122,7 +122,7 @@ print(instance)
To receive trigger events via webhooks, you need to configure a publicly accessible URL where Composio can send the event payloads. This URL should point to an endpoint in your application that can process incoming webhook requests.
<Frame caption="Webhook setup" background="subtle">
- <img src="../../assets/images/setup-webhook.png" alt="Webhook setup" />
+ <img src="../../../assets/images/setup-webhook.png" alt="Webhook setup" />
</Frame>
<CodeGroup>
@@ -203,7 +203,7 @@ The dashboard will show you the trigger configuration to fill in.
<Frame caption="Trigger configuration" background="subtle">
<img
- src="../../assets/images/trigger-config.png"
+ src="../../../assets/images/trigger-config.png"
alt="Trigger configuration"
width="400px"
height="auto"
@@ -281,5 +281,5 @@ If you encounter issues with triggers or webhook listeners, you can use the Comp
Access the trigger logs [here](https://app.composio.dev/trigger_logs).
<Frame caption="Trigger logs" background="subtle">
- <img src="../../assets/images/trigger-debug.png" alt="Trigger logs" />
+ <img src="../../../assets/images/trigger-debug.png" alt="Trigger logs" />
</Frame>
\ No newline at end of file
diff --git a/fern/scripts/build-snippets.ts b/fern/scripts/build-snippets.ts
index 22b76d670..467928127 100644
--- a/fern/scripts/build-snippets.ts
+++ b/fern/scripts/build-snippets.ts
@@ -57,9 +57,23 @@ function getLanguageFromPath(filePath: string): { syntax: string; displayName: s
return languageMap[extension || ''] || { syntax: 'text', displayName: 'Text' };
}
-function readFileLines(filePath: string, startLine?: number, endLine?: number): string {
+function readFileLines(
+ filePath: string,
+ contextDir: string,
+ startLine?: number,
+ endLine?: number
+): string {
try {
- const fullPath = path.resolve(PROJECT_ROOT, filePath);
+ let fullPath: string;
+
+ // If the path starts with './' or '../', resolve it relative to the context directory
+ if (filePath.startsWith('./') || filePath.startsWith('../')) {
+ fullPath = path.resolve(contextDir, filePath);
+ } else {
+ // Otherwise, resolve it relative to the project root
+ fullPath = path.resolve(PROJECT_ROOT, filePath);
+ }
+
const content = fs.readFileSync(fullPath, 'utf8');
const lines = content.split('\n');
@@ -90,7 +104,7 @@ function generateHighlightString(
return `{${relativeStart}-${relativeEnd}}`;
}
-function parseSnippetCodeTags(content: string): string {
+function parseSnippetCodeTags(content: string, contextDir: string): string {
const exampleCodeRegex = /<SnippetCode\s+([^>]*?)(?:\s*\/?>|>\s*<\/SnippetCode>)/g;
return content.replace(exampleCodeRegex, (match, propsString) => {
@@ -129,7 +143,7 @@ function parseSnippetCodeTags(content: string): string {
}
// Read the file content
- const codeContent = readFileLines(props.src, props.startLine, props.endLine);
+ const codeContent = readFileLines(props.src, contextDir, props.startLine, props.endLine);
const langInfo = getLanguageFromPath(props.src);
const syntax = props.language || langInfo.syntax;
const displayName = langInfo.displayName;
@@ -154,7 +168,8 @@ function parseSnippetCodeTags(content: string): string {
function processFile(srcPath: string, distPath: string) {
try {
const content = fs.readFileSync(srcPath, 'utf8');
- const processedContent = parseSnippetCodeTags(content);
+ const contextDir = path.dirname(srcPath);
+ const processedContent = parseSnippetCodeTags(content, contextDir);
// Ensure the directory exists
const distDir = path.dirname(distPath);
@@ -192,13 +207,8 @@ function processAllFiles() {
// Calculate the relative path from the source directory
const relativePath = path.relative(DOCS_SRC_DIR, srcPath);
- // Check if this file is in the SDK directory
- const isInSDK = relativePath.startsWith('sdk/') || relativePath.startsWith('sdk\\');
-
- // If in SDK, preserve directory structure; otherwise flatten
- const distPath = isInSDK
- ? path.join(PAGES_DIST_DIR, relativePath)
- : path.join(PAGES_DIST_DIR, entry.name);
+ // Always preserve directory structure
+ const distPath = path.join(PAGES_DIST_DIR, relativePath);
processFile(srcPath, distPath);
}
@@ -219,13 +229,8 @@ function startWatchMode() {
const srcPath = path.join(DOCS_SRC_DIR, filename);
- // Check if this file is in the SDK directory
- const isInSDK = filename.startsWith('sdk/') || filename.startsWith('sdk\\');
-
- // If in SDK, preserve directory structure; otherwise flatten
- const distPath = isInSDK
- ? path.join(PAGES_DIST_DIR, filename)
- : path.join(PAGES_DIST_DIR, path.basename(filename));
+ // Always preserve directory structure
+ const distPath = path.join(PAGES_DIST_DIR, filename);
if (eventType === 'change' && fs.existsSync(srcPath)) {
console.log(`🔄 File changed: ${filename}`);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index aff3b9df9..6b74ffb06 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -89,7 +89,7 @@ importers:
version: 1.9.7
composio-core:
specifier: ^0.5.39
hono:
specifier: ^4.7.11
version: 4.7.11
@@ -99,6 +99,9 @@ importers:
only-allow:
specifier: ^1.2.1
version: 1.2.1
+ openai:
+ specifier: ^4.94.0
react:
specifier: ^18.3.1
version: 18.3.1
@@ -7003,14 +7006,14 @@ snapshots:
transitivePeerDependencies:
- openai
dependencies:
'@cfworker/json-schema': 4.1.1
ansi-styles: 5.2.0
camelcase: 6.3.0
decamelize: 1.2.0
js-tiktoken: 1.0.20
mustache: 4.2.0
p-queue: 6.6.2
p-retry: 4.6.2
@@ -7074,9 +7077,9 @@ snapshots:
- encoding
- ws
dependencies:
js-tiktoken: 1.0.20
zod: 3.25.32
@@ -7084,9 +7087,9 @@ snapshots:
- encoding
- ws
dependencies:
js-tiktoken: 1.0.20
'@manypkg/[email protected]':
@@ -8824,7 +8827,7 @@ snapshots:
sirv: 3.0.1
tinyglobby: 0.2.14
tinyrainbow: 2.0.0
'@vitest/[email protected]':
dependencies:
@@ -9165,23 +9168,23 @@ snapshots:
has-own-prop: 2.0.0
repeat-string: 1.6.1
dependencies:
'@ai-sdk/openai': 1.3.22([email protected])
'@cloudflare/workers-types': 4.20250612.0
'@composio/mcp': 1.0.3-0
'@hey-api/client-axios': 0.2.12([email protected])
axios: 1.10.0
chalk: 4.1.2
cli-progress: 3.12.0
commander: 12.1.0
inquirer: 10.2.2
open: 8.4.2
pusher-js: 8.4.0-rc2
resolve-package-path: 4.0.3
uuid: 10.0.0
@@ -10086,15 +10089,15 @@ snapshots:
dependencies:
- '@langchain/textsplitters': 0.1.0(@langchain/[email protected]([email protected]([email protected])([email protected])))
+ '@langchain/textsplitters': 0.1.0(@langchain/[email protected]([email protected]([email protected])([email protected])))
js-tiktoken: 1.0.20
js-yaml: 4.1.0
jsonpointer: 5.0.1
openapi-types: 12.1.3
p-retry: 4.6.2
uuid: 10.0.0
@@ -10119,7 +10122,7 @@ snapshots:
optionalDependencies:
dependencies:
'@types/uuid': 10.0.0
chalk: 4.1.2
@@ -10129,7 +10132,7 @@ snapshots:
semver: 7.7.2
uuid: 10.0.0
optionalDependencies:
dependencies: