d25d482dc2
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) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
154 lines
5.3 KiB
TypeScript
154 lines
5.3 KiB
TypeScript
import { ApiIcon } from '@/components/icons'
|
|
import type { BlockConfig } from '@/blocks/types'
|
|
import { IntegrationType } from '@/blocks/types'
|
|
import type { RequestResponse } from '@/tools/http/types'
|
|
|
|
export const ApiBlock: BlockConfig<RequestResponse> = {
|
|
type: 'api',
|
|
name: 'API',
|
|
description: 'Use any API',
|
|
longDescription:
|
|
'This is a core workflow block. Connect to any external API with support for all standard HTTP methods and customizable request parameters. Configure headers, query parameters, and request bodies. Standard headers (User-Agent, Accept, Cache-Control, etc.) are automatically included.',
|
|
docsLink: 'https://docs.sim.ai/workflows/blocks/api',
|
|
bestPractices: `
|
|
- Curl the endpoint yourself before filling out the API block to make sure it's working IF you have the necessary authentication headers. Clarify with the user if you need any additional headers.
|
|
`,
|
|
category: 'blocks',
|
|
integrationType: IntegrationType.DevOps,
|
|
bgColor: '#2F55FF',
|
|
icon: ApiIcon,
|
|
subBlocks: [
|
|
{
|
|
id: 'url',
|
|
title: 'URL',
|
|
type: 'short-input',
|
|
placeholder: 'Enter URL',
|
|
required: true,
|
|
},
|
|
{
|
|
id: 'method',
|
|
title: 'Method',
|
|
type: 'dropdown',
|
|
required: true,
|
|
options: [
|
|
{ label: 'GET', id: 'GET' },
|
|
{ label: 'POST', id: 'POST' },
|
|
{ label: 'PUT', id: 'PUT' },
|
|
{ label: 'DELETE', id: 'DELETE' },
|
|
{ label: 'PATCH', id: 'PATCH' },
|
|
],
|
|
},
|
|
{
|
|
id: 'params',
|
|
title: 'Query Params',
|
|
type: 'table',
|
|
columns: ['Key', 'Value'],
|
|
},
|
|
{
|
|
id: 'headers',
|
|
title: 'Headers',
|
|
type: 'table',
|
|
columns: ['Key', 'Value'],
|
|
description:
|
|
'Custom headers (standard headers like User-Agent, Accept, etc. are added automatically)',
|
|
},
|
|
{
|
|
id: 'body',
|
|
title: 'Body',
|
|
type: 'code',
|
|
placeholder: 'Enter JSON...',
|
|
wandConfig: {
|
|
enabled: true,
|
|
maintainHistory: true,
|
|
prompt: `You are an expert JSON programmer.
|
|
Generate ONLY the raw JSON object based on the user's request.
|
|
The output MUST be a single, valid JSON object, starting with { and ending with }.
|
|
|
|
Current body: {context}
|
|
|
|
Do not include any explanations, markdown formatting, or other text outside the JSON object.
|
|
|
|
You have access to the following variables you can use to generate the JSON body:
|
|
- 'params' (object): Contains input parameters derived from the JSON schema. Access these directly using the parameter name wrapped in angle brackets, e.g., '<paramName>'. Do NOT use 'params.paramName'.
|
|
- 'environmentVariables' (object): Contains environment variables. Reference these using the double curly brace syntax: '{{ENV_VAR_NAME}}'. Do NOT use 'environmentVariables.VAR_NAME' or env.
|
|
|
|
Example:
|
|
{
|
|
"name": "<block.agent.response.content>",
|
|
"age": <block.function.output.age>,
|
|
"success": true
|
|
}`,
|
|
placeholder: 'Describe the API request body you need...',
|
|
generationType: 'json-object',
|
|
},
|
|
},
|
|
{
|
|
id: 'timeout',
|
|
title: 'Timeout (ms)',
|
|
type: 'short-input',
|
|
placeholder: '300000',
|
|
description:
|
|
'Request timeout in milliseconds (default: 300000 = 5 minutes, max: 600000 = 10 minutes)',
|
|
mode: 'advanced',
|
|
},
|
|
{
|
|
id: 'retries',
|
|
title: 'Retries',
|
|
type: 'short-input',
|
|
placeholder: '0',
|
|
description:
|
|
'Number of retry attempts for timeouts, 429 responses, and 5xx errors (default: 0, no retries)',
|
|
mode: 'advanced',
|
|
},
|
|
{
|
|
id: 'retryDelayMs',
|
|
title: 'Retry delay (ms)',
|
|
type: 'short-input',
|
|
placeholder: '500',
|
|
description: 'Initial retry delay in milliseconds (exponential backoff)',
|
|
mode: 'advanced',
|
|
},
|
|
{
|
|
id: 'retryMaxDelayMs',
|
|
title: 'Max retry delay (ms)',
|
|
type: 'short-input',
|
|
placeholder: '30000',
|
|
description: 'Maximum delay between retries in milliseconds',
|
|
mode: 'advanced',
|
|
},
|
|
{
|
|
id: 'retryNonIdempotent',
|
|
title: 'Retry non-idempotent methods',
|
|
type: 'switch',
|
|
description: 'Allow retries for POST/PATCH requests (may create duplicate requests)',
|
|
mode: 'advanced',
|
|
},
|
|
],
|
|
tools: {
|
|
access: ['http_request'],
|
|
},
|
|
inputs: {
|
|
url: { type: 'string', description: 'Request URL' },
|
|
method: { type: 'string', description: 'HTTP method' },
|
|
headers: { type: 'json', description: 'Request headers' },
|
|
body: { type: 'json', description: 'Request body data' },
|
|
params: { type: 'json', description: 'URL query parameters' },
|
|
timeout: { type: 'number', description: 'Request timeout in milliseconds' },
|
|
retries: { type: 'number', description: 'Number of retry attempts for retryable failures' },
|
|
retryDelayMs: { type: 'number', description: 'Initial retry delay in milliseconds' },
|
|
retryMaxDelayMs: {
|
|
type: 'number',
|
|
description: 'Maximum delay between retries in milliseconds',
|
|
},
|
|
retryNonIdempotent: {
|
|
type: 'boolean',
|
|
description: 'Allow retries for non-idempotent methods like POST/PATCH',
|
|
},
|
|
},
|
|
outputs: {
|
|
data: { type: 'json', description: 'API response data (JSON, text, or other formats)' },
|
|
status: { type: 'number', description: 'HTTP status code (200, 404, 500, etc.)' },
|
|
headers: { type: 'json', description: 'HTTP response headers as key-value pairs' },
|
|
},
|
|
}
|