superglue
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesesuperglue CLI (sg
) — Agent Reference
sgsuperglue CLI(sg
)—— Agent参考文档
sgCRITICAL RULES — READ FIRST
重要规则 — 请先阅读
Pre-requisites for using the CLI
- Check CLI exists: Run . If it fails with
sg --version, install it:command not foundnpm install -g @superglue/cli - Check superglue CLI config exists: Run . If it fails with
sg system listor auth errors, the CLI needs configuration viafetch failed(see below).sg init
Calling systems and running tools
- ALWAYS make sure you pull the relevant system context using before calling system endpoints and running inline JSON tools or building new tools.
sg system find - Use to do a targeted keyword search of system docs if you're unsure about how a system works.
sg system search-docs
Authentication & Credentials:
- Auth headers MUST be set explicitly — credentials are NEVER auto-injected into requests or tool steps
- Every request step (in tools AND ) must include the appropriate auth header using
sg system callsyntax<<systemId_credentialKey>> - OAuth systems also require explicit headers — only token refresh is automatic
Saving Tools:
- Don't save a tool without explicit user confirmation — always ask "Should I save this tool?" first
- After +
sg tool build, present results to the user and wait for approvalsg tool run - Only run after the user explicitly confirms
sg tool save --draft <id>
Credentials in Non-Interactive Environments (AI Agents, CI):
- Pass ALL credentials (including secrets) directly via JSON — do NOT use
--credentials(it requires an interactive TTY which agents don't have)--sensitive-credentials - Ask the user to provide secret values, then pass them in
--credentials '{"api_key":"sk-xxx"}'
使用CLI的前提条件
- 检查CLI是否存在:运行。如果提示
sg --version,则进行安装:command not foundnpm install -g @superglue/cli - 检查superglue CLI配置是否存在:运行。如果提示
sg system list或认证错误,则需要通过fetch failed配置CLI(见下文)。sg init
调用系统与运行工具
- 在调用系统端点、运行内联JSON工具或构建新工具之前,务必使用获取相关系统上下文。
sg system find - 如果你不确定系统的工作方式,请使用对系统文档进行针对性关键词搜索。
sg system search-docs
认证与凭证:
- 必须显式设置认证头 — 凭证绝不会自动注入到请求或工具步骤中
- 每个请求步骤(工具和中)都必须使用
sg system call语法包含适当的认证头<<systemId_credentialKey>> - OAuth系统也需要显式设置头 — 仅令牌刷新是自动的
保存工具:
- 未经用户明确确认,请勿保存工具 — 务必先询问“是否需要我保存此工具?”
- 在执行+
sg tool build后,将结果呈现给用户并等待批准sg tool run - 仅在用户明确确认后,再运行
sg tool save --draft <id>
非交互式环境中的凭证(AI Agent、CI):
- 通过JSON直接传递所有凭证(包括密钥) — 请勿使用
--credentials(它需要交互式TTY,而Agent不具备此环境)--sensitive-credentials - 请用户提供密钥值,然后通过传递
--credentials '{"api_key":"sk-xxx"}'
Installation & Setup
安装与设置
Installing the CLI
安装CLI
bash
npm install -g @superglue/cliAfter installation, the command is available globally.
sgbash
npm install -g @superglue/cli安装完成后,命令将在全局可用。
sgInitialization (REQUIRED before first use)
初始化(首次使用前必须完成)
The CLI will not work until configured with an API key. The endpoint defaults to if not specified.
https://api.superglue.cloudOption A: Interactive setup (recommended for humans)
bash
sg initThis prompts for:
- API Key (required) — get one at https://app.superglue.cloud/admin?view=api-keys
- API Endpoint — defaults to
https://api.superglue.cloud - Web Endpoint — for OAuth callbacks, auto-derived from API endpoint
- Output mode — (default) or
stdoutstdout+file - Config location — project-local () or global (
.superglue/config.json)~/.superglue/config.json
It verifies the connection before saving. On success it creates the config file, a directory, and updates if using local config.
drafts/.gitignoreOption B: Environment variables (recommended for CI and AI agents)
If is not practical (non-interactive environments, CI, AI agents), set these env vars instead:
sg initbash
export SUPERGLUE_API_KEY="your-api-key"
export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # optional, this is the defaultWith these set, all commands work without a config file.
sgOption C: CLI flags (per-command override)
bash
sg system list --api-key "your-key" --endpoint "https://api.superglue.cloud"在配置API密钥之前,CLI无法正常工作。如果未指定端点,默认值为。
https://api.superglue.cloud选项A:交互式设置(推荐人类用户使用)
bash
sg init此命令会提示你输入:
- API密钥(必填) — 可在https://app.superglue.cloud/admin?view=api-keys获取
- API端点 — 默认值为
https://api.superglue.cloud - Web端点 — 用于OAuth回调,从API端点自动派生
- 输出模式 — (默认)或
stdoutstdout+file - 配置位置 — 项目本地()或全局(
.superglue/config.json)~/.superglue/config.json
在保存配置之前,它会验证连接是否正常。成功后,将创建配置文件、目录,如果使用本地配置,还会更新。
drafts/.gitignore选项B:环境变量(推荐CI和AI Agent使用)
如果不可行(非交互式环境、CI、AI Agent),则设置以下环境变量:
sg initbash
export SUPERGLUE_API_KEY="your-api-key"
export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # 可选,此为默认值设置完成后,所有命令无需配置文件即可正常工作。
sg选项C:CLI标志(按命令覆盖配置)
bash
sg system list --api-key "your-key" --endpoint "https://api.superglue.cloud"Config Resolution Order
配置解析顺序
CLI flags > environment variables > config file (local > global ).
.superglue/config.json~/.superglue/config.jsonCLI标志 > 环境变量 > 配置文件(本地 > 全局)。
.superglue/config.json~/.superglue/config.jsonVerifying Setup
验证设置
After configuring, verify the connection works:
bash
sg system list # should return a list (possibly empty) without errors配置完成后,验证连接是否正常:
bash
sg system list # 应返回列表(可能为空)且无错误Quick Start
快速开始
bash
sg system list
sg tool build --config '{"id":"...","instruction":"...","steps":[...]}'
sg tool run --draft <draftId>
sg tool save --draft <draftId>bash
sg system list
sg tool build --config '{"id":"...","instruction":"...","steps":[...]}'
sg tool run --draft <draftId>
sg tool save --draft <draftId>Global Flags
全局标志
| Flag | Description |
|---|---|
| Force JSON output (auto-enabled in non-TTY) |
| Override API key |
| Override API endpoint |
| 标志 | 描述 |
|---|---|
| 强制输出JSON格式(在非TTY环境下自动启用) |
| 覆盖API密钥 |
| 覆盖API端点 |
Command Reference
命令参考
sg init
sg initsg init
sg initInteractive setup — API key, endpoint, output mode. Creates .
.superglue/交互式设置 — API密钥、端点、输出模式。创建目录。
.superglue/Tool Commands
工具命令
sg tool builddraftIdbash
sg tool build --config '{"id":"...","steps":[...]}' # inline JSON
sg tool build --id my-tool --instruction "..." --steps steps.json --payload '{"key":"val"}'
sg tool build --config tool.json # from file| | Full JSON config (file path or inline JSON string) |
| | Tool ID (kebab-case) |
| | Human-readable description |
| | JSON file with steps array |
| | Sample payload |
| | Attach file reference |
--config <file-or-json>--id <id>--instruction <text>--steps <file>--payload <json>--file <key=path>sg tool runbash
sg tool run --draft <draftId> --payload '{"userId":"123"}'
sg tool run --tool my-tool --payload-file payload.json| / | Draft ID or saved tool ID |
| / | Payload |
| | Include raw step results |
| | Include full tool config |
--draft <id>--tool <id>--payload <json>--payload-file <path>--include-step-results--include-configsg tool editbash
sg tool edit --draft <draftId> --patches '[{"op":"replace","path":"/steps/0/config/url","value":"..."}]'
sg tool edit --tool my-tool --patches patches.json| | JSON Patch array (inline or file) |
--patches <json-or-file>sg tool savebash
sg tool save --draft <draftId>sg tool listsg tool findbash
sg tool list # all non-archived tools
sg tool find "shopify orders" # search (compact results)
sg tool find --id my-tool # exact ID lookup (full config)sg tool builddraftIdbash
sg tool build --config '{"id":"...","steps":[...]}' # 内联JSON
sg tool build --id my-tool --instruction "..." --steps steps.json --payload '{"key":"val"}'
sg tool build --config tool.json # 从文件加载| | 完整JSON配置(文件路径或内联JSON字符串) |
| | 工具ID(短横线命名格式) |
| | 人类可读的描述 |
| | 包含步骤数组的JSON文件 |
| | 示例负载 |
| | 附加文件引用 |
--config <file-or-json>--id <id>--instruction <text>--steps <file>--payload <json>--file <key=path>sg tool runbash
sg tool run --draft <draftId> --payload '{"userId":"123"}'
sg tool run --tool my-tool --payload-file payload.json| / | 草稿ID或已保存的工具ID |
| / | 负载 |
| | 包含原始步骤结果 |
| | 包含完整工具配置 |
--draft <id>--tool <id>--payload <json>--payload-file <path>--include-step-results--include-configsg tool editbash
sg tool edit --draft <draftId> --patches '[{"op":"replace","path":"/steps/0/config/url","value":"..."}]'
sg tool edit --tool my-tool --patches patches.json| | JSON Patch数组(内联或文件) |
--patches <json-or-file>sg tool savebash
sg tool save --draft <draftId>sg tool listsg tool findbash
sg tool list # 所有未归档的工具
sg tool find "shopify orders" # 搜索(精简结果)
sg tool find --id my-tool # 精确ID查找(完整配置)System Commands
系统命令
sg system createRequired flags:
- — Human-readable display name
--name <name> - — API base URL (auto-filled when using
--url <url>)--template
Optional:
- — System ID (lowercase, underscores only, no hyphens). Derived from
--id <id>if omitted.--name - — Pre-configured template (auto-fills name and url if not provided)
--template <id>
Example with credentials (non-interactive — use this in AI agent / CI contexts):
bash
sg system create --name "My API" --url https://api.example.com \
--credentials '{"api_key":"sk-xxx"}'With template:
bash
sg system create --name "Slack" --template slackFull flag reference:
| Flag | Description |
|---|---|
| Human-readable name — REQUIRED |
| System ID (lowercase, underscores only) — derived from name if omitted |
| API base URL — REQUIRED (auto-filled by |
| Template ID (stripe, shopify, slack, etc.) |
| Credentials JSON (use for ALL creds in non-interactive mode) |
| Comma-separated fields for masked input (TTY only — do NOT use in AI agents) |
| Documentation URL to scrape |
| OpenAPI spec URL |
| Environment: |
sg system edit--env dev|prodsg system listsg system findfind--env dev|prodsg system call- Explore API endpoints and response structures
- Verify field names and data shapes BEFORE building tools
bash
undefinedsg system create必填标志:
- — 人类可读的显示名称
--name <name> - — API基础URL(使用
--url <url>时自动填充)--template
可选标志:
- — 系统ID(仅小写字母和下划线,无短横线)。如果省略,将从
--id <id>派生。--name - — 预配置模板(自动填充名称和URL,如果未提供)
--template <id>
带凭证的示例(非交互式 — AI Agent/CI环境使用):
bash
sg system create --name "My API" --url https://api.example.com \
--credentials '{"api_key":"sk-xxx"}'使用模板的示例:
bash
sg system create --name "Slack" --template slack完整标志参考:
| 标志 | 描述 |
|---|---|
| 人类可读名称 — 必填 |
| 系统ID(仅小写字母和下划线) — 如果省略,将从名称派生 |
| API基础URL — 必填(使用 |
| 模板ID(stripe、shopify、slack等) |
| 凭证JSON(非交互式模式下用于所有凭证) |
| 逗号分隔的掩码输入字段(仅TTY环境可用 — 请勿在AI Agent中使用) |
| 要抓取的文档URL |
| OpenAPI规范URL |
| 环境: |
sg system edit--env dev|prodsg system listsg system findfind--env dev|prodsg system call- 探索API端点和响应结构
- 在构建工具之前验证字段名称和数据格式
bash
undefinedPOST request with auth and body
带认证和请求体的POST请求
sg system call --url https://api.example.com/users
--system-id my_api
--method POST
--headers '{"Authorization":"Bearer <<my_api_access_token>>"}'
--body '{"name":"test"}'
--system-id my_api
--method POST
--headers '{"Authorization":"Bearer <<my_api_access_token>>"}'
--body '{"name":"test"}'
sg system call --url https://api.example.com/users
--system-id my_api
--method POST
--headers '{"Authorization":"Bearer <<my_api_access_token>>"}'
--body '{"name":"test"}'
--system-id my_api
--method POST
--headers '{"Authorization":"Bearer <<my_api_access_token>>"}'
--body '{"name":"test"}'
Database query (Postgres)
数据库查询(Postgres)
sg system call --url "postgres://<<my_db_host>>:5432/mydb"
--system-id my_db
--body '{"query":"SELECT * FROM users LIMIT 5"}'
--system-id my_db
--body '{"query":"SELECT * FROM users LIMIT 5"}'
sg system call --url "postgres://<<my_db_host>>:5432/mydb"
--system-id my_db
--body '{"query":"SELECT * FROM users LIMIT 5"}'
--system-id my_db
--body '{"query":"SELECT * FROM users LIMIT 5"}'
File server (SFTP)
文件服务器(SFTP)
sg system call --url "sftp://<<my_sftp_host>>:22/data"
--system-id my_sftp
--body '{"operation":"list","path":"/"}'
--system-id my_sftp
--body '{"operation":"list","path":"/"}'
| Flag | Description |
| ------------------- | --------------------------------------------------------- |
| `--url <url>` | Full URL with protocol (http/https/postgres/sftp/ftp/smb) |
| `--system-id <id>` | System ID for credential injection |
| `--method <method>` | HTTP method (GET, POST, PUT, DELETE, PATCH) |
| `--headers <json>` | HTTP headers JSON with credential placeholders |
| `--body <string>` | Request body (JSON string) |
| `--env <env>` | Environment: `dev` or `prod` |
| `--file <key=path>` | File references (repeatable) |
**`sg system search-docs`** — Search system documentation.
```bash
sg system search-docs --system-id slack -k "send message channels"sg system oauthbash
sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"| | Required |
| | Space-separated OAuth scopes (required) |
| | (default) or |
--system-id <id>--scopes <scopes>--grant-type <type>authorization_codeclient_credentialssg system call --url "sftp://<<my_sftp_host>>:22/data"
--system-id my_sftp
--body '{"operation":"list","path":"/"}'
--system-id my_sftp
--body '{"operation":"list","path":"/"}'
| 标志 | 描述 |
| ------------------- | -------------------------------------------------- |
| `--url <url>` | 带协议的完整URL(http/https/postgres/sftp/ftp/smb) |
| `--system-id <id>` | 用于凭证注入的系统ID |
| `--method <method>` | HTTP方法(GET、POST、PUT、DELETE、PATCH) |
| `--headers <json>` | 带凭证占位符的HTTP头JSON |
| `--body <string>` | 请求体(JSON字符串) |
| `--env <env>` | 环境:`dev`或`prod` |
| `--file <key=path>` | 文件引用(可重复使用) |
**`sg system search-docs`** — 搜索系统文档。
```bash
sg system search-docs --system-id slack -k "send message channels"sg system oauthbash
sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"| | 必填 |
| | 空格分隔的OAuth权限范围(必填) |
| | (默认)或 |
--system-id <id>--scopes <scopes>--grant-type <type>authorization_codeclient_credentialsRun Commands
运行命令
sg run list--tool--status--source--limitsg run get <runId>--fetch-resultssg run list--tool--status--source--limitsg run get <runId>--fetch-resultsTool Configuration — Full Schema
工具配置 — 完整 Schema
json
{
"id": "kebab-case-tool-name",
"instruction": "Brief human-readable description of what this tool does",
"steps": [
{
"id": "unique-step-id",
"config": {
"systemId": "example_system",
"url": "https://api.example.com/endpoint?param=<<payload_field>>",
"method": "GET",
"headers": {
"Authorization": "Bearer <<example_system_access_token>>"
},
"queryParams": { "limit": "10" },
"body": "{ \"key\": \"<<payload_field>>\" }"
},
"dataSelector": "(sourceData) => sourceData.previousStep.data.items",
"failureBehavior": "fail"
}
],
"outputTransform": "(sourceData) => sourceData.stepId.data",
"outputSchema": { "type": "object", "properties": {} },
"inputSchema": { "type": "object", "properties": {} }
}json
{
"id": "kebab-case-tool-name",
"instruction": "Brief human-readable description of what this tool does",
"steps": [
{
"id": "unique-step-id",
"config": {
"systemId": "example_system",
"url": "https://api.example.com/endpoint?param=<<payload_field>>",
"method": "GET",
"headers": {
"Authorization": "Bearer <<example_system_access_token>>"
},
"queryParams": { "limit": "10" },
"body": "{ \"key\": \"<<payload_field>>\" }"
},
"dataSelector": "(sourceData) => sourceData.previousStep.data.items",
"failureBehavior": "fail"
}
],
"outputTransform": "(sourceData) => sourceData.stepId.data",
"outputSchema": { "type": "object", "properties": {} },
"inputSchema": { "type": "object", "properties": {} }
}Step Config Fields (Request Steps)
步骤配置字段(请求步骤)
| Field | Type | Description |
|---|---|---|
| string | |
| string | System whose credentials to use |
| string | Full URL with |
| string | HTTP method |
| object | HTTP headers with credential placeholders |
| object | URL query parameters |
| string | Request body (JSON string with placeholders) |
| object | Auto-pagination config (see below) |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | |
| 字符串 | 要使用其凭证的系统ID |
| 字符串 | 带 |
| 字符串 | HTTP方法 |
| 对象 | 带凭证占位符的HTTP头 |
| 对象 | URL查询参数 |
| 字符串 | 请求体(带占位符的JSON字符串) |
| 对象 | 自动分页配置(见下文) |
Step Config Fields (Transform Steps)
步骤配置字段(转换步骤)
| Field | Type | Description |
|---|---|---|
| string | |
| string | JS function: |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | |
| 字符串 | JS函数: |
Step Behavior Fields
步骤行为字段
| Field | Type | Description |
|---|---|---|
| string | JS function controlling step input and loop mode |
| string | |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | 控制步骤输入和循环模式的JS函数 |
| 字符串 | |
Credential Placeholders
凭证占位符
System credentials are namespaced as and resolved server-side at execution time. You MUST explicitly reference them in headers.
<<systemId_credentialKey>>系统凭证以命名,并在执行时由服务器端解析。你必须在头中显式引用它们。
<<systemId_credentialKey>>Auth Header Patterns
认证头示例
json
{"Authorization": "Bearer <<stripe_api_key>>"}
{"Authorization": "Bearer <<gmail_access_token>>"}
{"X-API-Key": "<<my_api_api_key>>"}
{"Authorization": "Basic <<my_api_username>>:<<my_api_password>>"}Basic auth is auto-encoded: if the value after isn't already base64, the engine encodes it automatically.
Basic json
{"Authorization": "Bearer <<stripe_api_key>>"}
{"Authorization": "Bearer <<gmail_access_token>>"}
{"X-API-Key": "<<my_api_api_key>>"}
{"Authorization": "Basic <<my_api_username>>:<<my_api_password>>"}基础认证会自动编码:如果后的值不是base64格式,引擎会自动对其进行编码。
Basic Credential Lifecycle
凭证生命周期
- Non-sensitive creds (,
client_id, etc.) are stored viaauth_url--credentials - Sensitive creds (,
api_key) — in non-interactive mode (AI agents, CI), pass viaclient_secretJSON. In interactive TTY, use--credentialsfor masked input, or set--sensitive-credentialsenv vars.SUPERGLUE_CRED_<FIELD> - OAuth tokens (,
access_token) are auto-refreshed before each step executionrefresh_token
- 非敏感凭证(、
client_id等)通过auth_url存储--credentials - 敏感凭证(、
api_key) — 在非交互式环境(AI Agent、CI)中,通过client_secretJSON传递。在交互式TTY环境中,使用--credentials进行掩码输入,或设置--sensitive-credentials环境变量。SUPERGLUE_CRED_<FIELD> - OAuth令牌(、
access_token)在每个步骤执行前自动刷新refresh_token
Variables and Data Flow
变量与数据流
Variable Syntax
变量语法
All step config fields support placeholders:
<<variable>>| Syntax | Resolves to |
|---|---|
| Payload field or credential |
| System credential |
| JavaScript expression |
CRITICAL: Simple only works for top-level keys. No dots, no nesting.
<<varName>>- VALID: ,
<<userId>>,<<currentItem>><<stripe_api_key>> - INVALID: ,
<<currentItem.id>>— these FAIL at runtime<<sourceData.userId>>
For nested access, use arrow functions:
<<(sourceData) => sourceData.currentItem.id>>所有步骤配置字段都支持占位符:
<<variable>>| 语法 | 解析目标 |
|---|---|
| 负载字段或凭证 |
| 系统凭证 |
| JavaScript表达式 |
重要提示:简单的仅适用于顶级键。不支持点语法,不支持嵌套。
<<varName>>- 有效:、
<<userId>>、<<currentItem>><<stripe_api_key>> - 无效:、
<<currentItem.id>>— 这些会在运行时失败<<sourceData.userId>>
对于嵌套访问,请使用箭头函数:
<<(sourceData) => sourceData.currentItem.id>>sourceData Object
sourceData对象
sourceDatajavascript
sourceData = {
// Payload fields at ROOT level (NEVER use sourceData.payload.*)
userId: "123",
date: "2024-01-15",
// Previous step results, keyed by step ID
// Object-selector step:
getUsers: { currentItem: {}, data: { users: [...] }, success: true },
// Array-selector (loop) step:
fetchDetails: [
{ currentItem: "id1", data: { name: "Alice" }, success: true },
{ currentItem: "id2", data: { name: "Bob" }, success: true },
],
// Current loop item (only set inside a looping step's config)
currentItem: { id: 1 },
// Credentials (flattened, namespaced)
systemId_access_token: "...",
systemId_api_key: "..."
}sourceDatajavascript
sourceData = {
// 根级别的负载字段(绝不要使用sourceData.payload.*)
userId: "123",
date: "2024-01-15",
// 之前步骤的结果,按步骤ID键存储
// 对象选择器步骤:
getUsers: { currentItem: {}, data: { users: [...] }, success: true },
// 数组选择器(循环)步骤:
fetchDetails: [
{ currentItem: "id1", data: { name: "Alice" }, success: true },
{ currentItem: "id2", data: { name: "Bob" }, success: true },
],
// 当前循环项(仅在循环步骤的配置中设置)
currentItem: { id: 1 },
// 凭证(扁平化、命名空间化)
systemId_access_token: "...",
systemId_api_key: "..."
}Step Result Envelope
步骤结果信封
Every step result is wrapped in an envelope — you MUST account for this.
Object selector (or no selector) — step runs once:
javascript
sourceData.stepId = { currentItem: <selectorOutput>, data: <apiResponse>, success: true }
// Access the API response:
sourceData.stepId.data
sourceData.stepId.data.usersArray selector — step loops, result is an array of envelopes:
javascript
sourceData.stepId = [
{ currentItem: <item1>, data: <response1>, success: true },
{ currentItem: <item2>, data: <response2>, success: true },
...
]每个步骤结果都被包裹在信封中 — 你必须考虑这一点。
对象选择器(或无选择器) — 步骤运行一次:
javascript
sourceData.stepId = { currentItem: <selectorOutput>, data: <apiResponse>, success: true }
// 访问API响应:
sourceData.stepId.data
sourceData.stepId.data.users数组选择器 — 步骤循环运行,结果是信封数组:
javascript
sourceData.stepId = [
{ currentItem: <item1>, data: <response1>, success: true },
{ currentItem: <item2>, data: <response2>, success: true },
...
]Data Selectors
数据选择器
Control what a step receives as input and whether it loops:
| Return type | Behavior |
|---|---|
| Single object | Step runs once with that object |
| Array | Step runs once per item (loop mode) |
| Step receives full sourceData |
In loop mode, is set to the current array element.
sourceData.currentItemEmpty arrays are valid — the step simply skips execution.
控制步骤接收的输入以及是否循环:
| 返回类型 | 行为 |
|---|---|
| 单个对象 | 步骤使用该对象运行一次 |
| 数组 | 步骤针对每个项运行一次(循环模式) |
| 步骤接收完整的sourceData |
在循环模式下,被设置为当前数组元素。
sourceData.currentItem空数组是有效的 — 步骤将直接跳过执行。
Two Step Types
两种步骤类型
Request step (HTTP, Postgres, FTP/SFTP/SMB) — makes an API call:
json
{
"id": "get-users",
"config": {
"type": "request",
"systemId": "my_api",
"url": "https://api.example.com/users",
"method": "GET",
"headers": { "Authorization": "Bearer <<my_api_access_token>>" }
}
}Transform step — pure JavaScript, no API call. Use when a subsequent request step needs reshaped data:
json
{
"id": "format-data",
"config": {
"type": "transform",
"transformCode": "(sourceData) => sourceData.getUsers.data.map(u => ({ id: u.id, name: u.fullName }))"
}
}Transform steps do NOT have: , , , , , , or . The function receives (same object available everywhere) and its return value becomes in the step envelope.
systemIdurlmethodheadersbodyqueryParamspaginationtransformCodesourceData.dataWhen to use each:
| Need | Use |
|---|---|
| Filter/reshape data for a SUBSEQUENT request step | Transform step ( |
| Shape the final tool output | |
| Select input / control looping for a step | |
| Inline data computation in URL/body/headers | |
请求步骤(HTTP、Postgres、FTP/SFTP/SMB) — 发起API调用:
json
{
"id": "get-users",
"config": {
"type": "request",
"systemId": "my_api",
"url": "https://api.example.com/users",
"method": "GET",
"headers": { "Authorization": "Bearer <<my_api_access_token>>" }
}
}转换步骤 — 纯JavaScript,无API调用。当后续请求步骤需要重新格式化的数据时使用:
json
{
"id": "format-data",
"config": {
"type": "transform",
"transformCode": "(sourceData) => sourceData.getUsers.data.map(u => ({ id: u.id, name: u.fullName }))"
}
}转换步骤不包含:、、、、、或。函数接收(与其他地方可用的对象相同),其返回值将成为步骤信封中的。
systemIdurlmethodheadersbodyqueryParamspaginationtransformCodesourceData.data何时使用每种步骤:
| 需求 | 使用方式 |
|---|---|
| 为后续请求步骤过滤/重新格式化数据 | 转换步骤( |
| 格式化工具的最终输出 | |
| 选择步骤输入 / 控制步骤循环 | 步骤上的 |
| 在URL/请求体/头中内联数据计算 | |
Execution Pipeline
执行流程
For each step in order:
- Build :
sourceData{ ...originalPayload, ...previousStepResults, ...credentials } - Run → determines single vs loop execution
dataSelector(sourceData) - For each item: merge into
currentItem, resolvesourceDatavariables, execute step<<>>- Request step: makes the HTTP/DB/FTP call, raw response becomes
.data - Transform step: runs , return value becomes
transformCode(sourceData).data
- Request step: makes the HTTP/DB/FTP call, raw response becomes
- Wrap result: and store in
{ currentItem, data, success }sourceData[stepId] - After all steps: run to shape final output
outputTransform(sourceData)
按顺序处理每个步骤:
- 构建:
sourceData{ ...originalPayload, ...previousStepResults, ...credentials } - 运行→ 确定单次执行还是循环执行
dataSelector(sourceData) - 针对每个项:将合并到
currentItem中,解析sourceData变量,执行步骤<<>>- 请求步骤:发起HTTP/DB/FTP调用,原始响应成为
.data - 转换步骤:运行,返回值成为
transformCode(sourceData).data
- 请求步骤:发起HTTP/DB/FTP调用,原始响应成为
- 包装结果:并存储在
{ currentItem, data, success }中sourceData[stepId] - 所有步骤完成后:运行以格式化最终输出
outputTransform(sourceData)
HTTP API Patterns
HTTP API模式
Pagination
分页
json
{
"pagination": {
"type": "offset|cursor|page",
"pageSize": 100,
"cursorPath": "$.nextPageToken",
"stopCondition": "(response) => !response.hasMore"
}
}| Type | How it works |
|---|---|
| Increments |
| Extracts next cursor from |
| Increments |
All types stop when returns true, response is empty, or max pages reached.
stopConditionjson
{
"pagination": {
"type": "offset|cursor|page",
"pageSize": 100,
"cursorPath": "$.nextPageToken",
"stopCondition": "(response) => !response.hasMore"
}
}| 类型 | 工作原理 |
|---|---|
| 每页将 |
| 从 |
| 递增 |
当返回true、响应为空或达到最大页数时,所有类型的分页都会停止。
stopConditionSystems
系统
Credential Model
凭证模型
- — all credentials passed as JSON via
credentials--credentials - — interactive masked prompt for secrets (TTY only, NOT for AI agents or CI)
sensitiveCredentials - For AI agents / non-interactive use: pass ALL credentials (including secrets like api_key, client_secret) directly via . Ask the user to provide the secret values, then include them in the JSON.
--credentials '{"api_key":"..."}' - For human interactive use: use for masked input of secrets
--sensitive-credentials
- — 所有凭证通过
credentials以JSON形式传递--credentials - — 交互式掩码输入密钥(仅TTY环境可用,不适合AI Agent或CI)
sensitiveCredentials - AI Agent/非交互式使用: 通过直接传递所有凭证(包括api_key、client_secret等密钥)。请用户提供密钥值,然后将其包含在JSON中。
--credentials '{"api_key":"..."}' - 人类交互式使用: 使用进行密钥的掩码输入
--sensitive-credentials
Templates
模板
Templates auto-populate endpoints and OAuth config. Use to discover available templates.
sg system findPreconfigured OAuth (no user client_id/secret needed): slack, salesforce, asana, notion, airtable, jira, confluence
模板会自动填充端点和OAuth配置。使用发现可用模板。
sg system find预配置OAuth(无需用户提供client_id/secret):slack、salesforce、asana、notion、airtable、jira、confluence
OAuth Flow
OAuth流程
sg system create --name "Gmail" --url https://gmail.googleapis.com --credentials '{"auth_url":"...","token_url":"..."}' --sensitive-credentials client_id,client_secretsg system oauth --system-id gmail --scopes "..."- User authenticates in browser → tokens saved automatically
sg system create --name "Gmail" --url https://gmail.googleapis.com --credentials '{"auth_url":"...","token_url":"..."}' --sensitive-credentials client_id,client_secretsg system oauth --system-id gmail --scopes "..."- 用户在浏览器中完成认证 → 令牌自动保存
System IDs
系统ID
- Lowercase letters, numbers, underscores only — no hyphens
- Used for credential namespacing:
<<systemId_credKey>>
- 仅允许小写字母、数字和下划线 — 禁止短横线
- 用于凭证命名空间:
<<systemId_credKey>>
Debugging Failed Tools
调试失败的工具
Debug Workflow
调试流程
- Run with to see raw step responses
--include-step-results - Check each step's field — is the API returning what you expect?
data - Verify credential placeholders match placeholder list
sg system find --id <systemId> - Test API calls directly with — isolate whether the issue is auth, endpoint, or transform
sg system call
- 使用运行,查看原始步骤响应
--include-step-results - 检查每个步骤的字段 — API返回的结果是否符合预期?
data - 验证凭证占位符是否与返回的占位符列表匹配
sg system find --id <systemId> - 使用直接测试API调用 — 隔离问题是出在认证、端点还是转换上
sg system call
Deploying Tools to Production
将工具部署到生产环境
After building and saving a tool, integrate it into your application:
构建并保存工具后,将其集成到你的应用中:
REST API (Any Language)
REST API(任意语言)
bash
undefinedbash
undefinedRun a tool
运行工具
curl -X POST "https://api.superglue.cloud/v1/tools/{toolId}/run"
-H "Authorization: Bearer $SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"inputs": {"userId": "123"}}'
-H "Authorization: Bearer $SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"inputs": {"userId": "123"}}'
curl -X POST "https://api.superglue.cloud/v1/tools/{toolId}/run"
-H "Authorization: Bearer $SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"inputs": {"userId": "123"}}'
-H "Authorization: Bearer $SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"inputs": {"userId": "123"}}'
Webhook trigger (async, fire-and-forget)
Webhook触发(异步,即发即弃)
curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"userId": "123"}'
-H "Content-Type: application/json"
-d '{"userId": "123"}'
undefinedcurl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API_KEY"
-H "Content-Type: application/json"
-d '{"userId": "123"}'
-H "Content-Type: application/json"
-d '{"userId": "123"}'
undefinedTypeScript SDK
TypeScript SDK
typescript
import { configure, runTool } from "@superglue/client";
configure({ apiKey: process.env.SUPERGLUE_API_KEY!, baseUrl: "https://api.superglue.cloud/v1" });
const response = await runTool("my-tool-id", { inputs: { userId: "123" } });
// response.data is a Run object: { runId, toolId, status, data, error, metadata }typescript
import { configure, runTool } from "@superglue/client";
configure({ apiKey: process.env.SUPERGLUE_API_KEY!, baseUrl: "https://api.superglue.cloud/v1" });
const response = await runTool("my-tool-id", { inputs: { userId: "123" } });
// response.data是Run对象:{ runId, toolId, status, data, error, metadata }Python SDK
Python SDK
python
import os
from superglue_client import AuthenticatedClient
from superglue_client.api.tools import run_tool
from superglue_client.models.run_request import RunRequest
from superglue_client.models.run_request_inputs import RunRequestInputs
client = AuthenticatedClient(base_url="https://api.superglue.cloud/v1", token=os.environ["SUPERGLUE_API_KEY"])
with client as c:
result = run_tool.sync("my-tool-id", client=c, body=RunRequest(inputs=RunRequestInputs.from_dict({"userId": "123"})))python
import os
from superglue_client import AuthenticatedClient
from superglue_client.api.tools import run_tool
from superglue_client.models.run_request import RunRequest
from superglue_client.models.run_request_inputs import RunRequestInputs
client = AuthenticatedClient(base_url="https://api.superglue.cloud/v1", token=os.environ["SUPERGLUE_API_KEY"])
with client as c:
result = run_tool.sync("my-tool-id", client=c, body=RunRequest(inputs=RunRequestInputs.from_dict({"userId": "123"})))Reference Files
参考文件
For detailed documentation on specific topics, read these files in the directory:
references/| File | When to read |
|---|---|
| READ THIS when deploying tools to production - SDK usage, REST API, webhooks, error handling |
| Building tools that query PostgreSQL/MySQL databases |
| Building tools that interact with FTP/SFTP/SMB file servers |
| Complex data transformations, output shaping, JS sandbox constraints |
Important: When the user asks about integrating superglue into their codebase, deploying tools, using the SDK, or calling tools from code, you MUST read for complete examples.
references/integration.md有关特定主题的详细文档,请阅读目录中的以下文件:
references/| 文件 | 阅读时机 |
|---|---|
| 务必阅读此文件,当你将工具部署到生产环境时 - SDK使用、REST API、Webhook、错误处理 |
| 构建查询PostgreSQL/MySQL数据库的工具时阅读 |
| 构建与FTP/SFTP/SMB文件服务器交互的工具时阅读 |
| 处理复杂数据转换、输出格式化、JS沙箱约束时阅读 |
重要提示: 当用户询问如何将superglue集成到代码库、部署工具、使用SDK或从代码中调用工具时,你必须阅读以获取完整示例。
references/integration.mdDraft Management
草稿管理
Drafts live in . Created by , updated by , deleted by . Ephemeral — not persisted across sessions.
.superglue/drafts/<draftId>.jsonbuildeditsave草稿存储在中。由创建,更新,删除。临时存储 — 不会跨会话持久化。
.superglue/drafts/<draftId>.jsonbuildeditsaveFile References
文件引用
Attach files with . Reference in payloads with . Auto-parsed to JSON.
--file key=pathfile::<key>bash
sg tool run --draft <id> --payload '{"data": "file::mysheet"}' --file mysheet=data.xlsx使用附加文件。在负载中使用引用。会自动解析为JSON。
--file key=pathfile::<key>bash
sg tool run --draft <id> --payload '{"data": "file::mysheet"}' --file mysheet=data.xlsx