@superglue/cli 1.1.11 → 1.1.12

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.
@@ -0,0 +1,667 @@
1
+ ---
2
+ name: superglue
3
+ description: "Build, test, deploy and integrate superglue tools via the sg CLI and superglue SDKs. IMPORTANT — you MUST invoke this skill and read the full reference BEFORE running ANY sg command or writing ANY superglue SDK/REST/webhook integration code. Before using the sg CLI, first check that it is installed (run sg --version; if not found, install with npm install -g @superglue/cli), then verify it is configured (check that sg init has been run or that SUPERGLUE_API_KEY and SUPERGLUE_API_ENDPOINT environment variables are set). If not, guide the user through setup first. After reading the SKILL.md file, also read the relevant references/ files for the specific topic (databases, file servers, transforms, integration/SDK)."
4
+ ---
5
+
6
+ # superglue CLI (`sg`) — Agent Reference
7
+
8
+ ## CRITICAL RULES — READ FIRST
9
+
10
+ **Pre-requisites for using the CLI**
11
+
12
+ 1. **Check CLI exists**: Run `sg --version`. If it fails with `command not found`, install it: `npm install -g @superglue/cli`
13
+ 2. **Check superglue CLI config exists**: Run `sg system list`. If it fails with `fetch failed` or auth errors, the CLI needs configuration via `sg init` (see below).
14
+
15
+ **Calling systems and running tools**
16
+
17
+ 1. ALWAYS make sure you pull the relevant system context using `sg system find` before calling system endpoints and running inline JSON tools or building new tools.
18
+ 2. Use `sg system search-docs` to do a targeted keyword search of system docs if you're unsure about how a system works.
19
+
20
+ **Authentication & Credentials:**
21
+
22
+ - **Auth headers MUST be set explicitly** — credentials are NEVER auto-injected into requests or tool steps
23
+ - Every request step (in tools AND `sg system call`) must include the appropriate auth header using `<<systemId_credentialKey>>` syntax
24
+ - OAuth systems also require explicit headers — only token refresh is automatic
25
+
26
+ **Saving Tools:**
27
+
28
+ - **Don't save a tool without explicit user confirmation** — always ask "Should I save this tool?" first
29
+ - After `sg tool build` + `sg tool run`, present results to the user and wait for approval
30
+ - Only run `sg tool save --draft <id>` after the user explicitly confirms
31
+
32
+ **Credentials in Non-Interactive Environments (AI Agents, CI):**
33
+
34
+ - **Pass ALL credentials (including secrets) directly via `--credentials` JSON** — do NOT use `--sensitive-credentials` (it requires an interactive TTY which agents don't have)
35
+ - Ask the user to provide secret values, then pass them in `--credentials '{"api_key":"sk-xxx"}'`
36
+
37
+ ---
38
+
39
+ ## Installation & Setup
40
+
41
+ ### Installing the CLI
42
+
43
+ ```bash
44
+ npm install -g @superglue/cli
45
+ ```
46
+
47
+ After installation, the `sg` command is available globally.
48
+
49
+ ### Initialization (REQUIRED before first use)
50
+
51
+ The CLI **will not work** until configured with an API key. The endpoint defaults to `https://api.superglue.cloud` if not specified.
52
+
53
+ **Option A: Interactive setup (recommended for humans)**
54
+
55
+ ```bash
56
+ sg init
57
+ ```
58
+
59
+ This prompts for:
60
+
61
+ 1. **API Key** (required) — get one at https://app.superglue.cloud/admin?view=api-keys
62
+ 2. **API Endpoint** — defaults to `https://api.superglue.cloud`
63
+ 3. **Web Endpoint** — for OAuth callbacks, auto-derived from API endpoint
64
+ 4. **Output mode** — `stdout` (default) or `stdout+file`
65
+ 5. **Config location** — project-local (`.superglue/config.json`) or global (`~/.superglue/config.json`)
66
+
67
+ It verifies the connection before saving. On success it creates the config file, a `drafts/` directory, and updates `.gitignore` if using local config.
68
+
69
+ **Option B: Environment variables (recommended for CI and AI agents)**
70
+
71
+ If `sg init` is not practical (non-interactive environments, CI, AI agents), set these env vars instead:
72
+
73
+ ```bash
74
+ export SUPERGLUE_API_KEY="your-api-key"
75
+ export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # optional, this is the default
76
+ ```
77
+
78
+ With these set, all `sg` commands work without a config file.
79
+
80
+ **Option C: CLI flags (per-command override)**
81
+
82
+ ```bash
83
+ sg system list --api-key "your-key" --endpoint "https://api.superglue.cloud"
84
+ ```
85
+
86
+ ### Config Resolution Order
87
+
88
+ CLI flags > environment variables > config file (local `.superglue/config.json` > global `~/.superglue/config.json`).
89
+
90
+ ### Verifying Setup
91
+
92
+ After configuring, verify the connection works:
93
+
94
+ ```bash
95
+ sg system list # should return a list (possibly empty) without errors
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Quick Start
101
+
102
+ ```bash
103
+ sg system list
104
+ sg tool build --config '{"id":"...","instruction":"...","steps":[...]}'
105
+ sg tool run --draft <draftId>
106
+ sg tool save --draft <draftId>
107
+ ```
108
+
109
+ ## Global Flags
110
+
111
+ | Flag | Description |
112
+ | ------------------ | ------------------------------------------- |
113
+ | `--json` | Force JSON output (auto-enabled in non-TTY) |
114
+ | `--api-key <key>` | Override API key |
115
+ | `--endpoint <url>` | Override API endpoint |
116
+
117
+ ## Command Reference
118
+
119
+ ### `sg init`
120
+
121
+ Interactive setup — API key, endpoint, output mode. Creates `.superglue/`.
122
+
123
+ ### Tool Commands
124
+
125
+ **`sg tool build`** — Register a tool config. Returns a `draftId`. Not AI-powered — you provide the full config.
126
+
127
+ ```bash
128
+ sg tool build --config '{"id":"...","steps":[...]}' # inline JSON
129
+ sg tool build --id my-tool --instruction "..." --steps steps.json --payload '{"key":"val"}'
130
+ sg tool build --config tool.json # from file
131
+ ```
132
+
133
+ | `--config <file-or-json>` | Full JSON config (file path or inline JSON string) |
134
+ | `--id <id>` | Tool ID (kebab-case) |
135
+ | `--instruction <text>` | Human-readable description |
136
+ | `--steps <file>` | JSON file with steps array |
137
+ | `--payload <json>` | Sample payload |
138
+ | `--file <key=path>` | Attach file reference |
139
+
140
+ **`sg tool run`** — Execute a draft or saved tool. Streams live execution logs to the terminal.
141
+
142
+ ```bash
143
+ sg tool run --draft <draftId> --payload '{"userId":"123"}'
144
+ sg tool run --tool my-tool --payload-file payload.json
145
+ ```
146
+
147
+ | `--draft <id>` / `--tool <id>` | Draft ID or saved tool ID |
148
+ | `--payload <json>` / `--payload-file <path>` | Payload |
149
+ | `--include-step-results` | Include raw step results |
150
+ | `--include-config` | Include full tool config |
151
+
152
+ **`sg tool edit`** — Apply JSON Patch (RFC 6902) operations.
153
+
154
+ ```bash
155
+ sg tool edit --draft <draftId> --patches '[{"op":"replace","path":"/steps/0/config/url","value":"..."}]'
156
+ sg tool edit --tool my-tool --patches patches.json
157
+ ```
158
+
159
+ | `--patches <json-or-file>` | JSON Patch array (inline or file) |
160
+
161
+ **`sg tool save`** — Persist draft to database. Deletes draft file on success.
162
+
163
+ ```bash
164
+ sg tool save --draft <draftId>
165
+ ```
166
+
167
+ **`sg tool list` / `sg tool find`**
168
+
169
+ ```bash
170
+ sg tool list # all non-archived tools
171
+ sg tool find "shopify orders" # search (compact results)
172
+ sg tool find --id my-tool # exact ID lookup (full config)
173
+ ```
174
+
175
+ ### System Commands
176
+
177
+ **`sg system create`**
178
+
179
+ **Required flags:**
180
+
181
+ - `--name <name>` — Human-readable display name
182
+ - `--url <url>` — API base URL (auto-filled when using `--template`)
183
+
184
+ **Optional:**
185
+
186
+ - `--id <id>` — System ID (lowercase, underscores only, no hyphens). Derived from `--name` if omitted.
187
+ - `--template <id>` — Pre-configured template (auto-fills name and url if not provided)
188
+
189
+ **Example with credentials (non-interactive — use this in AI agent / CI contexts):**
190
+
191
+ ```bash
192
+ sg system create --name "My API" --url https://api.example.com \
193
+ --credentials '{"api_key":"sk-xxx"}'
194
+ ```
195
+
196
+ **With template:**
197
+
198
+ ```bash
199
+ sg system create --name "Slack" --template slack
200
+ ```
201
+
202
+ **Full flag reference:**
203
+
204
+ | Flag | Description |
205
+ | ---------------------------------- | ---------------------------------------------------------------------------- |
206
+ | `--name <name>` | Human-readable name — **REQUIRED** |
207
+ | `--id <id>` | System ID (lowercase, underscores only) — derived from name if omitted |
208
+ | `--url <url>` | API base URL — **REQUIRED** (auto-filled by `--template`) |
209
+ | `--template <id>` | Template ID (stripe, shopify, slack, etc.) |
210
+ | `--credentials <json>` | Credentials JSON (use for ALL creds in non-interactive mode) |
211
+ | `--sensitive-credentials <fields>` | Comma-separated fields for masked input (TTY only — do NOT use in AI agents) |
212
+ | `--docs-url <url>` | Documentation URL to scrape |
213
+ | `--openapi-url <url>` | OpenAPI spec URL |
214
+ | `--env <environment>` | Environment: `dev` or `prod` (default: prod) |
215
+
216
+ **`sg system edit`** — Update system config or credentials. Supports `--env dev|prod`.
217
+ **`sg system list` / `sg system find`** — List or search systems. `find` supports `--env dev|prod`.
218
+
219
+ **`sg system call`** — **CRITICAL for tool building.** Make authenticated calls to APIs, databases, and file servers. Use this to:
220
+
221
+ - Explore API endpoints and response structures
222
+ - Verify field names and data shapes BEFORE building tools
223
+
224
+ ```bash
225
+
226
+ # POST request with auth and body
227
+ sg system call --url https://api.example.com/users \
228
+ --system-id my_api \
229
+ --method POST \
230
+ --headers '{"Authorization":"Bearer <<my_api_access_token>>"}' \
231
+ --body '{"name":"test"}'
232
+
233
+ # Database query (Postgres)
234
+ sg system call --url "postgres://<<my_db_host>>:5432/mydb" \
235
+ --system-id my_db \
236
+ --body '{"query":"SELECT * FROM users LIMIT 5"}'
237
+
238
+ # Redis command
239
+ sg system call --url "redis://<<my_redis_host>>:6379/0" \
240
+ --system-id my_redis \
241
+ --body '{"command":"HGETALL","args":["user:123"]}'
242
+
243
+ # File server (SFTP)
244
+ sg system call --url "sftp://<<my_sftp_host>>:22/data" \
245
+ --system-id my_sftp \
246
+ --body '{"operation":"list","path":"/"}'
247
+ ```
248
+
249
+ | Flag | Description |
250
+ | ------------------- | ---------------------------------------------------------------------- |
251
+ | `--url <url>` | Full URL with protocol (http/https/postgres/redis/rediss/sftp/ftp/smb) |
252
+ | `--system-id <id>` | System ID for credential injection |
253
+ | `--method <method>` | HTTP method (GET, POST, PUT, DELETE, PATCH) |
254
+ | `--headers <json>` | HTTP headers JSON with credential placeholders |
255
+ | `--body <string>` | Request body (JSON string) |
256
+ | `--env <env>` | Environment: `dev` or `prod` |
257
+ | `--file <key=path>` | File references (repeatable) |
258
+
259
+ **`sg system search-docs`** — Search system documentation.
260
+
261
+ ```bash
262
+ sg system search-docs --system-id slack -k "send message channels"
263
+ ```
264
+
265
+ **`sg system oauth`** — Authenticate via OAuth.
266
+
267
+ ```bash
268
+ sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
269
+ sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"
270
+ ```
271
+
272
+ | `--system-id <id>` | Required |
273
+ | `--scopes <scopes>` | Space-separated OAuth scopes (required) |
274
+ | `--grant-type <type>` | `authorization_code` (default) or `client_credentials` |
275
+
276
+ ### Run Commands
277
+
278
+ **`sg run list`** — List execution runs. Filter by `--tool`, `--status`, `--source`, `--limit`.
279
+ **`sg run get <runId>`** — Get run details. `--fetch-results` to include data.
280
+
281
+ ---
282
+
283
+ ## Tool Configuration — Full Schema
284
+
285
+ ```json
286
+ {
287
+ "id": "kebab-case-tool-name",
288
+ "instruction": "Brief human-readable description of what this tool does",
289
+ "steps": [
290
+ {
291
+ "id": "unique-step-id",
292
+ "config": {
293
+ "systemId": "example_system",
294
+ "url": "https://api.example.com/endpoint?param=<<payload_field>>",
295
+ "method": "GET",
296
+ "headers": {
297
+ "Authorization": "Bearer <<example_system_access_token>>"
298
+ },
299
+ "queryParams": { "limit": "10" },
300
+ "body": "{ \"key\": \"<<payload_field>>\" }"
301
+ },
302
+ "dataSelector": "(sourceData) => sourceData.previousStep.data.items",
303
+ "failureBehavior": "fail"
304
+ }
305
+ ],
306
+ "outputTransform": "(sourceData) => sourceData.stepId.data",
307
+ "outputSchema": { "type": "object", "properties": {} },
308
+ "inputSchema": { "type": "object", "properties": {} }
309
+ }
310
+ ```
311
+
312
+ ### Step Config Fields (Request Steps)
313
+
314
+ | Field | Type | Description |
315
+ | ------------- | ------ | -------------------------------------------- |
316
+ | `type` | string | `"request"` (default, can be omitted) |
317
+ | `systemId` | string | System whose credentials to use |
318
+ | `url` | string | Full URL with `<<variable>>` placeholders |
319
+ | `method` | string | HTTP method |
320
+ | `headers` | object | HTTP headers with credential placeholders |
321
+ | `queryParams` | object | URL query parameters |
322
+ | `body` | string | Request body (JSON string with placeholders) |
323
+ | `pagination` | object | Auto-pagination config (see below) |
324
+
325
+ ### Step Config Fields (Transform Steps)
326
+
327
+ | Field | Type | Description |
328
+ | --------------- | ------ | ------------------------------------------------ |
329
+ | `type` | string | `"transform"` — **REQUIRED** for transform steps |
330
+ | `transformCode` | string | JS function: `(sourceData) => transformedData` |
331
+
332
+ ### Step Behavior Fields
333
+
334
+ | Field | Type | Description |
335
+ | ----------------- | ------ | ------------------------------------------------ |
336
+ | `dataSelector` | string | JS function controlling step input and loop mode |
337
+ | `failureBehavior` | string | `fail` (default) or `continue` |
338
+
339
+ ---
340
+
341
+ ## Credential Placeholders
342
+
343
+ System credentials are namespaced as `<<systemId_credentialKey>>` and resolved server-side at execution time. **You MUST explicitly reference them in headers.**
344
+
345
+ ### Auth Header Patterns
346
+
347
+ ```json
348
+ {"Authorization": "Bearer <<stripe_api_key>>"}
349
+ {"Authorization": "Bearer <<gmail_access_token>>"}
350
+ {"X-API-Key": "<<my_api_api_key>>"}
351
+ {"Authorization": "Basic <<my_api_username>>:<<my_api_password>>"}
352
+ ```
353
+
354
+ Basic auth is auto-encoded: if the value after `Basic ` isn't already base64, the engine encodes it automatically.
355
+
356
+ ### Credential Lifecycle
357
+
358
+ - Non-sensitive creds (`client_id`, `auth_url`, etc.) are stored via `--credentials`
359
+ - Sensitive creds (`api_key`, `client_secret`) — in non-interactive mode (AI agents, CI), pass via `--credentials` JSON. In interactive TTY, use `--sensitive-credentials` for masked input, or set `SUPERGLUE_CRED_<FIELD>` env vars.
360
+ - OAuth tokens (`access_token`, `refresh_token`) are auto-refreshed before each step execution
361
+
362
+ ---
363
+
364
+ ## Variables and Data Flow
365
+
366
+ ### Variable Syntax
367
+
368
+ All step config fields support `<<variable>>` placeholders:
369
+
370
+ | Syntax | Resolves to |
371
+ | -------------------------- | --------------------------- |
372
+ | `<<fieldName>>` | Payload field or credential |
373
+ | `<<systemId_credKey>>` | System credential |
374
+ | `<<sg_auth_email>>` | Email of authenticated user |
375
+ | `<<(sourceData) => expr>>` | JavaScript expression |
376
+
377
+ **CRITICAL**: Simple `<<varName>>` only works for **top-level keys**. No dots, no nesting.
378
+
379
+ - VALID: `<<userId>>`, `<<currentItem>>`, `<<stripe_api_key>>`, `<<sg_auth_email>>`
380
+ - INVALID: `<<currentItem.id>>`, `<<sourceData.userId>>` — these FAIL at runtime
381
+
382
+ For nested access, use arrow functions: `<<(sourceData) => sourceData.currentItem.id>>`
383
+
384
+ ### Context Variables
385
+
386
+ Context variables provide information about the execution environment:
387
+
388
+ - `<<sg_auth_email>>` — Email of the authenticated user who triggered the tool
389
+
390
+ **Use case**: Personalize tool outputs based on who runs the tool (e.g., user-specific permissions, account lookups, audit logging).
391
+
392
+ **Important**: `sg_auth_email` is NOT available in scheduled executions. Tools using `<<sg_auth_email>>` will fail if run via scheduler.
393
+
394
+ ### sourceData Object
395
+
396
+ `sourceData` is the cumulative state available to all JS expressions (data selectors, transforms, variable expressions):
397
+
398
+ ```javascript
399
+ sourceData = {
400
+ // Payload fields at ROOT level (NEVER use sourceData.payload.*)
401
+ userId: "123",
402
+ date: "2024-01-15",
403
+
404
+ // Previous step results, keyed by step ID
405
+ // Object-selector step:
406
+ getUsers: { currentItem: {}, data: { users: [...] }, success: true },
407
+ // Array-selector (loop) step:
408
+ fetchDetails: [
409
+ { currentItem: "id1", data: { name: "Alice" }, success: true },
410
+ { currentItem: "id2", data: { name: "Bob" }, success: true },
411
+ ],
412
+
413
+ // Current loop item (only set inside a looping step's config)
414
+ currentItem: { id: 1 },
415
+
416
+ // Credentials (flattened, namespaced)
417
+ systemId_access_token: "...",
418
+ systemId_api_key: "..."
419
+ }
420
+ ```
421
+
422
+ ### Step Result Envelope
423
+
424
+ **Every** step result is wrapped in an envelope — you MUST account for this.
425
+
426
+ **Object selector (or no selector)** — step runs once:
427
+
428
+ ```javascript
429
+ sourceData.stepId = { currentItem: <selectorOutput>, data: <apiResponse>, success: true }
430
+ // Access the API response:
431
+ sourceData.stepId.data
432
+ sourceData.stepId.data.users
433
+ ```
434
+
435
+ **Array selector** — step loops, result is an array of envelopes:
436
+
437
+ ```javascript
438
+ sourceData.stepId = [
439
+ { currentItem: <item1>, data: <response1>, success: true },
440
+ { currentItem: <item2>, data: <response2>, success: true },
441
+ ...
442
+ ]
443
+ ```
444
+
445
+ ### Data Selectors
446
+
447
+ Control what a step receives as input and whether it loops:
448
+
449
+ | Return type | Behavior |
450
+ | ------------------ | ----------------------------------- |
451
+ | Single object | Step runs once with that object |
452
+ | Array | Step runs once per item (loop mode) |
453
+ | `undefined`/`null` | Step receives full sourceData |
454
+
455
+ In loop mode, `sourceData.currentItem` is set to the current array element.
456
+
457
+ Empty arrays are valid — the step simply skips execution.
458
+
459
+ ### Two Step Types
460
+
461
+ **Request step** (HTTP, Postgres, Redis, FTP/SFTP/SMB) — makes an API call:
462
+
463
+ ```json
464
+ {
465
+ "id": "get-users",
466
+ "config": {
467
+ "type": "request",
468
+ "systemId": "my_api",
469
+ "url": "https://api.example.com/users",
470
+ "method": "GET",
471
+ "headers": { "Authorization": "Bearer <<my_api_access_token>>" }
472
+ }
473
+ }
474
+ ```
475
+
476
+ **Transform step** — pure JavaScript, no API call. Use when a subsequent request step needs reshaped data:
477
+
478
+ ```json
479
+ {
480
+ "id": "format-data",
481
+ "config": {
482
+ "type": "transform",
483
+ "transformCode": "(sourceData) => sourceData.getUsers.data.map(u => ({ id: u.id, name: u.fullName }))"
484
+ }
485
+ }
486
+ ```
487
+
488
+ Transform steps do NOT have: `systemId`, `url`, `method`, `headers`, `body`, `queryParams`, or `pagination`. The `transformCode` function receives `sourceData` (same object available everywhere) and its return value becomes `.data` in the step envelope.
489
+
490
+ **When to use each:**
491
+
492
+ | Need | Use |
493
+ | ------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
494
+ | Filter/reshape data for a SUBSEQUENT request step | Transform step (`config.type: "transform"`) |
495
+ | Shape the final tool output | `outputTransform` (runs after all steps, has a slightly different schema than transform only steps) |
496
+ | Select input / control looping for a step | `dataSelector` on the step |
497
+ | Inline data computation in URL/body/headers | `<<(sourceData) => ...>>` expressions |
498
+
499
+ ### Execution Pipeline
500
+
501
+ For each step in order:
502
+
503
+ 1. Build `sourceData`: `{ ...originalPayload, ...previousStepResults, ...credentials }`
504
+ 2. Run `dataSelector(sourceData)` → determines single vs loop execution
505
+ 3. For each item: merge `currentItem` into `sourceData`, resolve `<<>>` variables, execute step
506
+ - **Request step**: makes the HTTP/DB/FTP call, raw response becomes `.data`
507
+ - **Transform step**: runs `transformCode(sourceData)`, return value becomes `.data`
508
+ 4. Wrap result: `{ currentItem, data, success }` and store in `sourceData[stepId]`
509
+ 5. After all steps: run `outputTransform(sourceData)` to shape final output
510
+
511
+ ---
512
+
513
+ ## HTTP API Patterns
514
+
515
+ ### Pagination
516
+
517
+ ```json
518
+ {
519
+ "pagination": {
520
+ "type": "offset|cursor|page",
521
+ "pageSize": 100,
522
+ "cursorPath": "$.nextPageToken",
523
+ "stopCondition": "(response) => !response.hasMore"
524
+ }
525
+ }
526
+ ```
527
+
528
+ | Type | How it works |
529
+ | -------- | ------------------------------------------------------------ |
530
+ | `offset` | Increments `offset` param by `pageSize` each page |
531
+ | `cursor` | Extracts next cursor from `cursorPath`, sends as query param |
532
+ | `page` | Increments `page` query param |
533
+
534
+ All types stop when `stopCondition` returns true, response is empty, or max pages reached.
535
+
536
+ ## Systems
537
+
538
+ ### Credential Model
539
+
540
+ - `credentials` — all credentials passed as JSON via `--credentials`
541
+ - `sensitiveCredentials` — interactive masked prompt for secrets (TTY only, NOT for AI agents or CI)
542
+ - **For AI agents / non-interactive use:** pass ALL credentials (including secrets like api_key, client_secret) directly via `--credentials '{"api_key":"..."}'`. Ask the user to provide the secret values, then include them in the JSON.
543
+ - **For human interactive use:** use `--sensitive-credentials` for masked input of secrets
544
+
545
+ ### Templates
546
+
547
+ Templates auto-populate endpoints and OAuth config. Use `sg system find` to discover available templates.
548
+
549
+ **Preconfigured OAuth** (no user client_id/secret needed): slack, salesforce, asana, notion, airtable, jira, confluence
550
+
551
+ ### OAuth Flow
552
+
553
+ **IMPORTANT:** For OAuth systems, prefer `--template` when available because it auto-configures OAuth URLs and defaults. OAuth also works without a template if you provide required credentials (for example `client_id`, `auth_url`, and `token_url`) manually.
554
+
555
+ If you don't know the template ID, the CLI auto-detects it from the URL — but using `--template` explicitly is more reliable.
556
+
557
+ **Step 1: Create the system with template and credentials**
558
+
559
+ ```bash
560
+ # Best: explicit template (auto-fills URL and OAuth config)
561
+ sg system create --name "Gmail" --template gmail \
562
+ --credentials '{"client_id":"...","client_secret":"..."}'
563
+
564
+ # Also works: URL-based auto-detection (template inferred from googleapis.com)
565
+ sg system create --name "Gmail" --url https://gmail.googleapis.com \
566
+ --credentials '{"client_id":"...","client_secret":"..."}'
567
+ ```
568
+
569
+ **Step 2: Authenticate via OAuth**
570
+
571
+ ```bash
572
+ sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
573
+ ```
574
+
575
+ **Step 3:** User authenticates in browser → tokens saved automatically
576
+
577
+ **Common OAuth templates:** gmail, googleDrive, googleCalendar, googleSheets, slack, salesforce, github, jira, confluence, notion, airtable, hubspot, shopify, dropbox, zoom, microsoft
578
+
579
+ ### System IDs
580
+
581
+ - Lowercase letters, numbers, underscores only — **no hyphens**
582
+ - Used for credential namespacing: `<<systemId_credKey>>`
583
+
584
+ ---
585
+
586
+ ## Debugging Failed Tools
587
+
588
+ ### Debug Workflow
589
+
590
+ 1. Run with `--include-step-results` to see raw step responses
591
+ 2. Check each step's `data` field — is the API returning what you expect?
592
+ 3. Verify credential placeholders match `sg system find --id <systemId>` placeholder list
593
+ 4. **Test API calls directly with `sg system call`** — isolate whether the issue is auth, endpoint, or transform
594
+
595
+ ---
596
+
597
+ ## Deploying Tools to Production
598
+
599
+ After building and saving a tool, integrate it into your application:
600
+
601
+ ### REST API (Any Language)
602
+
603
+ ```bash
604
+ # Run a tool
605
+ curl -X POST "https://api.superglue.cloud/v1/tools/{toolId}/run" \
606
+ -H "Authorization: Bearer $SUPERGLUE_API_KEY" \
607
+ -H "Content-Type: application/json" \
608
+ -d '{"inputs": {"userId": "123"}}'
609
+
610
+ # Webhook trigger (async, fire-and-forget)
611
+ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API_KEY" \
612
+ -H "Content-Type: application/json" \
613
+ -d '{"userId": "123"}'
614
+ ```
615
+
616
+ ### TypeScript SDK
617
+
618
+ ```typescript
619
+ import { configure, runTool } from "@superglue/client";
620
+ configure({ apiKey: process.env.SUPERGLUE_API_KEY!, baseUrl: "https://api.superglue.cloud/v1" });
621
+ const response = await runTool("my-tool-id", { inputs: { userId: "123" } });
622
+ // response.data is a Run object: { runId, toolId, status, data, error, metadata }
623
+ ```
624
+
625
+ ### Python SDK
626
+
627
+ ```python
628
+ import os
629
+ from superglue_client import AuthenticatedClient
630
+ from superglue_client.api.tools import run_tool
631
+ from superglue_client.models.run_request import RunRequest
632
+ from superglue_client.models.run_request_inputs import RunRequestInputs
633
+
634
+ client = AuthenticatedClient(base_url="https://api.superglue.cloud/v1", token=os.environ["SUPERGLUE_API_KEY"])
635
+ with client as c:
636
+ result = run_tool.sync("my-tool-id", client=c, body=RunRequest(inputs=RunRequestInputs.from_dict({"userId": "123"})))
637
+ ```
638
+
639
+ ---
640
+
641
+ ## Reference Files
642
+
643
+ For detailed documentation on specific topics, read these files in the `references/` directory:
644
+
645
+ | File | When to read |
646
+ | ------------------------------------- | ------------------------------------------------------------------------------------------------ |
647
+ | `references/integration.md` | **READ THIS** when deploying tools to production - SDK usage, REST API, webhooks, error handling |
648
+ | `references/databases.md` | Building tools that query PostgreSQL/MySQL databases |
649
+ | `references/redis.md` | Building tools that interact with Redis (commands, pipelines, data types) |
650
+ | `references/file-servers.md` | Building tools that interact with FTP/SFTP/SMB file servers |
651
+ | `references/transforms-and-output.md` | Complex data transformations, output shaping, JS sandbox constraints |
652
+
653
+ **Important:** When the user asks about integrating superglue into their codebase, deploying tools, using the SDK, or calling tools from code, you MUST read `references/integration.md` for complete examples.
654
+
655
+ ---
656
+
657
+ ## Draft Management
658
+
659
+ Drafts live in `.superglue/drafts/<draftId>.json`. Created by `build`, updated by `edit`, deleted by `save`. Ephemeral — not persisted across sessions.
660
+
661
+ ## File References
662
+
663
+ Attach files with `--file key=path`. Reference in payloads with `file::<key>`. Auto-parsed to JSON.
664
+
665
+ ```bash
666
+ sg tool run --draft <id> --payload '{"data": "file::mysheet"}' --file mysheet=data.xlsx
667
+ ```
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "superglue"
3
+ short_description: "Build, test, deploy, and integrate superglue API tools via the sg CLI and SDK"
4
+ icon_small: "./assets/superglue.png"
5
+ icon_large: "./assets/superglue.png"
6
+ brand_color: "#FFA500"
7
+ default_prompt: "I need help building a superglue integration tool"