Skip to content

Commit 9751c9f

Browse files
v0.4.20: internal request, kb url fixes, docs styling
2 parents 641e353 + e6ba323 commit 9751c9f

File tree

14 files changed

+103
-9
lines changed

14 files changed

+103
-9
lines changed

apps/docs/components/docs-layout/sidebar-components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function SidebarFolder({
9797
<div
9898
className={cn(
9999
'overflow-hidden transition-all duration-200 ease-in-out',
100-
open ? 'max-h-[2000px] opacity-100' : 'max-h-0 opacity-0'
100+
open ? 'max-h-[10000px] opacity-100' : 'max-h-0 opacity-0'
101101
)}
102102
>
103103
<ul className='mt-0.5 ml-2 space-y-[0.0625rem] border-gray-200/60 border-l pl-2.5 dark:border-gray-700/60'>

apps/docs/components/navbar/navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function Navbar() {
3939
</div>
4040

4141
{/* Center cluster: search */}
42-
<div className='flex flex-1 items-center justify-center'>
42+
<div className='flex flex-1 items-center justify-center pl-32'>
4343
<SearchTrigger />
4444
</div>
4545

apps/docs/components/ui/search-trigger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function SearchTrigger() {
1515
return (
1616
<button
1717
type='button'
18-
className='flex h-10 w-[500px] items-center gap-2 rounded-xl border border-border/50 px-3 py-2 text-sm backdrop-blur-xl transition-colors hover:border-border'
18+
className='flex h-10 w-[460px] items-center gap-2 rounded-xl border border-border/50 px-3 py-2 text-sm backdrop-blur-xl transition-colors hover:border-border'
1919
style={{
2020
backgroundColor: 'hsla(0, 0%, 5%, 0.85)',
2121
backdropFilter: 'blur(33px) saturate(180%)',

apps/sim/lib/knowledge/documents/document-processor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,16 @@ async function parseWithMistralOCR(fileUrl: string, filename: string, mimeType:
407407
try {
408408
const response = await retryWithExponentialBackoff(
409409
async () => {
410-
const url =
410+
let url =
411411
typeof mistralParserTool.request!.url === 'function'
412412
? mistralParserTool.request!.url(params)
413413
: mistralParserTool.request!.url
414414

415+
if (url.startsWith('/')) {
416+
const { getBaseUrl } = await import('@/lib/urls/utils')
417+
url = `${getBaseUrl()}${url}`
418+
}
419+
415420
const headers =
416421
typeof mistralParserTool.request!.headers === 'function'
417422
? mistralParserTool.request!.headers(params)

apps/sim/tools/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export async function executeTool(
227227
const isInternalRoute = endpointUrl.startsWith('/api/')
228228

229229
if (isInternalRoute || skipProxy) {
230-
const result = await handleInternalRequest(toolId, tool, contextParams)
230+
const result = await handleInternalRequest(toolId, tool, contextParams, executionContext)
231231

232232
// Apply post-processing if available and not skipped
233233
let finalResult = result
@@ -414,7 +414,8 @@ function isErrorResponse(
414414
async function handleInternalRequest(
415415
toolId: string,
416416
tool: ToolConfig,
417-
params: Record<string, any>
417+
params: Record<string, any>,
418+
executionContext?: ExecutionContext
418419
): Promise<ToolResponse> {
419420
const requestId = generateRequestId()
420421

@@ -427,7 +428,11 @@ async function handleInternalRequest(
427428
const endpointUrl =
428429
typeof tool.request.url === 'function' ? tool.request.url(params) : tool.request.url
429430

430-
const fullUrl = new URL(endpointUrl, baseUrl).toString()
431+
const fullUrlObj = new URL(endpointUrl, baseUrl)
432+
if (executionContext?.workflowId && typeof window === 'undefined') {
433+
fullUrlObj.searchParams.set('workflowId', executionContext.workflowId)
434+
}
435+
const fullUrl = fullUrlObj.toString()
431436

432437
// For custom tools, validate parameters on the client side before sending
433438
if (toolId.startsWith('custom_') && tool.request.body) {
@@ -445,10 +450,21 @@ async function handleInternalRequest(
445450
}
446451
}
447452

453+
const headers = new Headers(requestParams.headers)
454+
if (typeof window === 'undefined') {
455+
try {
456+
const internalToken = await generateInternalToken()
457+
headers.set('Authorization', `Bearer ${internalToken}`)
458+
logger.info(`[${requestId}] Added internal auth token for ${toolId}`)
459+
} catch (error) {
460+
logger.error(`[${requestId}] Failed to generate internal token for ${toolId}:`, error)
461+
}
462+
}
463+
448464
// Prepare request options
449465
const requestOptions = {
450466
method: requestParams.method,
451-
headers: new Headers(requestParams.headers),
467+
headers: headers,
452468
body: requestParams.body,
453469
}
454470

helm/sim/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,18 +629,30 @@ helm uninstall sim
629629

630630
For production deployments, make sure to:
631631

632-
1. **Change default secrets**: Update `BETTER_AUTH_SECRET` and `ENCRYPTION_KEY` with secure, randomly generated values
632+
1. **Change default secrets**: Update `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, and `INTERNAL_API_SECRET` with secure, randomly generated values using `openssl rand -hex 32`
633633
2. **Use strong database passwords**: Set `postgresql.auth.password` to a strong password
634634
3. **Enable TLS**: Configure `postgresql.tls.enabled=true` and provide proper certificates
635635
4. **Configure ingress TLS**: Enable HTTPS with proper SSL certificates
636636

637+
**Required Secrets:**
638+
- `BETTER_AUTH_SECRET`: Authentication JWT signing (minimum 32 characters)
639+
- `ENCRYPTION_KEY`: Encrypts sensitive data like environment variables (minimum 32 characters)
640+
- `INTERNAL_API_SECRET`: Internal service-to-service authentication (minimum 32 characters)
641+
642+
**Optional Security (Recommended for Production):**
643+
- `CRON_SECRET`: Authenticates scheduled job requests to API endpoints (required only if `cronjobs.enabled=true`)
644+
- `API_ENCRYPTION_KEY`: Encrypts API keys at rest in database (must be exactly 64 hex characters). If not set, API keys are stored in plain text. Generate using: `openssl rand -hex 32` (outputs 64 hex chars representing 32 bytes)
645+
637646
### Example secure values:
638647

639648
```yaml
640649
app:
641650
env:
642651
BETTER_AUTH_SECRET: "your-secure-random-string-here"
643652
ENCRYPTION_KEY: "your-secure-encryption-key-here"
653+
INTERNAL_API_SECRET: "your-secure-internal-api-secret-here"
654+
CRON_SECRET: "your-secure-cron-secret-here"
655+
API_ENCRYPTION_KEY: "your-64-char-hex-string-for-api-key-encryption" # Optional but recommended
644656

645657
postgresql:
646658
auth:

helm/sim/examples/values-aws.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ app:
3232
NEXT_PUBLIC_SOCKET_URL: "https://simstudio-ws.acme.com"
3333

3434
# Security settings (REQUIRED - replace with your own secure secrets)
35+
# Generate using: openssl rand -hex 32
3536
BETTER_AUTH_SECRET: "your-secure-production-auth-secret-here"
3637
ENCRYPTION_KEY: "your-secure-production-encryption-key-here"
38+
INTERNAL_API_SECRET: "your-secure-production-internal-api-secret-here"
39+
CRON_SECRET: "your-secure-production-cron-secret-here"
40+
41+
# Optional: API Key Encryption (RECOMMENDED for production)
42+
# Generate 64-character hex string using: openssl rand -hex 32
43+
API_ENCRYPTION_KEY: "your-64-char-hex-api-encryption-key-here" # Optional but recommended
3744

3845
NODE_ENV: "production"
3946
NEXT_TELEMETRY_DISABLED: "1"

helm/sim/examples/values-azure.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ app:
3030
NEXT_PUBLIC_SOCKET_URL: "https://simstudio-ws.acme.com"
3131

3232
# Security settings (REQUIRED - replace with your own secure secrets)
33+
# Generate using: openssl rand -hex 32
3334
BETTER_AUTH_SECRET: "your-secure-production-auth-secret-here"
3435
ENCRYPTION_KEY: "your-secure-production-encryption-key-here"
36+
INTERNAL_API_SECRET: "your-secure-production-internal-api-secret-here"
37+
CRON_SECRET: "your-secure-production-cron-secret-here"
38+
39+
# Optional: API Key Encryption (RECOMMENDED for production)
40+
# Generate 64-character hex string using: openssl rand -hex 32
41+
API_ENCRYPTION_KEY: "your-64-char-hex-api-encryption-key-here" # Optional but recommended
3542

3643
NODE_ENV: "production"
3744
NEXT_TELEMETRY_DISABLED: "1"

helm/sim/examples/values-development.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ app:
2626
NEXT_PUBLIC_SOCKET_URL: "http://localhost:3002"
2727

2828
# Example secrets for development (replace with secure values for production)
29+
# For production, generate using: openssl rand -hex 32
2930
BETTER_AUTH_SECRET: "dev-32-char-auth-secret-not-secure-dev"
3031
ENCRYPTION_KEY: "dev-32-char-encryption-key-not-secure"
32+
INTERNAL_API_SECRET: "dev-32-char-internal-secret-not-secure"
33+
CRON_SECRET: "dev-32-char-cron-secret-not-for-prod"
34+
35+
# Optional: API Key Encryption (leave empty for dev, encrypts API keys at rest)
36+
# For production, generate 64-char hex using: openssl rand -hex 32
37+
API_ENCRYPTION_KEY: "" # Optional - if not set, API keys stored in plain text
3138

3239
# Realtime service
3340
realtime:

helm/sim/examples/values-external-db.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ app:
2626
NEXT_PUBLIC_SOCKET_URL: "https://simstudio-ws.acme.com"
2727

2828
# Security settings (REQUIRED - replace with your own secure secrets)
29+
# Generate using: openssl rand -hex 32
2930
BETTER_AUTH_SECRET: "" # Set via --set flag or external secret manager
3031
ENCRYPTION_KEY: "" # Set via --set flag or external secret manager
32+
INTERNAL_API_SECRET: "" # Set via --set flag or external secret manager
33+
CRON_SECRET: "" # Set via --set flag or external secret manager
34+
35+
# Optional: API Key Encryption (RECOMMENDED for production)
36+
# Generate 64-character hex string using: openssl rand -hex 32
37+
API_ENCRYPTION_KEY: "" # Optional but recommended - encrypts API keys at rest
3138

3239
NODE_ENV: "production"
3340
NEXT_TELEMETRY_DISABLED: "1"
@@ -150,4 +157,7 @@ networkPolicy:
150157
# --set externalDatabase.database="your-db-name" \
151158
# --set app.env.BETTER_AUTH_SECRET="$(openssl rand -hex 32)" \
152159
# --set app.env.ENCRYPTION_KEY="$(openssl rand -hex 32)" \
160+
# --set app.env.INTERNAL_API_SECRET="$(openssl rand -hex 32)" \
161+
# --set app.env.CRON_SECRET="$(openssl rand -hex 32)" \
162+
# --set app.env.API_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
153163
# --set realtime.env.BETTER_AUTH_SECRET="$(openssl rand -hex 32)"

0 commit comments

Comments
 (0)