@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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/cli.js +39 -91
- package/dist/dist/cli.js +39 -91
- package/dist/dist/skills/superglue/SKILL.md +124 -240
- package/dist/dist/skills/superglue/references/integration.md +61 -56
- package/dist/skills/superglue/SKILL.md +124 -240
- package/dist/skills/superglue/references/integration.md +61 -56
- package/package.json +1 -1
- package/skills/superglue/SKILL.md +124 -240
- package/skills/superglue/references/integration.md +61 -56
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "superglue",
|
|
3
3
|
"description": "Build, test, and manage superglue tools via the sg CLI. Use when working with superglue tools, systems, APIs, SDKs, or the sg command.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "superglue",
|
|
7
7
|
"email": "hello@superglue.cloud"
|
package/dist/cli.js
CHANGED
|
@@ -1850,16 +1850,16 @@ var require_types = __commonJS({
|
|
|
1850
1850
|
RunStatus2["FAILED"] = "FAILED";
|
|
1851
1851
|
RunStatus2["ABORTED"] = "ABORTED";
|
|
1852
1852
|
})(RunStatus || (exports2.RunStatus = RunStatus = {}));
|
|
1853
|
-
var
|
|
1854
|
-
(function(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
})(
|
|
1853
|
+
var RequestSource2;
|
|
1854
|
+
(function(RequestSource3) {
|
|
1855
|
+
RequestSource3["API"] = "api";
|
|
1856
|
+
RequestSource3["FRONTEND"] = "frontend";
|
|
1857
|
+
RequestSource3["SCHEDULER"] = "scheduler";
|
|
1858
|
+
RequestSource3["MCP"] = "mcp";
|
|
1859
|
+
RequestSource3["TOOL_CHAIN"] = "tool-chain";
|
|
1860
|
+
RequestSource3["WEBHOOK"] = "webhook";
|
|
1861
|
+
RequestSource3["CLI"] = "cli";
|
|
1862
|
+
})(RequestSource2 || (exports2.RequestSource = RequestSource2 = {}));
|
|
1863
1863
|
var FilterTarget;
|
|
1864
1864
|
(function(FilterTarget2) {
|
|
1865
1865
|
FilterTarget2["KEYS"] = "KEYS";
|
|
@@ -2986,10 +2986,15 @@ If the user has or creates an OAuth app in their Google Cloud project:
|
|
|
2986
2986
|
4. After system creation, use authenticate_oauth - user completes Google sign-in in popup
|
|
2987
2987
|
5. Superglue auto-refreshes tokens - no manual token management needed
|
|
2988
2988
|
|
|
2989
|
-
OPTION 2: Service Account
|
|
2990
|
-
If the user has a service account JSON file:
|
|
2991
|
-
-
|
|
2992
|
-
-
|
|
2989
|
+
OPTION 2: Service Account JWT (Advanced)
|
|
2990
|
+
If the user has a service account JSON file, you can generate JWTs dynamically using a transform step:
|
|
2991
|
+
- Extract private_key and client_email from the service account JSON
|
|
2992
|
+
- Build the JWT header and claims, then sign with crypto.sign('sha256', data, privateKey, 'base64url')
|
|
2993
|
+
- Exchange the JWT for an access token via POST to https://oauth2.googleapis.com/token
|
|
2994
|
+
|
|
2995
|
+
OPTION 3: Service Account Token via CLI (Manual refresh required)
|
|
2996
|
+
If the user prefers to generate tokens externally:
|
|
2997
|
+
- User generates an access token on their machine using gcloud CLI:
|
|
2993
2998
|
1. Activate the service account: gcloud auth activate-service-account --key-file=/path/to/service-account.json
|
|
2994
2999
|
2. Print the token: gcloud auth print-access-token
|
|
2995
3000
|
- The token is valid for 1 hour only
|
|
@@ -21233,7 +21238,7 @@ var require_superglue_client = __commonJS({
|
|
|
21233
21238
|
* Execute a single step without creating a run in the database.
|
|
21234
21239
|
* Used for individual step testing in the playground.
|
|
21235
21240
|
*/
|
|
21236
|
-
async executeStep({ step, payload, previousResults, credentials, options, runId, mode }) {
|
|
21241
|
+
async executeStep({ step, payload, previousResults, credentials, options, runId, mode, systemIds }) {
|
|
21237
21242
|
return this.restRequest("POST", "/v1/tools/step/run", {
|
|
21238
21243
|
step,
|
|
21239
21244
|
payload,
|
|
@@ -21241,7 +21246,8 @@ var require_superglue_client = __commonJS({
|
|
|
21241
21246
|
credentials,
|
|
21242
21247
|
options,
|
|
21243
21248
|
runId,
|
|
21244
|
-
mode
|
|
21249
|
+
mode,
|
|
21250
|
+
systemIds
|
|
21245
21251
|
});
|
|
21246
21252
|
}
|
|
21247
21253
|
/**
|
|
@@ -21704,7 +21710,7 @@ var import_node_util = require("util");
|
|
|
21704
21710
|
// package.json
|
|
21705
21711
|
var package_default = {
|
|
21706
21712
|
name: "@superglue/cli",
|
|
21707
|
-
version: "1.1.
|
|
21713
|
+
version: "1.1.3",
|
|
21708
21714
|
bin: {
|
|
21709
21715
|
sg: "./dist/cli.js"
|
|
21710
21716
|
},
|
|
@@ -22614,12 +22620,10 @@ function registerRunCommand(parent, getContext2) {
|
|
|
22614
22620
|
|
|
22615
22621
|
// src/commands/tool/edit.ts
|
|
22616
22622
|
var fs7 = __toESM(require("fs"));
|
|
22617
|
-
var crypto3 = __toESM(require("crypto"));
|
|
22618
22623
|
var import_shared5 = __toESM(require_dist2());
|
|
22619
|
-
var import_shared6 = __toESM(require_dist2());
|
|
22620
22624
|
var jsonpatch = __toESM(require("fast-json-patch"));
|
|
22621
22625
|
function registerEditCommand(parent, getContext2) {
|
|
22622
|
-
parent.command("edit").description("Edit a tool using JSON Patch operations").option("--draft <id>", "Draft ID to edit").option("--tool <id>", "Saved tool ID to edit").option("--patches <json-or-file>", "JSON Patch array (inline JSON or file path)").
|
|
22626
|
+
parent.command("edit").description("Edit a tool using JSON Patch operations").option("--draft <id>", "Draft ID to edit").option("--tool <id>", "Saved tool ID to edit").option("--patches <json-or-file>", "JSON Patch array (inline JSON or file path)").action(async (opts) => {
|
|
22623
22627
|
const { client } = getContext2();
|
|
22624
22628
|
if (!opts.draft && !opts.tool) {
|
|
22625
22629
|
error("Provide --draft or --tool");
|
|
@@ -22666,7 +22670,7 @@ function registerEditCommand(parent, getContext2) {
|
|
|
22666
22670
|
try {
|
|
22667
22671
|
const copy = JSON.parse(JSON.stringify(originalConfig));
|
|
22668
22672
|
const result = jsonpatch.applyPatch(copy, patches, true, true);
|
|
22669
|
-
patchedConfig = (0,
|
|
22673
|
+
patchedConfig = (0, import_shared5.normalizeToolSchemas)(result.newDocument || copy);
|
|
22670
22674
|
} catch (err) {
|
|
22671
22675
|
error(`Patch failed: ${err.message}`);
|
|
22672
22676
|
process.exit(1);
|
|
@@ -22694,67 +22698,11 @@ function registerEditCommand(parent, getContext2) {
|
|
|
22694
22698
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
22695
22699
|
};
|
|
22696
22700
|
writeDraft(draft);
|
|
22697
|
-
if (
|
|
22698
|
-
|
|
22699
|
-
try {
|
|
22700
|
-
payload = opts.payload ? JSON.parse(opts.payload) : {};
|
|
22701
|
-
} catch (err) {
|
|
22702
|
-
error(`Invalid --payload JSON: ${err.message}`);
|
|
22703
|
-
process.exit(1);
|
|
22704
|
-
}
|
|
22705
|
-
const traceId = crypto3.randomUUID();
|
|
22706
|
-
const spin = spinner("Running test...");
|
|
22707
|
-
const logSub = await client.subscribeToLogsSSE({
|
|
22708
|
-
traceId,
|
|
22709
|
-
onLog: (log) => spin.log(`${c.dim}${log.message}${c.reset}`)
|
|
22710
|
-
}).catch(() => ({ unsubscribe: () => {
|
|
22711
|
-
} }));
|
|
22712
|
-
try {
|
|
22713
|
-
const testResult = await client.runToolConfig({
|
|
22714
|
-
tool: draft.config,
|
|
22715
|
-
payload,
|
|
22716
|
-
options: { requestSource: import_shared5.RequestSource.CLI },
|
|
22717
|
-
traceId
|
|
22718
|
-
});
|
|
22719
|
-
logSub.unsubscribe();
|
|
22720
|
-
spin.stop();
|
|
22721
|
-
if (testResult.success) {
|
|
22722
|
-
success("Test passed");
|
|
22723
|
-
} else {
|
|
22724
|
-
error(`Test failed: ${testResult.error || "Unknown error"}`);
|
|
22725
|
-
}
|
|
22726
|
-
if (process.argv.includes("--json") || !process.stdout.isTTY) {
|
|
22727
|
-
output({
|
|
22728
|
-
success: true,
|
|
22729
|
-
draftId: workingDraftId,
|
|
22730
|
-
diffs,
|
|
22731
|
-
testResult: {
|
|
22732
|
-
success: testResult.success,
|
|
22733
|
-
data: testResult.data,
|
|
22734
|
-
error: testResult.error
|
|
22735
|
-
}
|
|
22736
|
-
});
|
|
22737
|
-
} else {
|
|
22738
|
-
output(testResult.data);
|
|
22739
|
-
}
|
|
22740
|
-
} catch (err) {
|
|
22741
|
-
logSub.unsubscribe();
|
|
22742
|
-
spin.stop();
|
|
22743
|
-
error(`Test error: ${err.message}`);
|
|
22744
|
-
output({
|
|
22745
|
-
success: true,
|
|
22746
|
-
draftId: workingDraftId,
|
|
22747
|
-
diffs,
|
|
22748
|
-
testResult: { success: false, error: err.message }
|
|
22749
|
-
});
|
|
22750
|
-
}
|
|
22701
|
+
if (process.argv.includes("--json") || !process.stdout.isTTY) {
|
|
22702
|
+
output({ success: true, draftId: workingDraftId, diffs });
|
|
22751
22703
|
} else {
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
} else {
|
|
22755
|
-
success(`Draft updated: ${c.bold}${workingDraftId}${c.reset}`);
|
|
22756
|
-
console.log("");
|
|
22757
|
-
}
|
|
22704
|
+
success(`Draft updated: ${c.bold}${workingDraftId}${c.reset}`);
|
|
22705
|
+
console.log("");
|
|
22758
22706
|
}
|
|
22759
22707
|
});
|
|
22760
22708
|
}
|
|
@@ -22871,7 +22819,7 @@ function registerToolCommands(program2, getContext2) {
|
|
|
22871
22819
|
// src/commands/system/create.ts
|
|
22872
22820
|
var fs8 = __toESM(require("fs"));
|
|
22873
22821
|
var import_commander = require("commander");
|
|
22874
|
-
var
|
|
22822
|
+
var import_shared6 = __toESM(require_dist2());
|
|
22875
22823
|
async function collectSensitiveCredentials(fields) {
|
|
22876
22824
|
const creds = {};
|
|
22877
22825
|
for (const field of fields) {
|
|
@@ -22928,10 +22876,10 @@ function registerCreateCommand(parent, getContext2) {
|
|
|
22928
22876
|
};
|
|
22929
22877
|
}
|
|
22930
22878
|
if (opts.template) {
|
|
22931
|
-
const template =
|
|
22879
|
+
const template = import_shared6.systems[opts.template];
|
|
22932
22880
|
if (!template) {
|
|
22933
22881
|
error(
|
|
22934
|
-
`Template not found: ${opts.template}. Available: ${Object.keys(
|
|
22882
|
+
`Template not found: ${opts.template}. Available: ${Object.keys(import_shared6.systems).join(", ")}`
|
|
22935
22883
|
);
|
|
22936
22884
|
process.exit(1);
|
|
22937
22885
|
}
|
|
@@ -23069,7 +23017,7 @@ function registerEditCommand2(parent, getContext2) {
|
|
|
23069
23017
|
|
|
23070
23018
|
// src/commands/system/find.ts
|
|
23071
23019
|
var import_commander3 = require("commander");
|
|
23072
|
-
var
|
|
23020
|
+
var import_shared7 = __toESM(require_dist2());
|
|
23073
23021
|
function filterSystemFields(system) {
|
|
23074
23022
|
const credentialKeys = Object.keys(system.credentials || {});
|
|
23075
23023
|
return {
|
|
@@ -23113,7 +23061,7 @@ function registerFindCommand2(parent, getContext2) {
|
|
|
23113
23061
|
error(`System not found: ${opts.id}`);
|
|
23114
23062
|
process.exit(1);
|
|
23115
23063
|
}
|
|
23116
|
-
const templateMatch = (0,
|
|
23064
|
+
const templateMatch = (0, import_shared7.findTemplateForSystem)(system);
|
|
23117
23065
|
output({
|
|
23118
23066
|
success: true,
|
|
23119
23067
|
system: filterSystemFields(system),
|
|
@@ -23149,7 +23097,7 @@ function registerFindCommand2(parent, getContext2) {
|
|
|
23149
23097
|
|
|
23150
23098
|
// src/commands/system/call.ts
|
|
23151
23099
|
var import_commander4 = require("commander");
|
|
23152
|
-
var
|
|
23100
|
+
var import_shared8 = __toESM(require_dist2());
|
|
23153
23101
|
function registerCallCommand(parent, getContext2) {
|
|
23154
23102
|
parent.command("call").description("Call a system (API, database, file server)").requiredOption("--url <url>", "Full URL including protocol").option("--system-id <id>", "System ID for credential injection").option("--method <method>", "HTTP method", "GET").option("--headers <json>", "HTTP headers JSON").option("--body <string>", "Request body").option(
|
|
23155
23103
|
"--file <key=path...>",
|
|
@@ -23220,7 +23168,7 @@ function registerCallCommand(parent, getContext2) {
|
|
|
23220
23168
|
const responseData = result.data?.data !== void 0 ? result.data.data : result.data;
|
|
23221
23169
|
output({
|
|
23222
23170
|
success: result.success,
|
|
23223
|
-
protocol: (0,
|
|
23171
|
+
protocol: (0, import_shared8.getConnectionProtocol)(opts.url),
|
|
23224
23172
|
data: responseData,
|
|
23225
23173
|
...result.error ? { error: result.error } : {}
|
|
23226
23174
|
});
|
|
@@ -23281,7 +23229,7 @@ function registerDocsCommand(parent, getContext2) {
|
|
|
23281
23229
|
|
|
23282
23230
|
// src/commands/system/oauth.ts
|
|
23283
23231
|
var import_node_child_process2 = require("child_process");
|
|
23284
|
-
var
|
|
23232
|
+
var import_shared9 = __toESM(require_dist2());
|
|
23285
23233
|
function openBrowser(url) {
|
|
23286
23234
|
const platform = process.platform;
|
|
23287
23235
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
|
|
@@ -23317,7 +23265,7 @@ function registerOAuthCommand(parent, getContext2) {
|
|
|
23317
23265
|
error(err.message);
|
|
23318
23266
|
process.exit(1);
|
|
23319
23267
|
}
|
|
23320
|
-
const templateMatch = (0,
|
|
23268
|
+
const templateMatch = (0, import_shared9.findTemplateForSystem)(system);
|
|
23321
23269
|
const templateOAuth = templateMatch?.template?.oauth;
|
|
23322
23270
|
const clientId = system.credentials?.client_id ?? templateOAuth?.client_id;
|
|
23323
23271
|
const authUrl = opts.authUrl ?? system.credentials?.auth_url ?? templateOAuth?.authUrl;
|
|
@@ -23395,7 +23343,7 @@ function registerOAuthCommand(parent, getContext2) {
|
|
|
23395
23343
|
error(`Failed to get OAuth encryption secret: ${err.message}`);
|
|
23396
23344
|
process.exit(1);
|
|
23397
23345
|
}
|
|
23398
|
-
const encryptedApiKey = (0,
|
|
23346
|
+
const encryptedApiKey = (0, import_shared9.encryptCliApiKey)(config.apiKey, opts.systemId, encryptionSecret);
|
|
23399
23347
|
const redirectUri = `${config.webEndpoint.replace(/\/$/, "")}/api/auth/callback`;
|
|
23400
23348
|
const state = {
|
|
23401
23349
|
systemId: opts.systemId,
|
package/dist/dist/cli.js
CHANGED
|
@@ -1850,16 +1850,16 @@ var require_types = __commonJS({
|
|
|
1850
1850
|
RunStatus2["FAILED"] = "FAILED";
|
|
1851
1851
|
RunStatus2["ABORTED"] = "ABORTED";
|
|
1852
1852
|
})(RunStatus || (exports2.RunStatus = RunStatus = {}));
|
|
1853
|
-
var
|
|
1854
|
-
(function(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
})(
|
|
1853
|
+
var RequestSource2;
|
|
1854
|
+
(function(RequestSource3) {
|
|
1855
|
+
RequestSource3["API"] = "api";
|
|
1856
|
+
RequestSource3["FRONTEND"] = "frontend";
|
|
1857
|
+
RequestSource3["SCHEDULER"] = "scheduler";
|
|
1858
|
+
RequestSource3["MCP"] = "mcp";
|
|
1859
|
+
RequestSource3["TOOL_CHAIN"] = "tool-chain";
|
|
1860
|
+
RequestSource3["WEBHOOK"] = "webhook";
|
|
1861
|
+
RequestSource3["CLI"] = "cli";
|
|
1862
|
+
})(RequestSource2 || (exports2.RequestSource = RequestSource2 = {}));
|
|
1863
1863
|
var FilterTarget;
|
|
1864
1864
|
(function(FilterTarget2) {
|
|
1865
1865
|
FilterTarget2["KEYS"] = "KEYS";
|
|
@@ -2986,10 +2986,15 @@ If the user has or creates an OAuth app in their Google Cloud project:
|
|
|
2986
2986
|
4. After system creation, use authenticate_oauth - user completes Google sign-in in popup
|
|
2987
2987
|
5. Superglue auto-refreshes tokens - no manual token management needed
|
|
2988
2988
|
|
|
2989
|
-
OPTION 2: Service Account
|
|
2990
|
-
If the user has a service account JSON file:
|
|
2991
|
-
-
|
|
2992
|
-
-
|
|
2989
|
+
OPTION 2: Service Account JWT (Advanced)
|
|
2990
|
+
If the user has a service account JSON file, you can generate JWTs dynamically using a transform step:
|
|
2991
|
+
- Extract private_key and client_email from the service account JSON
|
|
2992
|
+
- Build the JWT header and claims, then sign with crypto.sign('sha256', data, privateKey, 'base64url')
|
|
2993
|
+
- Exchange the JWT for an access token via POST to https://oauth2.googleapis.com/token
|
|
2994
|
+
|
|
2995
|
+
OPTION 3: Service Account Token via CLI (Manual refresh required)
|
|
2996
|
+
If the user prefers to generate tokens externally:
|
|
2997
|
+
- User generates an access token on their machine using gcloud CLI:
|
|
2993
2998
|
1. Activate the service account: gcloud auth activate-service-account --key-file=/path/to/service-account.json
|
|
2994
2999
|
2. Print the token: gcloud auth print-access-token
|
|
2995
3000
|
- The token is valid for 1 hour only
|
|
@@ -21233,7 +21238,7 @@ var require_superglue_client = __commonJS({
|
|
|
21233
21238
|
* Execute a single step without creating a run in the database.
|
|
21234
21239
|
* Used for individual step testing in the playground.
|
|
21235
21240
|
*/
|
|
21236
|
-
async executeStep({ step, payload, previousResults, credentials, options, runId, mode }) {
|
|
21241
|
+
async executeStep({ step, payload, previousResults, credentials, options, runId, mode, systemIds }) {
|
|
21237
21242
|
return this.restRequest("POST", "/v1/tools/step/run", {
|
|
21238
21243
|
step,
|
|
21239
21244
|
payload,
|
|
@@ -21241,7 +21246,8 @@ var require_superglue_client = __commonJS({
|
|
|
21241
21246
|
credentials,
|
|
21242
21247
|
options,
|
|
21243
21248
|
runId,
|
|
21244
|
-
mode
|
|
21249
|
+
mode,
|
|
21250
|
+
systemIds
|
|
21245
21251
|
});
|
|
21246
21252
|
}
|
|
21247
21253
|
/**
|
|
@@ -21704,7 +21710,7 @@ var import_node_util = require("util");
|
|
|
21704
21710
|
// package.json
|
|
21705
21711
|
var package_default = {
|
|
21706
21712
|
name: "@superglue/cli",
|
|
21707
|
-
version: "1.1.
|
|
21713
|
+
version: "1.1.3",
|
|
21708
21714
|
bin: {
|
|
21709
21715
|
sg: "./dist/cli.js"
|
|
21710
21716
|
},
|
|
@@ -22614,12 +22620,10 @@ function registerRunCommand(parent, getContext2) {
|
|
|
22614
22620
|
|
|
22615
22621
|
// src/commands/tool/edit.ts
|
|
22616
22622
|
var fs7 = __toESM(require("fs"));
|
|
22617
|
-
var crypto3 = __toESM(require("crypto"));
|
|
22618
22623
|
var import_shared5 = __toESM(require_dist2());
|
|
22619
|
-
var import_shared6 = __toESM(require_dist2());
|
|
22620
22624
|
var jsonpatch = __toESM(require("fast-json-patch"));
|
|
22621
22625
|
function registerEditCommand(parent, getContext2) {
|
|
22622
|
-
parent.command("edit").description("Edit a tool using JSON Patch operations").option("--draft <id>", "Draft ID to edit").option("--tool <id>", "Saved tool ID to edit").option("--patches <json-or-file>", "JSON Patch array (inline JSON or file path)").
|
|
22626
|
+
parent.command("edit").description("Edit a tool using JSON Patch operations").option("--draft <id>", "Draft ID to edit").option("--tool <id>", "Saved tool ID to edit").option("--patches <json-or-file>", "JSON Patch array (inline JSON or file path)").action(async (opts) => {
|
|
22623
22627
|
const { client } = getContext2();
|
|
22624
22628
|
if (!opts.draft && !opts.tool) {
|
|
22625
22629
|
error("Provide --draft or --tool");
|
|
@@ -22666,7 +22670,7 @@ function registerEditCommand(parent, getContext2) {
|
|
|
22666
22670
|
try {
|
|
22667
22671
|
const copy = JSON.parse(JSON.stringify(originalConfig));
|
|
22668
22672
|
const result = jsonpatch.applyPatch(copy, patches, true, true);
|
|
22669
|
-
patchedConfig = (0,
|
|
22673
|
+
patchedConfig = (0, import_shared5.normalizeToolSchemas)(result.newDocument || copy);
|
|
22670
22674
|
} catch (err) {
|
|
22671
22675
|
error(`Patch failed: ${err.message}`);
|
|
22672
22676
|
process.exit(1);
|
|
@@ -22694,67 +22698,11 @@ function registerEditCommand(parent, getContext2) {
|
|
|
22694
22698
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
22695
22699
|
};
|
|
22696
22700
|
writeDraft(draft);
|
|
22697
|
-
if (
|
|
22698
|
-
|
|
22699
|
-
try {
|
|
22700
|
-
payload = opts.payload ? JSON.parse(opts.payload) : {};
|
|
22701
|
-
} catch (err) {
|
|
22702
|
-
error(`Invalid --payload JSON: ${err.message}`);
|
|
22703
|
-
process.exit(1);
|
|
22704
|
-
}
|
|
22705
|
-
const traceId = crypto3.randomUUID();
|
|
22706
|
-
const spin = spinner("Running test...");
|
|
22707
|
-
const logSub = await client.subscribeToLogsSSE({
|
|
22708
|
-
traceId,
|
|
22709
|
-
onLog: (log) => spin.log(`${c.dim}${log.message}${c.reset}`)
|
|
22710
|
-
}).catch(() => ({ unsubscribe: () => {
|
|
22711
|
-
} }));
|
|
22712
|
-
try {
|
|
22713
|
-
const testResult = await client.runToolConfig({
|
|
22714
|
-
tool: draft.config,
|
|
22715
|
-
payload,
|
|
22716
|
-
options: { requestSource: import_shared5.RequestSource.CLI },
|
|
22717
|
-
traceId
|
|
22718
|
-
});
|
|
22719
|
-
logSub.unsubscribe();
|
|
22720
|
-
spin.stop();
|
|
22721
|
-
if (testResult.success) {
|
|
22722
|
-
success("Test passed");
|
|
22723
|
-
} else {
|
|
22724
|
-
error(`Test failed: ${testResult.error || "Unknown error"}`);
|
|
22725
|
-
}
|
|
22726
|
-
if (process.argv.includes("--json") || !process.stdout.isTTY) {
|
|
22727
|
-
output({
|
|
22728
|
-
success: true,
|
|
22729
|
-
draftId: workingDraftId,
|
|
22730
|
-
diffs,
|
|
22731
|
-
testResult: {
|
|
22732
|
-
success: testResult.success,
|
|
22733
|
-
data: testResult.data,
|
|
22734
|
-
error: testResult.error
|
|
22735
|
-
}
|
|
22736
|
-
});
|
|
22737
|
-
} else {
|
|
22738
|
-
output(testResult.data);
|
|
22739
|
-
}
|
|
22740
|
-
} catch (err) {
|
|
22741
|
-
logSub.unsubscribe();
|
|
22742
|
-
spin.stop();
|
|
22743
|
-
error(`Test error: ${err.message}`);
|
|
22744
|
-
output({
|
|
22745
|
-
success: true,
|
|
22746
|
-
draftId: workingDraftId,
|
|
22747
|
-
diffs,
|
|
22748
|
-
testResult: { success: false, error: err.message }
|
|
22749
|
-
});
|
|
22750
|
-
}
|
|
22701
|
+
if (process.argv.includes("--json") || !process.stdout.isTTY) {
|
|
22702
|
+
output({ success: true, draftId: workingDraftId, diffs });
|
|
22751
22703
|
} else {
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
} else {
|
|
22755
|
-
success(`Draft updated: ${c.bold}${workingDraftId}${c.reset}`);
|
|
22756
|
-
console.log("");
|
|
22757
|
-
}
|
|
22704
|
+
success(`Draft updated: ${c.bold}${workingDraftId}${c.reset}`);
|
|
22705
|
+
console.log("");
|
|
22758
22706
|
}
|
|
22759
22707
|
});
|
|
22760
22708
|
}
|
|
@@ -22871,7 +22819,7 @@ function registerToolCommands(program2, getContext2) {
|
|
|
22871
22819
|
// src/commands/system/create.ts
|
|
22872
22820
|
var fs8 = __toESM(require("fs"));
|
|
22873
22821
|
var import_commander = require("commander");
|
|
22874
|
-
var
|
|
22822
|
+
var import_shared6 = __toESM(require_dist2());
|
|
22875
22823
|
async function collectSensitiveCredentials(fields) {
|
|
22876
22824
|
const creds = {};
|
|
22877
22825
|
for (const field of fields) {
|
|
@@ -22928,10 +22876,10 @@ function registerCreateCommand(parent, getContext2) {
|
|
|
22928
22876
|
};
|
|
22929
22877
|
}
|
|
22930
22878
|
if (opts.template) {
|
|
22931
|
-
const template =
|
|
22879
|
+
const template = import_shared6.systems[opts.template];
|
|
22932
22880
|
if (!template) {
|
|
22933
22881
|
error(
|
|
22934
|
-
`Template not found: ${opts.template}. Available: ${Object.keys(
|
|
22882
|
+
`Template not found: ${opts.template}. Available: ${Object.keys(import_shared6.systems).join(", ")}`
|
|
22935
22883
|
);
|
|
22936
22884
|
process.exit(1);
|
|
22937
22885
|
}
|
|
@@ -23069,7 +23017,7 @@ function registerEditCommand2(parent, getContext2) {
|
|
|
23069
23017
|
|
|
23070
23018
|
// src/commands/system/find.ts
|
|
23071
23019
|
var import_commander3 = require("commander");
|
|
23072
|
-
var
|
|
23020
|
+
var import_shared7 = __toESM(require_dist2());
|
|
23073
23021
|
function filterSystemFields(system) {
|
|
23074
23022
|
const credentialKeys = Object.keys(system.credentials || {});
|
|
23075
23023
|
return {
|
|
@@ -23113,7 +23061,7 @@ function registerFindCommand2(parent, getContext2) {
|
|
|
23113
23061
|
error(`System not found: ${opts.id}`);
|
|
23114
23062
|
process.exit(1);
|
|
23115
23063
|
}
|
|
23116
|
-
const templateMatch = (0,
|
|
23064
|
+
const templateMatch = (0, import_shared7.findTemplateForSystem)(system);
|
|
23117
23065
|
output({
|
|
23118
23066
|
success: true,
|
|
23119
23067
|
system: filterSystemFields(system),
|
|
@@ -23149,7 +23097,7 @@ function registerFindCommand2(parent, getContext2) {
|
|
|
23149
23097
|
|
|
23150
23098
|
// src/commands/system/call.ts
|
|
23151
23099
|
var import_commander4 = require("commander");
|
|
23152
|
-
var
|
|
23100
|
+
var import_shared8 = __toESM(require_dist2());
|
|
23153
23101
|
function registerCallCommand(parent, getContext2) {
|
|
23154
23102
|
parent.command("call").description("Call a system (API, database, file server)").requiredOption("--url <url>", "Full URL including protocol").option("--system-id <id>", "System ID for credential injection").option("--method <method>", "HTTP method", "GET").option("--headers <json>", "HTTP headers JSON").option("--body <string>", "Request body").option(
|
|
23155
23103
|
"--file <key=path...>",
|
|
@@ -23220,7 +23168,7 @@ function registerCallCommand(parent, getContext2) {
|
|
|
23220
23168
|
const responseData = result.data?.data !== void 0 ? result.data.data : result.data;
|
|
23221
23169
|
output({
|
|
23222
23170
|
success: result.success,
|
|
23223
|
-
protocol: (0,
|
|
23171
|
+
protocol: (0, import_shared8.getConnectionProtocol)(opts.url),
|
|
23224
23172
|
data: responseData,
|
|
23225
23173
|
...result.error ? { error: result.error } : {}
|
|
23226
23174
|
});
|
|
@@ -23281,7 +23229,7 @@ function registerDocsCommand(parent, getContext2) {
|
|
|
23281
23229
|
|
|
23282
23230
|
// src/commands/system/oauth.ts
|
|
23283
23231
|
var import_node_child_process2 = require("child_process");
|
|
23284
|
-
var
|
|
23232
|
+
var import_shared9 = __toESM(require_dist2());
|
|
23285
23233
|
function openBrowser(url) {
|
|
23286
23234
|
const platform = process.platform;
|
|
23287
23235
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
|
|
@@ -23317,7 +23265,7 @@ function registerOAuthCommand(parent, getContext2) {
|
|
|
23317
23265
|
error(err.message);
|
|
23318
23266
|
process.exit(1);
|
|
23319
23267
|
}
|
|
23320
|
-
const templateMatch = (0,
|
|
23268
|
+
const templateMatch = (0, import_shared9.findTemplateForSystem)(system);
|
|
23321
23269
|
const templateOAuth = templateMatch?.template?.oauth;
|
|
23322
23270
|
const clientId = system.credentials?.client_id ?? templateOAuth?.client_id;
|
|
23323
23271
|
const authUrl = opts.authUrl ?? system.credentials?.auth_url ?? templateOAuth?.authUrl;
|
|
@@ -23395,7 +23343,7 @@ function registerOAuthCommand(parent, getContext2) {
|
|
|
23395
23343
|
error(`Failed to get OAuth encryption secret: ${err.message}`);
|
|
23396
23344
|
process.exit(1);
|
|
23397
23345
|
}
|
|
23398
|
-
const encryptedApiKey = (0,
|
|
23346
|
+
const encryptedApiKey = (0, import_shared9.encryptCliApiKey)(config.apiKey, opts.systemId, encryptionSecret);
|
|
23399
23347
|
const redirectUri = `${config.webEndpoint.replace(/\/$/, "")}/api/auth/callback`;
|
|
23400
23348
|
const state = {
|
|
23401
23349
|
systemId: opts.systemId,
|