@superglue/cli 1.1.1 → 1.1.3

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.
@@ -15,7 +15,7 @@ export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud"
15
15
  curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/tools/my-tool-id/run" \
16
16
  -H "Authorization: Bearer $SUPERGLUE_API_KEY" \
17
17
  -H "Content-Type: application/json" \
18
- -d '{"inputs": {"userId": "123"}, "options": {"async": false}}'
18
+ -d '{"inputs": {"userId": "123"}}'
19
19
 
20
20
  # Run a tool (async - returns immediately)
21
21
  curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/tools/my-tool-id/run" \
@@ -50,6 +50,7 @@ curl -X POST "$SUPERGLUE_API_ENDPOINT/v1/runs/{runId}/cancel" \
50
50
  "toolId": "my-tool-id",
51
51
  "status": "success",
52
52
  "data": { "result": "..." },
53
+ "stepResults": [{ "stepId": "step-1", "success": true, "data": {} }],
53
54
  "metadata": {
54
55
  "startedAt": "2024-01-15T10:00:00Z",
55
56
  "completedAt": "2024-01-15T10:00:05Z",
@@ -80,103 +81,118 @@ npm install @superglue/client
80
81
  pip install superglue-client
81
82
  ```
82
83
 
84
+ Both SDKs are auto-generated from the OpenAPI spec (JS via orval, Python via openapi-python-client).
85
+
83
86
  ## TypeScript/JavaScript Usage
84
87
 
88
+ The JS SDK exports: `configure`, `listTools`, `getTool`, `runTool`, `getRun`, `cancelRun`, `triggerWebhook`, `listRuns`.
89
+
85
90
  ```typescript
86
- import { configure, listTools, runTool, getRun } from "@superglue/client";
91
+ import { configure, runTool, getRun, listTools, getTool } from "@superglue/client";
87
92
 
88
- // Configure once at startup
89
93
  configure({
90
- apiKey: process.env.SUPERGLUE_API_KEY,
91
- baseUrl: "https://api.superglue.cloud/v1", // or your self-hosted endpoint
94
+ apiKey: process.env.SUPERGLUE_API_KEY!,
95
+ baseUrl: "https://api.superglue.cloud/v1",
92
96
  });
97
+ ```
93
98
 
94
- // Run a tool (sync - waits for completion)
95
- const { data: result } = await runTool("my-tool-id", {
99
+ ### Run a Tool (Sync)
100
+
101
+ ```typescript
102
+ const response = await runTool("my-tool-id", {
96
103
  inputs: { userId: "123", date: "2024-01-15" },
97
- options: { async: false },
98
104
  });
99
105
 
100
- if (result.status === "success") {
101
- console.log(result.data);
106
+ if (response.status === 200) {
107
+ const run = response.data;
108
+ console.log(run.status); // "success" | "failed"
109
+ console.log(run.data); // tool output
102
110
  } else {
103
- console.error(result.error);
111
+ console.error("Error:", response.data);
104
112
  }
105
113
  ```
106
114
 
115
+ The response is `{ data: Run, status: number, headers: Headers }`. The `Run` object has: `runId`, `toolId`, `status`, `data`, `error`, `stepResults`, `metadata`.
116
+
107
117
  ### Async Execution (Fire-and-Forget)
108
118
 
109
119
  ```typescript
110
- // Run async - returns immediately
111
- const { data: run } = await runTool("my-tool-id", {
120
+ const response = await runTool("my-tool-id", {
112
121
  inputs: { userId: "123" },
113
122
  options: { async: true },
114
123
  });
115
124
 
116
- console.log(`Run started: ${run.runId}`);
125
+ if (response.status === 202) {
126
+ const run = response.data;
127
+ console.log(`Run started: ${run.runId}`);
117
128
 
118
- // Poll for completion if needed
119
- let status = run;
120
- while (status.status === "running") {
121
- await new Promise((r) => setTimeout(r, 1000));
122
- const { data } = await getRun(status.runId);
123
- status = data;
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
+ }
124
135
  }
125
136
  ```
126
137
 
127
138
  ### List and Discover Tools
128
139
 
129
140
  ```typescript
130
- import { listTools, getTool, listSystems } from "@superglue/client";
131
-
132
- // List all tools
133
141
  const { data: tools } = await listTools({ page: 1, limit: 50 });
134
142
  console.log(tools.data);
135
143
 
136
- // Get tool details (including inputSchema)
137
144
  const { data: tool } = await getTool("my-tool-id");
138
145
  console.log(tool.inputSchema);
139
-
140
- // List systems
141
- const { data: systems } = await listSystems();
142
146
  ```
143
147
 
144
148
  ## Python Usage
145
149
 
150
+ The Python SDK uses `AuthenticatedClient` with httpx. Functions are in `superglue_client.api.tools` and `superglue_client.api.runs`.
151
+
146
152
  ```python
147
153
  import os
148
- from superglue_client import SuperglueClient
154
+ from superglue_client import AuthenticatedClient
149
155
  from superglue_client.api.tools import run_tool, list_tools, get_tool
150
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
151
159
 
152
- # Create authenticated client
153
- client = SuperglueClient(
160
+ client = AuthenticatedClient(
154
161
  base_url="https://api.superglue.cloud/v1",
155
- token=os.environ["SUPERGLUE_API_KEY"]
162
+ token=os.environ["SUPERGLUE_API_KEY"],
156
163
  )
164
+ ```
157
165
 
158
- # Run a tool (sync)
166
+ ### Run a Tool (Sync)
167
+
168
+ ```python
159
169
  with client as c:
160
170
  result = run_tool.sync(
171
+ "my-tool-id",
161
172
  client=c,
162
- tool_id="my-tool-id",
163
- body={"inputs": {"userId": "123"}, "options": {"async": False}}
173
+ body=RunRequest(
174
+ inputs=RunRequestInputs.from_dict({"userId": "123"}),
175
+ ),
164
176
  )
165
177
 
166
- if result.status == "success":
178
+ if hasattr(result, "status") and result.status == "success":
167
179
  print(result.data)
168
- else:
180
+ elif hasattr(result, "error"):
169
181
  print(result.error)
170
182
  ```
171
183
 
184
+ `sync()` returns `Run | Error | None`. Use `sync_detailed()` for the full `Response` wrapper with status code and headers.
185
+
172
186
  ### Async Python
173
187
 
174
188
  ```python
175
189
  async with client as c:
176
190
  result = await run_tool.asyncio(
191
+ "my-tool-id",
177
192
  client=c,
178
- tool_id="my-tool-id",
179
- body={"inputs": {"userId": "123"}}
193
+ body=RunRequest(
194
+ inputs=RunRequestInputs.from_dict({"userId": "123"}),
195
+ ),
180
196
  )
181
197
  ```
182
198
 
@@ -226,14 +242,16 @@ curl "https://api.superglue.cloud/v1/runs/{runId}" \
226
242
  ```typescript
227
243
  async function runToolWithRetry(toolId: string, inputs: Record<string, any>, maxRetries = 3) {
228
244
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
229
- const { data: result } = await runTool(toolId, { inputs, options: { async: false } });
245
+ const response = await runTool(toolId, { inputs });
230
246
 
231
- if (result.status === "success") return result;
247
+ if (response.status === 200 && response.data.status === "success") {
248
+ return response.data;
249
+ }
232
250
 
233
- // Don't retry on validation errors
234
- if (result.error?.includes("validation")) throw new Error(result.error);
251
+ if (response.data.error?.includes("validation")) {
252
+ throw new Error(response.data.error);
253
+ }
235
254
 
236
- // Exponential backoff for transient errors
237
255
  if (attempt < maxRetries) {
238
256
  await new Promise((r) => setTimeout(r, 1000 * Math.pow(2, attempt)));
239
257
  }
@@ -242,19 +260,6 @@ async function runToolWithRetry(toolId: string, inputs: Record<string, any>, max
242
260
  }
243
261
  ```
244
262
 
245
- ### Fallback Pattern
246
-
247
- ```typescript
248
- async function runWithFallback(inputs: Record<string, any>) {
249
- const { data: primary } = await runTool("primary-tool", { inputs, options: { async: false } });
250
- if (primary.status === "success") return primary;
251
-
252
- console.warn("Primary tool failed, using fallback");
253
- const { data: fallback } = await runTool("fallback-tool", { inputs, options: { async: false } });
254
- return fallback;
255
- }
256
- ```
257
-
258
263
  ## Environment Configuration
259
264
 
260
265
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },