chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { db } from '@sim/db'
|
||||
import { docsEmbeddings } from '@sim/db/schema'
|
||||
|
||||
export { db, docsEmbeddings }
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Generate embeddings for search queries using OpenAI API
|
||||
*/
|
||||
export async function generateSearchEmbedding(query: string): Promise<number[]> {
|
||||
const apiKey = process.env.OPENAI_API_KEY
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error('OPENAI_API_KEY environment variable is required')
|
||||
}
|
||||
|
||||
const response = await fetch('https://api.openai.com/v1/embeddings', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
input: query,
|
||||
model: 'text-embedding-3-small',
|
||||
encoding_format: 'float',
|
||||
}),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
throw new Error(`OpenAI API failed: ${response.status} ${response.statusText} - ${errorText}`)
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (!data?.data || !Array.isArray(data.data) || data.data.length === 0) {
|
||||
throw new Error('OpenAI API returned invalid response structure: missing or empty data array')
|
||||
}
|
||||
|
||||
if (!data.data[0]?.embedding || !Array.isArray(data.data[0].embedding)) {
|
||||
throw new Error('OpenAI API returned invalid response structure: missing or invalid embedding')
|
||||
}
|
||||
|
||||
return data.data[0].embedding
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineI18n } from 'fumadocs-core/i18n'
|
||||
|
||||
export const i18n = defineI18n({
|
||||
defaultLanguage: 'en',
|
||||
languages: ['en', 'es', 'fr', 'de', 'ja', 'zh'],
|
||||
hideLocale: 'default-locale',
|
||||
parser: 'dir',
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
export function serializeJsonLd(value: unknown): string {
|
||||
return JSON.stringify(value).replace(/</g, '\\u003c')
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { InferPageType } from 'fumadocs-core/source'
|
||||
import type { PageData, source } from '@/lib/source'
|
||||
|
||||
export async function getLLMText(page: InferPageType<typeof source>) {
|
||||
const data = page.data as unknown as PageData
|
||||
if (typeof data.getText !== 'function') return ''
|
||||
const processed = await data.getText('processed')
|
||||
return `# ${data.title} (${page.url})
|
||||
|
||||
${processed}`
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { createOpenAPI } from 'fumadocs-openapi/server'
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
input: ['./openapi.json'],
|
||||
})
|
||||
|
||||
interface OpenAPIOperation {
|
||||
path: string
|
||||
method: string
|
||||
}
|
||||
|
||||
function resolveRef(ref: string, spec: Record<string, unknown>): unknown {
|
||||
const parts = ref.replace('#/', '').split('/')
|
||||
let current: unknown = spec
|
||||
for (const part of parts) {
|
||||
if (current && typeof current === 'object') {
|
||||
current = (current as Record<string, unknown>)[part]
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
function resolveRefs(obj: unknown, spec: Record<string, unknown>, depth = 0): unknown {
|
||||
if (depth > 10) return obj
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item) => resolveRefs(item, spec, depth + 1))
|
||||
}
|
||||
if (obj && typeof obj === 'object') {
|
||||
const record = obj as Record<string, unknown>
|
||||
if ('$ref' in record && typeof record.$ref === 'string') {
|
||||
const resolved = resolveRef(record.$ref, spec)
|
||||
return resolveRefs(resolved, spec, depth + 1)
|
||||
}
|
||||
const result: Record<string, unknown> = {}
|
||||
for (const [key, value] of Object.entries(record)) {
|
||||
result[key] = resolveRefs(value, spec, depth + 1)
|
||||
}
|
||||
return result
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
function formatSchema(schema: unknown): string {
|
||||
return JSON.stringify(schema, null, 2)
|
||||
}
|
||||
|
||||
let cachedSpec: Record<string, unknown> | null = null
|
||||
|
||||
function getSpec(): Record<string, unknown> {
|
||||
if (!cachedSpec) {
|
||||
const specPath = join(process.cwd(), 'openapi.json')
|
||||
cachedSpec = JSON.parse(readFileSync(specPath, 'utf8')) as Record<string, unknown>
|
||||
}
|
||||
return cachedSpec
|
||||
}
|
||||
|
||||
export function getApiSpecContent(
|
||||
title: string,
|
||||
description: string | undefined,
|
||||
operations: OpenAPIOperation[]
|
||||
): string {
|
||||
const spec = getSpec()
|
||||
|
||||
if (!operations || operations.length === 0) {
|
||||
return `# ${title}\n\n${description || ''}`
|
||||
}
|
||||
|
||||
const op = operations[0]
|
||||
const method = op.method.toUpperCase()
|
||||
const pathObj = (spec.paths as Record<string, Record<string, unknown>>)?.[op.path]
|
||||
const operation = pathObj?.[op.method.toLowerCase()] as Record<string, unknown> | undefined
|
||||
|
||||
if (!operation) {
|
||||
return `# ${title}\n\n${description || ''}`
|
||||
}
|
||||
|
||||
const resolved = resolveRefs(operation, spec) as Record<string, unknown>
|
||||
const lines: string[] = []
|
||||
|
||||
lines.push(`# ${title}`)
|
||||
lines.push(`\`${method} ${op.path}\``)
|
||||
|
||||
if (resolved.description) {
|
||||
lines.push(`## Description\n${resolved.description}`)
|
||||
}
|
||||
|
||||
const parameters = resolved.parameters as Array<Record<string, unknown>> | undefined
|
||||
if (parameters && parameters.length > 0) {
|
||||
lines.push('## Parameters')
|
||||
for (const param of parameters) {
|
||||
const required = param.required ? ' (required)' : ''
|
||||
const schemaType = param.schema
|
||||
? ` — \`${(param.schema as Record<string, unknown>).type || 'string'}\``
|
||||
: ''
|
||||
lines.push(
|
||||
`- **${param.name}** (${param.in})${required}${schemaType}: ${param.description || ''}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const requestBody = resolved.requestBody as Record<string, unknown> | undefined
|
||||
if (requestBody) {
|
||||
lines.push('## Request Body')
|
||||
if (requestBody.description) {
|
||||
lines.push(String(requestBody.description))
|
||||
}
|
||||
const content = requestBody.content as Record<string, Record<string, unknown>> | undefined
|
||||
const jsonContent = content?.['application/json']
|
||||
if (jsonContent?.schema) {
|
||||
lines.push(`\`\`\`json\n${formatSchema(jsonContent.schema)}\n\`\`\``)
|
||||
}
|
||||
}
|
||||
|
||||
const responses = resolved.responses as Record<string, Record<string, unknown>> | undefined
|
||||
if (responses) {
|
||||
lines.push('## Responses')
|
||||
for (const [status, response] of Object.entries(responses)) {
|
||||
lines.push(`### ${status} — ${response.description || ''}`)
|
||||
const content = response.content as Record<string, Record<string, unknown>> | undefined
|
||||
const jsonContent = content?.['application/json']
|
||||
if (jsonContent?.schema) {
|
||||
lines.push(`\`\`\`json\n${formatSchema(jsonContent.schema)}\n\`\`\``)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n\n')
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import { createElement, Fragment } from 'react'
|
||||
import { loader, multiple } from 'fumadocs-core/source'
|
||||
import type { DocData, DocMethods } from 'fumadocs-mdx/runtime/types'
|
||||
import { openapiSource } from 'fumadocs-openapi/server'
|
||||
import { docs } from '@/.source/server'
|
||||
import { i18n } from './i18n'
|
||||
import { openapi } from './openapi'
|
||||
|
||||
const METHOD_COLORS: Record<string, string> = {
|
||||
GET: 'text-green-600 dark:text-green-400',
|
||||
HEAD: 'text-green-600 dark:text-green-400',
|
||||
OPTIONS: 'text-green-600 dark:text-green-400',
|
||||
POST: 'text-blue-600 dark:text-blue-400',
|
||||
PUT: 'text-yellow-600 dark:text-yellow-400',
|
||||
PATCH: 'text-orange-600 dark:text-orange-400',
|
||||
DELETE: 'text-red-600 dark:text-red-400',
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom openapi plugin that places method badges BEFORE the page name
|
||||
* in the sidebar (like Mintlify/Gumloop) instead of after.
|
||||
*/
|
||||
function openapiPluginBadgeLeft() {
|
||||
return {
|
||||
name: 'fumadocs:openapi-badge-left',
|
||||
enforce: 'pre' as const,
|
||||
transformPageTree: {
|
||||
file(
|
||||
this: {
|
||||
storage: {
|
||||
read: (path: string) => { format: string; data: Record<string, unknown> } | undefined
|
||||
}
|
||||
},
|
||||
node: { name: React.ReactNode },
|
||||
filePath: string | undefined
|
||||
) {
|
||||
if (!filePath) return node
|
||||
const file = this.storage.read(filePath)
|
||||
if (!file || file.format !== 'page') return node
|
||||
const openApiData = file.data._openapi as { method?: string; webhook?: boolean } | undefined
|
||||
if (!openApiData || typeof openApiData !== 'object') return node
|
||||
if (openApiData.webhook) {
|
||||
node.name = createElement(
|
||||
Fragment,
|
||||
null,
|
||||
node.name,
|
||||
' ',
|
||||
createElement(
|
||||
'span',
|
||||
{
|
||||
className:
|
||||
'ms-auto border border-current px-1 rounded-lg text-xs text-nowrap font-mono',
|
||||
},
|
||||
'Webhook'
|
||||
)
|
||||
)
|
||||
} else if (openApiData.method) {
|
||||
const method = openApiData.method.toUpperCase()
|
||||
const colorClass = METHOD_COLORS[method] ?? METHOD_COLORS.GET
|
||||
node.name = createElement(
|
||||
Fragment,
|
||||
null,
|
||||
createElement(
|
||||
'span',
|
||||
{
|
||||
className: `font-mono font-medium me-1.5 text-[10px] text-nowrap ${colorClass}`,
|
||||
'data-method': method.toLowerCase(),
|
||||
},
|
||||
method
|
||||
),
|
||||
node.name
|
||||
)
|
||||
}
|
||||
return node
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const source = loader(
|
||||
multiple({
|
||||
docs: docs.toFumadocsSource(),
|
||||
openapi: await openapiSource(openapi, {
|
||||
baseDir: 'en/api-reference/(generated)',
|
||||
groupBy: 'tag',
|
||||
}),
|
||||
}),
|
||||
{
|
||||
baseUrl: '/',
|
||||
i18n,
|
||||
plugins: [openapiPluginBadgeLeft() as never],
|
||||
}
|
||||
)
|
||||
|
||||
/** Diátaxis page type surfaced as a badge near the page title. */
|
||||
export type DocsPageType = 'tutorial' | 'guide' | 'reference' | 'concept'
|
||||
|
||||
/** Full page data type including MDX content and metadata */
|
||||
export type PageData = DocData &
|
||||
DocMethods & {
|
||||
title: string
|
||||
description?: string
|
||||
full?: boolean
|
||||
pageType?: DocsPageType
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export const DOCS_BASE_URL = process.env.NEXT_PUBLIC_DOCS_URL ?? 'https://docs.sim.ai'
|
||||
/**
|
||||
* The public marketing site's fixed canonical origin — not `NEXT_PUBLIC_APP_URL`.
|
||||
* That env var reflects wherever *this* deployment (self-hosted or otherwise)
|
||||
* happens to run, but the footer's marketing links (`/blog`, `/enterprise`,
|
||||
* `/models`, `/terms`, `/privacy`, …) only ever exist on sim.ai itself, so
|
||||
* they must stay hardcoded to it regardless of where docs is hosted.
|
||||
*/
|
||||
export const SIM_SITE_URL = 'https://sim.ai'
|
||||
@@ -0,0 +1,26 @@
|
||||
import { type ClassValue, clsx } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
/**
|
||||
* Combines multiple class names into a single string, merging Tailwind classes properly
|
||||
*/
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full URL for an asset stored in Vercel Blob
|
||||
* - If CDN is configured (NEXT_PUBLIC_BLOB_BASE_URL), uses CDN URL
|
||||
* - Otherwise falls back to local static assets served from root path
|
||||
*/
|
||||
export function getAssetUrl(filename: string) {
|
||||
// Absolute URLs (e.g. blob-hosted academy videos) are already complete.
|
||||
if (/^https?:\/\//.test(filename)) {
|
||||
return filename
|
||||
}
|
||||
const cdnBaseUrl = process.env.NEXT_PUBLIC_BLOB_BASE_URL
|
||||
if (cdnBaseUrl) {
|
||||
return `${cdnBaseUrl}/${filename}`
|
||||
}
|
||||
return `/${filename}`
|
||||
}
|
||||
Reference in New Issue
Block a user