@superglue/cli 1.1.17 → 1.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/cli.js +832 -23922
  3. package/dist/skills/superglue/SKILL.md +240 -27
  4. package/dist/skills/superglue/references/access-rules.md +137 -0
  5. package/dist/skills/superglue/references/data-handling.md +303 -0
  6. package/dist/skills/superglue/references/databases.md +7 -3
  7. package/dist/skills/superglue/references/file-handling.md +160 -0
  8. package/dist/skills/superglue/references/file-servers.md +13 -37
  9. package/dist/skills/superglue/references/http-apis.md +248 -0
  10. package/dist/skills/superglue/references/redis.md +4 -5
  11. package/package.json +2 -1
  12. package/skills/superglue/SKILL.md +240 -27
  13. package/skills/superglue/references/access-rules.md +137 -0
  14. package/skills/superglue/references/data-handling.md +303 -0
  15. package/skills/superglue/references/databases.md +7 -3
  16. package/skills/superglue/references/file-handling.md +160 -0
  17. package/skills/superglue/references/file-servers.md +13 -37
  18. package/skills/superglue/references/http-apis.md +248 -0
  19. package/skills/superglue/references/redis.md +4 -5
  20. package/dist/dist/cli.js +0 -24370
  21. package/dist/dist/skills/superglue/SKILL.md +0 -678
  22. package/dist/dist/skills/superglue/agents/openai.yaml +0 -7
  23. package/dist/dist/skills/superglue/assets/superglue.png +0 -0
  24. package/dist/dist/skills/superglue/references/databases.md +0 -249
  25. package/dist/dist/skills/superglue/references/file-servers.md +0 -136
  26. package/dist/dist/skills/superglue/references/integration.md +0 -279
  27. package/dist/dist/skills/superglue/references/redis.md +0 -190
  28. package/dist/dist/skills/superglue/references/transforms-and-output.md +0 -92
  29. package/dist/skills/superglue/references/transforms-and-output.md +0 -92
  30. package/skills/superglue/references/transforms-and-output.md +0 -92
@@ -1,249 +0,0 @@
1
- # Database Steps
2
-
3
- Superglue supports both PostgreSQL and Microsoft SQL Server (including Azure SQL).
4
-
5
- ---
6
-
7
- ## PostgreSQL
8
-
9
- ### Step Configuration
10
-
11
- ```typescript
12
- {
13
- type: "request",
14
- systemId: "my_postgres_db",
15
- url: "postgres://<<my_postgres_db_user>>:<<my_postgres_db_password>>@<<my_postgres_db_host>>:<<my_postgres_db_port>>/<<my_postgres_db_database>>",
16
- method: "POST", // ignored for Postgres but required by schema
17
- body: '{"query": "SELECT * FROM users WHERE id = $1", "params": [<<userId>>]}'
18
- }
19
- ```
20
-
21
- Configure the connection url depending on which credentials are saved in the stored db system - reference them accordingly.
22
-
23
- ## URL Format
24
-
25
- ```
26
- postgres://user:password@host:port/database
27
- postgresql://user:password@host:port/database
28
- ```
29
-
30
- All credential variables are resolved before connecting. Trailing slashes and extra slashes before query strings are cleaned.
31
-
32
- ## Body Format
33
-
34
- JSON string with `query` and optional `params` (or `values`):
35
-
36
- ```json
37
- { "query": "SELECT * FROM users WHERE age > $1 AND status = $2", "params": [25, "active"] }
38
- ```
39
-
40
- ### Parameterized Queries
41
-
42
- **Always use parameterized queries** with `$1`, `$2`, etc. — prevents SQL injection.
43
-
44
- ```json
45
- { "query": "SELECT * FROM orders WHERE customer_id = $1", "params": ["<<customerId>>"] }
46
- ```
47
-
48
- With expressions:
49
-
50
- ```json
51
- {
52
- "query": "INSERT INTO logs (message, level) VALUES ($1, $2)",
53
- "params": ["<<(sourceData) => sourceData.message>>", "error"]
54
- }
55
- ```
56
-
57
- With RETURNING:
58
-
59
- ```json
60
- {
61
- "query": "INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *",
62
- "params": [
63
- "<<(sourceData) => sourceData.currentItem.name>>",
64
- "<<(sourceData) => sourceData.currentItem.email>>"
65
- ]
66
- }
67
- ```
68
-
69
- ## Connection Pooling
70
-
71
- - Pools cached by connection string, max 10 clients, 5s connection timeout
72
- - Idle pools cleaned up automatically
73
- - SSL auto-configured: enabled (with `rejectUnauthorized: false`) unless connecting to localhost without explicit sslmode
74
-
75
- ## Retry Logic
76
-
77
- Default retries from server config. On final failure, error includes query text and params.
78
-
79
- ## Return Value
80
-
81
- Returns `result.rows` — array of row objects with column names as keys.
82
-
83
- - `SELECT`: array of matching rows
84
- - `INSERT/UPDATE/DELETE` with `RETURNING`: array of returned rows
85
- - Mutations without `RETURNING`: empty array
86
-
87
- ### Batch Operations via Loop
88
-
89
- Use a data selector returning an array to execute a query per item:
90
-
91
- ```javascript
92
- // dataSelector: (sourceData) => sourceData.newUsers
93
- // body: {"query": "INSERT INTO users (name) VALUES ($1)", "params": ["<<(sourceData) => sourceData.currentItem.name>>"]}
94
- ```
95
-
96
- ---
97
-
98
- ## Microsoft SQL Server / Azure SQL
99
-
100
- ### Step Configuration
101
-
102
- ```typescript
103
- {
104
- type: "request",
105
- systemId: "my_azure_sql",
106
- url: "mssql://<<my_azure_sql_user>>:<<my_azure_sql_password>>@<<my_azure_sql_host>>:<<my_azure_sql_port>>/<<my_azure_sql_database>>",
107
- method: "POST", // ignored for MSSQL but required by schema
108
- body: '{"query": "SELECT * FROM users WHERE id = @param1", "params": [<<userId>>]}'
109
- }
110
- ```
111
-
112
- Configure the connection url depending on which credentials are saved in the stored db system - reference them accordingly.
113
-
114
- ### URL Format
115
-
116
- ```
117
- mssql://user:password@host:port/database
118
- sqlserver://user:password@host:port/database
119
- ```
120
-
121
- Both `mssql://` and `sqlserver://` protocols are supported. All credential variables are resolved before connecting.
122
-
123
- #### Azure SQL Database Connection
124
-
125
- For Azure SQL Database, use the fully qualified server name:
126
-
127
- ```
128
- mssql://myuser@myserver:mypassword@myserver.database.windows.net:1433/mydatabase
129
- ```
130
-
131
- You can include connection parameters as query strings:
132
-
133
- ```
134
- mssql://user:password@host:port/database?encrypt=true&trustServerCertificate=false
135
- ```
136
-
137
- **Connection Parameters:**
138
-
139
- - `encrypt` (default: `true`) - Enable/disable encryption (required for Azure SQL)
140
- - `trustServerCertificate` (default: `false`) - Whether to trust the server certificate
141
- - `database` - Database name (can be in URL path or query parameter)
142
-
143
- ### Body Format
144
-
145
- JSON string with `query` and optional `params` (or `values`):
146
-
147
- ```json
148
- {
149
- "query": "SELECT * FROM users WHERE age > @param1 AND status = @param2",
150
- "params": [25, "active"]
151
- }
152
- ```
153
-
154
- ### Parameterized Queries
155
-
156
- **Always use parameterized queries** with `@param1`, `@param2`, etc. — prevents SQL injection.
157
-
158
- ```json
159
- { "query": "SELECT * FROM orders WHERE customer_id = @param1", "params": ["<<customerId>>"] }
160
- ```
161
-
162
- With expressions:
163
-
164
- ```json
165
- {
166
- "query": "INSERT INTO logs (message, level) VALUES (@param1, @param2)",
167
- "params": ["<<(sourceData) => sourceData.message>>", "error"]
168
- }
169
- ```
170
-
171
- With OUTPUT (MSSQL equivalent of RETURNING):
172
-
173
- ```json
174
- {
175
- "query": "INSERT INTO users (name, email) OUTPUT INSERTED.* VALUES (@param1, @param2)",
176
- "params": [
177
- "<<(sourceData) => sourceData.currentItem.name>>",
178
- "<<(sourceData) => sourceData.currentItem.email>>"
179
- ]
180
- }
181
- ```
182
-
183
- **Parameter Naming**: MSSQL uses named parameters with `@` prefix. The params array maps positionally: `params[0]` → `@param1`, `params[1]` → `@param2`, etc.
184
-
185
- ### Connection Pooling
186
-
187
- - Pools cached by connection string, max 10 clients per pool
188
- - 5s connection timeout, configurable request timeout
189
- - Idle pools cleaned up automatically
190
- - SSL/TLS encryption enabled by default for Azure SQL
191
-
192
- ### Retry Logic
193
-
194
- Default retries from server config. On final failure, error includes query text and params.
195
-
196
- ### Return Value
197
-
198
- Returns the recordset — array of row objects with column names as keys.
199
-
200
- - `SELECT`: array of matching rows
201
- - `INSERT/UPDATE/DELETE` with `OUTPUT`: array of returned rows
202
- - Mutations without `OUTPUT`: empty array
203
-
204
- ### Batch Operations via Loop
205
-
206
- Use a data selector returning an array to execute a query per item:
207
-
208
- ```javascript
209
- // dataSelector: (sourceData) => sourceData.newUsers
210
- // body: {"query": "INSERT INTO users (name) VALUES (@param1)", "params": ["<<(sourceData) => sourceData.currentItem.name>>"]}
211
- ```
212
-
213
- ### Common Patterns
214
-
215
- **Simple SELECT:**
216
-
217
- ```json
218
- {
219
- "query": "SELECT id, name, email FROM users WHERE status = @param1",
220
- "params": ["active"]
221
- }
222
- ```
223
-
224
- **INSERT with OUTPUT:**
225
-
226
- ```json
227
- {
228
- "query": "INSERT INTO users (name, email, created_at) OUTPUT INSERTED.id, INSERTED.created_at VALUES (@param1, @param2, GETUTCDATE())",
229
- "params": ["John Doe", "john@example.com"]
230
- }
231
- ```
232
-
233
- **UPDATE with OUTPUT:**
234
-
235
- ```json
236
- {
237
- "query": "UPDATE users SET last_login = GETUTCDATE() OUTPUT INSERTED.id, INSERTED.last_login WHERE id = @param1",
238
- "params": [123]
239
- }
240
- ```
241
-
242
- **Stored Procedure Call:**
243
-
244
- ```json
245
- {
246
- "query": "EXEC dbo.GetUserById @param1",
247
- "params": [123]
248
- }
249
- ```
@@ -1,136 +0,0 @@
1
- # File Server Steps (FTP / SFTP / SMB)
2
-
3
- FTP, SFTP, and SMB share an identical operation interface. Only the URL protocol and connection details differ.
4
-
5
- ## URL Formats
6
-
7
- ```
8
- ftp://user:password@host:port/basePath (port 21)
9
- ftps://user:password@host:port/basePath (port 21, TLS)
10
- sftp://user:password@host:port/basePath (port 22)
11
- smb://user:password@host/sharename/basePath (port 445)
12
- smb://domain\user:password@host/sharename/ (domain auth)
13
- ```
14
-
15
- All support `<<variable>>` syntax in the URL.
16
-
17
- SMB requires a share name as the first path segment. Additional segments become a base path prepended to all operation paths.
18
-
19
- ## Path Handling
20
-
21
- **All operation paths are relative to the base path in the URL.** Do NOT use absolute filesystem paths.
22
-
23
- If the system URL is `sftp://user:pass@host/home/sftptest/uploads`:
24
-
25
- - `report.csv` → `/home/sftptest/uploads/report.csv`
26
- - `subdir/data.csv` → `/home/sftptest/uploads/subdir/data.csv`
27
-
28
- Do NOT use `/home/sftptest/uploads/report.csv` — the base path is already set in the URL.
29
-
30
- If the URL has no base path (e.g., `sftp://user:pass@host`), operation paths are used as-is from the server root.
31
-
32
- ## Body Format
33
-
34
- JSON string — single operation or array of operations (batch):
35
-
36
- ### Single
37
-
38
- ```json
39
- { "operation": "get", "path": "data/report.csv" }
40
- ```
41
-
42
- ### Batch (sequential, same connection)
43
-
44
- ```json
45
- [
46
- { "operation": "mkdir", "path": "backup" },
47
- { "operation": "get", "path": "data/report.csv" },
48
- { "operation": "put", "path": "backup/report.csv", "content": "data here" }
49
- ]
50
- ```
51
-
52
- ## Supported Operations
53
-
54
- | Operation | Required fields | Returns |
55
- | --------- | ----------------- | ----------------------------------------------------------------------- |
56
- | `list` | `path` | Array of `{ name, path, size, type, modifyTime, ... }` |
57
- | `get` | `path` | Auto-parsed file content (CSV→objects, JSON→parsed, etc.) or raw string |
58
- | `put` | `path`, `content` | `{ success, message, size }` |
59
- | `delete` | `path` | `{ success, message }` |
60
- | `rename` | `path`, `newPath` | `{ success, message }` |
61
- | `mkdir` | `path` | `{ success, message }` |
62
- | `rmdir` | `path` | `{ success, message }` |
63
- | `exists` | `path` | `{ exists: boolean, path }` |
64
- | `stat` | `path` | File metadata or `{ exists: false }` |
65
-
66
- ### `get` — Auto-Parsing
67
-
68
- Downloaded files are all parsed automatically:
69
-
70
- - CSV, JSON, XML, Excel, PDF, etc. → parsed to JS objects
71
- - Falls back to UTF-8 string
72
- - SMB additionally detects binary files (returns `{ _binary: true, encoding: "base64", data: "..." }`)
73
-
74
- ### `put` — Content Handling
75
-
76
- - String → written as-is
77
- - Buffer → written directly
78
- - Object/Array → `JSON.stringify` with 2-space indent
79
-
80
- ## Connection Details
81
-
82
- ### SFTP
83
-
84
- Uses `ssh2-sftp-client`. Supports password + private key auth (`credentials.privateKey`, `credentials.passphrase`).
85
-
86
- ### FTP/FTPS
87
-
88
- Uses `basic-ftp`. FTPS uses TLS with `rejectUnauthorized: false`.
89
-
90
- ### SMB
91
-
92
- Uses `@awo00/smb2`. Connection lifecycle: create client → authenticate (domain optional) → connect tree (share) → execute → disconnect/logoff/close. Entire operation wrapped in timeout race.
93
-
94
- All paths use forward slashes (`/`) — SMB library handles Windows conversion internally.
95
-
96
- Credentials must be injected into the URL using placeholders:
97
-
98
- ```
99
- smb://<<systemId_username>>:<<systemId_password>>@fileserver.example.com/ShareName
100
- ```
101
-
102
- For private systems via Secure Gateway, the host is `tunnelId.tunnel` (e.g., `my_tunnel.tunnel`).
103
-
104
- ## Return Value
105
-
106
- Single operation → result directly. Multiple operations → array of results.
107
-
108
- ## Common Patterns
109
-
110
- ### Download and process
111
-
112
- ```json
113
- { "operation": "get", "path": "incoming/<<(sourceData) => sourceData.currentItem.filename>>" }
114
- ```
115
-
116
- ### Upload results
117
-
118
- ```json
119
- {
120
- "operation": "put",
121
- "path": "output/results.json",
122
- "content": "<<(sourceData) => JSON.stringify(sourceData.processData.data)>>"
123
- }
124
- ```
125
-
126
- ### List then loop
127
-
128
- Step 1 lists files, step 2 uses data selector to loop over them:
129
-
130
- ```javascript
131
- // Step 1: list files
132
- // body: {"operation": "list", "path": "incoming"}
133
-
134
- // Step 2 dataSelector: (sourceData) => sourceData.listFiles.data.filter(f => f.type === "file")
135
- // body: {"operation": "get", "path": "<<(sourceData) => sourceData.currentItem.path>>"}
136
- ```
@@ -1,279 +0,0 @@
1
- # Integrating superglue into Your Codebase
2
-
3
- After building and saving tools with the CLI, integrate them into your application.
4
-
5
- ## Quick Reference: REST API (curl)
6
-
7
- For any language, use the REST API directly:
8
-
9
- ```bash
10
- # Set your API key and endpoint
11
- export SUPERGLUE_API_KEY="your-api-key"
12
- export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud"
13
-
14
- # Run a tool (sync - waits for completion)
15
- curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/tools/my-tool-id/run" \
16
- -H "Authorization: Bearer $SUPERGLUE_API_KEY" \
17
- -H "Content-Type: application/json" \
18
- -d '{"inputs": {"userId": "123"}}'
19
-
20
- # Run a tool (async - returns immediately)
21
- curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/tools/my-tool-id/run" \
22
- -H "Authorization: Bearer $SUPERGLUE_API_KEY" \
23
- -H "Content-Type: application/json" \
24
- -d '{"inputs": {"userId": "123"}, "options": {"async": true}}'
25
-
26
- # Get run status/result
27
- curl "$SUPERGLUE_API_ENDPOINT/v1/runs/{runId}" \
28
- -H "Authorization: Bearer $SUPERGLUE_API_KEY"
29
-
30
- # List tools
31
- curl "$SUPERGLUE_API_ENDPOINT/v1/tools?page=1&limit=50" \
32
- -H "Authorization: Bearer $SUPERGLUE_API_KEY"
33
-
34
- # Get tool details
35
- curl "$SUPERGLUE_API_ENDPOINT/v1/tools/my-tool-id" \
36
- -H "Authorization: Bearer $SUPERGLUE_API_KEY"
37
-
38
- # Cancel a running tool
39
- curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/runs/{runId}/cancel" \
40
- -H "Authorization: Bearer $SUPERGLUE_API_KEY"
41
- ```
42
-
43
- ### Response Format
44
-
45
- **Sync execution (200 OK):**
46
-
47
- ```json
48
- {
49
- "runId": "7f3e9c1a-2b4d-4e8f-9a3b-1c5d7e9f2a4b",
50
- "toolId": "my-tool-id",
51
- "status": "success",
52
- "data": { "result": "..." },
53
- "stepResults": [{ "stepId": "step-1", "success": true, "data": {} }],
54
- "metadata": {
55
- "startedAt": "2024-01-15T10:00:00Z",
56
- "completedAt": "2024-01-15T10:00:05Z",
57
- "durationMs": 5234
58
- }
59
- }
60
- ```
61
-
62
- **Async execution (202 Accepted):**
63
-
64
- ```json
65
- {
66
- "runId": "7f3e9c1a-2b4d-4e8f-9a3b-1c5d7e9f2a4b",
67
- "toolId": "my-tool-id",
68
- "status": "running"
69
- }
70
- ```
71
-
72
- ---
73
-
74
- ## SDK Installation
75
-
76
- ```bash
77
- # TypeScript/JavaScript
78
- npm install @superglue/client
79
-
80
- # Python
81
- pip install superglue-client
82
- ```
83
-
84
- Both SDKs are auto-generated from the OpenAPI spec (JS via orval, Python via openapi-python-client).
85
-
86
- ## TypeScript/JavaScript Usage
87
-
88
- The JS SDK exports: `configure`, `listTools`, `getTool`, `runTool`, `getRun`, `cancelRun`, `triggerWebhook`, `listRuns`.
89
-
90
- ```typescript
91
- import { configure, runTool, getRun, listTools, getTool } from "@superglue/client";
92
-
93
- configure({
94
- apiKey: process.env.SUPERGLUE_API_KEY!,
95
- baseUrl: "https://api.superglue.cloud/v1",
96
- });
97
- ```
98
-
99
- ### Run a Tool (Sync)
100
-
101
- ```typescript
102
- const response = await runTool("my-tool-id", {
103
- inputs: { userId: "123", date: "2024-01-15" },
104
- });
105
-
106
- if (response.status === 200) {
107
- const run = response.data;
108
- console.log(run.status); // "success" | "failed"
109
- console.log(run.data); // tool output
110
- } else {
111
- console.error("Error:", response.data);
112
- }
113
- ```
114
-
115
- The response is `{ data: Run, status: number, headers: Headers }`. The `Run` object has: `runId`, `toolId`, `status`, `data`, `error`, `stepResults`, `metadata`.
116
-
117
- ### Async Execution (Fire-and-Forget)
118
-
119
- ```typescript
120
- const response = await runTool("my-tool-id", {
121
- inputs: { userId: "123" },
122
- options: { async: true },
123
- });
124
-
125
- if (response.status === 202) {
126
- const run = response.data;
127
- console.log(`Run started: ${run.runId}`);
128
-
129
- let latest = run;
130
- while (latest.status === "running") {
131
- await new Promise((r) => setTimeout(r, 1000));
132
- const poll = await getRun(latest.runId);
133
- latest = poll.data;
134
- }
135
- }
136
- ```
137
-
138
- ### List and Discover Tools
139
-
140
- ```typescript
141
- const { data: tools } = await listTools({ page: 1, limit: 50 });
142
- console.log(tools.data);
143
-
144
- const { data: tool } = await getTool("my-tool-id");
145
- console.log(tool.inputSchema);
146
- ```
147
-
148
- ## Python Usage
149
-
150
- The Python SDK uses `AuthenticatedClient` with httpx. Functions are in `superglue_client.api.tools` and `superglue_client.api.runs`.
151
-
152
- ```python
153
- import os
154
- from superglue_client import AuthenticatedClient
155
- from superglue_client.api.tools import run_tool, list_tools, get_tool
156
- from superglue_client.api.runs import get_run
157
- from superglue_client.models.run_request import RunRequest
158
- from superglue_client.models.run_request_inputs import RunRequestInputs
159
-
160
- client = AuthenticatedClient(
161
- base_url="https://api.superglue.cloud/v1",
162
- token=os.environ["SUPERGLUE_API_KEY"],
163
- )
164
- ```
165
-
166
- ### Run a Tool (Sync)
167
-
168
- ```python
169
- with client as c:
170
- result = run_tool.sync(
171
- "my-tool-id",
172
- client=c,
173
- body=RunRequest(
174
- inputs=RunRequestInputs.from_dict({"userId": "123"}),
175
- ),
176
- )
177
-
178
- if hasattr(result, "status") and result.status == "success":
179
- print(result.data)
180
- elif hasattr(result, "error"):
181
- print(result.error)
182
- ```
183
-
184
- `sync()` returns `Run | Error | None`. Use `sync_detailed()` for the full `Response` wrapper with status code and headers.
185
-
186
- ### Async Python
187
-
188
- ```python
189
- async with client as c:
190
- result = await run_tool.asyncio(
191
- "my-tool-id",
192
- client=c,
193
- body=RunRequest(
194
- inputs=RunRequestInputs.from_dict({"userId": "123"}),
195
- ),
196
- )
197
- ```
198
-
199
- ## Webhook Triggers
200
-
201
- Trigger tools via HTTP POST without SDK. Webhooks execute asynchronously.
202
-
203
- ```bash
204
- curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token={apiKey}" \
205
- -H "Content-Type: application/json" \
206
- -d '{"userId": "123"}'
207
- ```
208
-
209
- ### Webhook URL Pattern
210
-
211
- ```
212
- POST {endpoint}/v1/hooks/{toolId}?token={apiKey}
213
- ```
214
-
215
- - `endpoint` — Your superglue API endpoint
216
- - `toolId` — The saved tool ID (from `sg tool save`)
217
- - `apiKey` — Your superglue API key (passed as `token` query param)
218
-
219
- ### Webhook Response
220
-
221
- Webhooks return `202 Accepted` immediately:
222
-
223
- ```json
224
- {
225
- "runId": "uuid-of-execution",
226
- "status": "accepted",
227
- "toolId": "my-tool-id"
228
- }
229
- ```
230
-
231
- To get the result, poll the run status:
232
-
233
- ```bash
234
- curl "https://api.superglue.cloud/v1/runs/{runId}" \
235
- -H "Authorization: Bearer {apiKey}"
236
- ```
237
-
238
- ## Error Handling
239
-
240
- ### Retry Pattern (TypeScript)
241
-
242
- ```typescript
243
- async function runToolWithRetry(toolId: string, inputs: Record<string, any>, maxRetries = 3) {
244
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
245
- const response = await runTool(toolId, { inputs });
246
-
247
- if (response.status === 200 && response.data.status === "success") {
248
- return response.data;
249
- }
250
-
251
- if (response.data.error?.includes("validation")) {
252
- throw new Error(response.data.error);
253
- }
254
-
255
- if (attempt < maxRetries) {
256
- await new Promise((r) => setTimeout(r, 1000 * Math.pow(2, attempt)));
257
- }
258
- }
259
- throw new Error(`Tool ${toolId} failed after ${maxRetries} attempts`);
260
- }
261
- ```
262
-
263
- ## Environment Configuration
264
-
265
- ```bash
266
- # Required
267
- SUPERGLUE_API_KEY=your-api-key
268
-
269
- # Optional (defaults to hosted)
270
- SUPERGLUE_API_ENDPOINT=https://api.superglue.cloud
271
- ```
272
-
273
- ## Best Practices
274
-
275
- 1. **Store API keys in secrets** — Never commit to version control
276
- 2. **Validate payloads client-side** — Check against `inputSchema` before calling
277
- 3. **Handle errors gracefully** — Tools can fail due to external API issues
278
- 4. **Monitor run history** — Use `sg run list` or the web UI to track executions
279
- 5. **Use async mode for long-running tools** — Avoid timeouts on complex workflows