@superglue/cli 1.1.11 → 1.1.13

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.
@@ -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": "0.1.0",
4
+ "version": "1.1.13",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
@@ -9,5 +9,12 @@
9
9
  "homepage": "https://superglue.cloud",
10
10
  "repository": "https://github.com/superglue-ai/cli",
11
11
  "license": "MIT",
12
- "keywords": ["systems", "integration", "cli", "tools", "automation", "api"]
12
+ "keywords": [
13
+ "systems",
14
+ "integration",
15
+ "cli",
16
+ "tools",
17
+ "automation",
18
+ "api"
19
+ ]
13
20
  }
package/dist/cli.js CHANGED
@@ -1742,21 +1742,67 @@ var require_json_schema = __commonJS({
1742
1742
  }
1743
1743
  });
1744
1744
 
1745
+ // ../shared/dist/rbac-utils.js
1746
+ var require_rbac_utils = __commonJS({
1747
+ "../shared/dist/rbac-utils.js"(exports2) {
1748
+ "use strict";
1749
+ Object.defineProperty(exports2, "__esModule", { value: true });
1750
+ exports2.RESERVED_ROLE_NAMES = exports2.RESERVED_ROLE_IDS = exports2.PREDEFINED_ROLE_IDS = void 0;
1751
+ exports2.isCustomRulePermission = isCustomRulePermission;
1752
+ exports2.getSystemRules = getSystemRules;
1753
+ exports2.isPredefinedRole = isPredefinedRole;
1754
+ exports2.isReservedRoleId = isReservedRoleId;
1755
+ exports2.isReservedRoleName = isReservedRoleName;
1756
+ exports2.hasRole = hasRole;
1757
+ exports2.getRoleIds = getRoleIds;
1758
+ exports2.getBaseRole = getBaseRole;
1759
+ exports2.getBaseRoleId = getBaseRoleId;
1760
+ function isCustomRulePermission(p) {
1761
+ return typeof p === "object" && p !== null && "rules" in p;
1762
+ }
1763
+ function getSystemRules(systems2, systemId) {
1764
+ if (systems2 === "ALL" || !systems2[systemId])
1765
+ return [];
1766
+ const p = systems2[systemId];
1767
+ return isCustomRulePermission(p) ? p.rules : [];
1768
+ }
1769
+ exports2.PREDEFINED_ROLE_IDS = ["admin", "member", "enduser"];
1770
+ exports2.RESERVED_ROLE_IDS = ["admin", "member", "enduser", "__admin__"];
1771
+ exports2.RESERVED_ROLE_NAMES = ["member", "end user", "enduser", "admin"];
1772
+ function isPredefinedRole(roleId) {
1773
+ return exports2.PREDEFINED_ROLE_IDS.includes(roleId);
1774
+ }
1775
+ function isReservedRoleId(roleId) {
1776
+ return exports2.RESERVED_ROLE_IDS.includes(roleId);
1777
+ }
1778
+ function isReservedRoleName(name) {
1779
+ return exports2.RESERVED_ROLE_NAMES.includes(name.toLowerCase().trim());
1780
+ }
1781
+ function hasRole(roles, roleId) {
1782
+ return roles.some((r) => r.id === roleId);
1783
+ }
1784
+ function getRoleIds(roles) {
1785
+ return roles.map((r) => r.id);
1786
+ }
1787
+ function getBaseRole(roles) {
1788
+ const baseRoles = roles.filter((r) => r.isBaseRole);
1789
+ return baseRoles.length === 1 ? baseRoles[0] : null;
1790
+ }
1791
+ function getBaseRoleId(roles) {
1792
+ const base = getBaseRole(roles);
1793
+ return base ? base.id : null;
1794
+ }
1795
+ }
1796
+ });
1797
+
1745
1798
  // ../shared/dist/types.js
1746
1799
  var require_types = __commonJS({
1747
1800
  "../shared/dist/types.js"(exports2) {
1748
1801
  "use strict";
1749
1802
  Object.defineProperty(exports2, "__esModule", { value: true });
1750
- exports2.ConfirmationAction = exports2.FileStatus = exports2.DiscoveryRunStatus = exports2.RemoveScope = exports2.FilterAction = exports2.FilterTarget = exports2.RequestSource = exports2.RunStatus = exports2.CredentialMode = exports2.UpsertMode = exports2.LogLevel = exports2.PaginationType = exports2.DecompressionMethod = exports2.AuthType = exports2.FileType = exports2.CacheMode = exports2.HttpMethod = exports2.SupportedFileType = exports2.UserRole = void 0;
1803
+ exports2.SystemAccessLevel = exports2.ConfirmationAction = exports2.FileStatus = exports2.DiscoveryRunStatus = exports2.RemoveScope = exports2.FilterAction = exports2.FilterTarget = exports2.RequestSource = exports2.RunStatus = exports2.CredentialMode = exports2.UpsertMode = exports2.LogLevel = exports2.PaginationType = exports2.DecompressionMethod = exports2.AuthType = exports2.FileType = exports2.CacheMode = exports2.HttpMethod = exports2.SupportedFileType = void 0;
1751
1804
  exports2.isRequestConfig = isRequestConfig;
1752
1805
  exports2.isTransformConfig = isTransformConfig;
1753
- exports2.getToolSystemIds = getToolSystemIds;
1754
- exports2.isProductionSystem = isProductionSystem;
1755
- var UserRole;
1756
- (function(UserRole2) {
1757
- UserRole2["ADMIN"] = "admin";
1758
- UserRole2["MEMBER"] = "member";
1759
- })(UserRole || (exports2.UserRole = UserRole = {}));
1760
1806
  var SupportedFileType;
1761
1807
  (function(SupportedFileType2) {
1762
1808
  SupportedFileType2["JSON"] = "JSON";
@@ -1884,20 +1930,6 @@ var require_types = __commonJS({
1884
1930
  function isTransformConfig(config) {
1885
1931
  return config?.type === "transform";
1886
1932
  }
1887
- function getToolSystemIds(tool) {
1888
- if (!tool.steps)
1889
- return [];
1890
- const ids = /* @__PURE__ */ new Set();
1891
- for (const step of tool.steps) {
1892
- if (step.config && isRequestConfig(step.config) && step.config.systemId) {
1893
- ids.add(step.config.systemId);
1894
- }
1895
- }
1896
- return Array.from(ids);
1897
- }
1898
- function isProductionSystem(system) {
1899
- return system.environment !== "dev";
1900
- }
1901
1933
  var DiscoveryRunStatus;
1902
1934
  (function(DiscoveryRunStatus2) {
1903
1935
  DiscoveryRunStatus2["PENDING"] = "PENDING";
@@ -1922,6 +1954,12 @@ var require_types = __commonJS({
1922
1954
  ConfirmationAction2["OAUTH_SUCCESS"] = "oauth_success";
1923
1955
  ConfirmationAction2["OAUTH_FAILURE"] = "oauth_failure";
1924
1956
  })(ConfirmationAction || (exports2.ConfirmationAction = ConfirmationAction = {}));
1957
+ var SystemAccessLevel;
1958
+ (function(SystemAccessLevel2) {
1959
+ SystemAccessLevel2["NONE"] = "none";
1960
+ SystemAccessLevel2["READ_ONLY"] = "read-only";
1961
+ SystemAccessLevel2["READ_WRITE"] = "read-write";
1962
+ })(SystemAccessLevel || (exports2.SystemAccessLevel = SystemAccessLevel = {}));
1925
1963
  }
1926
1964
  });
1927
1965
 
@@ -20091,6 +20129,7 @@ var require_utils = __commonJS({
20091
20129
  };
20092
20130
  Object.defineProperty(exports2, "__esModule", { value: true });
20093
20131
  exports2.ALLOWED_PATCH_SYSTEM_FIELDS = exports2.getSystemAuthStatus = exports2.detectSystemAuthType = exports2.maskSystemCredentials = exports2.isSensitiveCredentialKey = exports2.ALLOWED_FILE_EXTENSIONS = exports2.getConnectionProtocol = void 0;
20132
+ exports2.isAbortError = isAbortError;
20094
20133
  exports2.validateExternalUrl = validateExternalUrl;
20095
20134
  exports2.flattenAndNamespaceCredentials = flattenAndNamespaceCredentials;
20096
20135
  exports2.flattenAndNamespaceSystemUrls = flattenAndNamespaceSystemUrls;
@@ -20098,7 +20137,6 @@ var require_utils = __commonJS({
20098
20137
  exports2.generateUniqueId = generateUniqueId;
20099
20138
  exports2.waitForSystemProcessing = waitForSystemProcessing;
20100
20139
  exports2.inferJsonSchema = inferJsonSchema;
20101
- exports2.mapUserRole = mapUserRole;
20102
20140
  exports2.resolveOAuthCertAndKey = resolveOAuthCertAndKey;
20103
20141
  exports2.isArrowFunction = isArrowFunction;
20104
20142
  exports2.assertValidArrowFunction = assertValidArrowFunction;
@@ -20115,6 +20153,8 @@ var require_utils = __commonJS({
20115
20153
  exports2.normalizeToolDiffs = normalizeToolDiffs;
20116
20154
  exports2.composeUrl = composeUrl;
20117
20155
  exports2.truncateRunResult = truncateRunResult;
20156
+ exports2.getToolSystemIds = getToolSystemIds;
20157
+ exports2.isProductionSystem = isProductionSystem;
20118
20158
  var json_schema_js_1 = require_json_schema();
20119
20159
  var types_js_1 = require_types();
20120
20160
  var truncate_json_1 = __importDefault((init_main5(), __toCommonJS(main_exports)));
@@ -20133,6 +20173,18 @@ var require_utils = __commonJS({
20133
20173
  return "http";
20134
20174
  };
20135
20175
  exports2.getConnectionProtocol = getConnectionProtocol2;
20176
+ function isAbortError(error2) {
20177
+ if (!error2)
20178
+ return false;
20179
+ if (typeof error2 === "string")
20180
+ return error2.startsWith("AbortError:");
20181
+ if (error2 instanceof DOMException)
20182
+ return error2.name === "AbortError";
20183
+ if (error2 instanceof Error) {
20184
+ return error2.name === "AbortError" || error2.message.startsWith("AbortError:");
20185
+ }
20186
+ return false;
20187
+ }
20136
20188
  function validateExternalUrl(raw) {
20137
20189
  const parsed = new URL(raw);
20138
20190
  if (!["http:", "https:"].includes(parsed.protocol)) {
@@ -20364,16 +20416,6 @@ var require_utils = __commonJS({
20364
20416
  }
20365
20417
  return buildArraySchemaFromData(data);
20366
20418
  }
20367
- function mapUserRole(role) {
20368
- switch (role) {
20369
- case "admin":
20370
- return types_js_1.UserRole.ADMIN;
20371
- case "member":
20372
- return types_js_1.UserRole.MEMBER;
20373
- default:
20374
- return types_js_1.UserRole.MEMBER;
20375
- }
20376
- }
20377
20419
  function resolveOAuthCertAndKey(oauthCert, oauthKey) {
20378
20420
  let parsedCert = null;
20379
20421
  let parsedKey = null;
@@ -20767,6 +20809,20 @@ var require_utils = __commonJS({
20767
20809
  };
20768
20810
  }
20769
20811
  }
20812
+ function getToolSystemIds(tool) {
20813
+ if (!tool.steps)
20814
+ return [];
20815
+ const ids = /* @__PURE__ */ new Set();
20816
+ for (const step of tool.steps) {
20817
+ if (step.config && (0, types_js_1.isRequestConfig)(step.config) && step.config.systemId) {
20818
+ ids.add(step.config.systemId);
20819
+ }
20820
+ }
20821
+ return Array.from(ids);
20822
+ }
20823
+ function isProductionSystem(system) {
20824
+ return system.environment !== "dev";
20825
+ }
20770
20826
  }
20771
20827
  });
20772
20828
 
@@ -21338,6 +21394,7 @@ var require_superglue_client = __commonJS({
21338
21394
  exports2.SuperglueClient = void 0;
21339
21395
  var types_js_1 = require_types();
21340
21396
  var sse_log_subscription_js_1 = require_sse_log_subscription();
21397
+ var utils_js_1 = require_utils();
21341
21398
  var SuperglueClient3 = class {
21342
21399
  constructor({ apiKey, apiEndpoint, onInfrastructureError }) {
21343
21400
  this.apiKey = apiKey;
@@ -21346,15 +21403,15 @@ var require_superglue_client = __commonJS({
21346
21403
  this.onInfrastructureError = onInfrastructureError;
21347
21404
  }
21348
21405
  isInfrastructureError(error2) {
21406
+ if ((0, utils_js_1.isAbortError)(error2))
21407
+ return false;
21349
21408
  if (error2 instanceof TypeError && error2.message.toLowerCase().includes("fetch"))
21350
21409
  return true;
21351
- if (error2 instanceof DOMException && error2.name === "AbortError")
21352
- return true;
21353
21410
  if (error2 instanceof Error && error2.name === "TimeoutError")
21354
21411
  return true;
21355
21412
  return false;
21356
21413
  }
21357
- async restRequest(method, path7, body, extraHeaders) {
21414
+ async restRequest(method, path7, body, extraHeaders, requestInit) {
21358
21415
  const url = `${this.apiEndpoint.replace(/\/$/, "")}${path7}`;
21359
21416
  const headers = {
21360
21417
  Authorization: `Bearer ${this.apiKey}`,
@@ -21368,7 +21425,8 @@ var require_superglue_client = __commonJS({
21368
21425
  response = await fetch(url, {
21369
21426
  method,
21370
21427
  headers,
21371
- body: body ? JSON.stringify(body) : void 0
21428
+ body: body ? JSON.stringify(body) : void 0,
21429
+ signal: requestInit?.signal
21372
21430
  });
21373
21431
  } catch (error2) {
21374
21432
  if (this.isInfrastructureError(error2)) {
@@ -21568,13 +21626,23 @@ var require_superglue_client = __commonJS({
21568
21626
  };
21569
21627
  }
21570
21628
  async listRuns(options) {
21571
- const { limit = 100, page = 1, toolId, status, requestSources, userId, systemId } = options ?? {};
21629
+ const { limit = 100, page = 1, toolId, search, searchUserIds, includeTotal = true, startedAfter, status, requestSources, userId, systemId, signal } = options ?? {};
21572
21630
  const params = new URLSearchParams({
21573
21631
  limit: String(limit),
21574
21632
  page: String(page)
21575
21633
  });
21576
21634
  if (toolId)
21577
21635
  params.set("toolId", toolId);
21636
+ if (search?.trim())
21637
+ params.set("search", search.trim());
21638
+ if (searchUserIds && searchUserIds.length > 0) {
21639
+ params.set("searchUserIds", searchUserIds.join(","));
21640
+ }
21641
+ if (!includeTotal)
21642
+ params.set("includeTotal", "false");
21643
+ if (startedAfter) {
21644
+ params.set("startedAfter", startedAfter instanceof Date ? startedAfter.toISOString() : startedAfter);
21645
+ }
21578
21646
  if (status)
21579
21647
  params.set("status", status);
21580
21648
  if (requestSources && requestSources.length > 0) {
@@ -21584,7 +21652,7 @@ var require_superglue_client = __commonJS({
21584
21652
  params.set("userId", userId);
21585
21653
  if (systemId)
21586
21654
  params.set("systemId", systemId);
21587
- const response = await this.restRequest("GET", `/v1/runs?${params.toString()}`);
21655
+ const response = await this.restRequest("GET", `/v1/runs?${params.toString()}`, void 0, void 0, { signal });
21588
21656
  return {
21589
21657
  items: response.data.map((run) => this.mapOpenAPIRunToRun(run)),
21590
21658
  total: response.total,
@@ -21611,15 +21679,19 @@ var require_superglue_client = __commonJS({
21611
21679
  if (err.message?.includes("404") || err.message?.includes("not found")) {
21612
21680
  return null;
21613
21681
  }
21682
+ if (err.message?.includes("403") || err.message?.includes("not allowed")) {
21683
+ return null;
21684
+ }
21614
21685
  throw err;
21615
21686
  }
21616
21687
  }
21617
21688
  async archiveWorkflow(id, archived = true) {
21618
21689
  return this.upsertWorkflow(id, { archived });
21619
21690
  }
21620
- async listWorkflows(limit = 10, offset = 0) {
21691
+ async listWorkflows(limit = 10, offset = 0, includeArchived = false) {
21621
21692
  const page = Math.floor(offset / limit) + 1;
21622
- const response = await this.restRequest("GET", `/v1/tools?limit=${limit}&page=${page}`);
21693
+ const archiveParam = includeArchived ? "&includeArchived=true" : "";
21694
+ const response = await this.restRequest("GET", `/v1/tools?limit=${limit}&page=${page}${archiveParam}`);
21623
21695
  return { items: response.data, total: response.total };
21624
21696
  }
21625
21697
  async upsertWorkflow(id, input) {
@@ -21657,11 +21729,6 @@ var require_superglue_client = __commonJS({
21657
21729
  const response = await this.restRequest("GET", `/v1/systems?${params.toString()}`);
21658
21730
  return { items: response.data, total: response.total };
21659
21731
  }
21660
- async findRelevantTools(searchTerms) {
21661
- const params = searchTerms ? `?q=${encodeURIComponent(searchTerms)}` : "";
21662
- const response = await this.restRequest("GET", `/v1/tools/search${params}`);
21663
- return response.data;
21664
- }
21665
21732
  async getSystem(id, options) {
21666
21733
  const queryParams = options?.environment ? `?env=${options.environment}` : "";
21667
21734
  const response = await this.restRequest("GET", `/v1/systems/${encodeURIComponent(id)}${queryParams}`);
@@ -21817,6 +21884,7 @@ var require_dist2 = __commonJS({
21817
21884
  Object.defineProperty(exports2, "__esModule", { value: true });
21818
21885
  exports2.SSELogSubscriptionManager = exports2.SuperglueClient = void 0;
21819
21886
  __exportStar(require_json_schema(), exports2);
21887
+ __exportStar(require_rbac_utils(), exports2);
21820
21888
  __exportStar(require_seed_config(), exports2);
21821
21889
  __exportStar(require_templates(), exports2);
21822
21890
  __exportStar(require_type_utils(), exports2);
@@ -21836,7 +21904,7 @@ var require_dist2 = __commonJS({
21836
21904
  });
21837
21905
 
21838
21906
  // src/cli.ts
21839
- var import_commander5 = require("commander");
21907
+ var import_commander6 = require("commander");
21840
21908
 
21841
21909
  // src/config.ts
21842
21910
  var fs = __toESM(require("fs"));
@@ -21922,6 +21990,7 @@ function createClient(config) {
21922
21990
  var fs2 = __toESM(require("fs"));
21923
21991
  var path2 = __toESM(require("path"));
21924
21992
  var os2 = __toESM(require("os"));
21993
+ var import_commander = require("commander");
21925
21994
  var import_shared2 = __toESM(require_dist2());
21926
21995
 
21927
21996
  // src/output.ts
@@ -21934,7 +22003,7 @@ var import_node_util = require("util");
21934
22003
  // package.json
21935
22004
  var package_default = {
21936
22005
  name: "@superglue/cli",
21937
- version: "1.1.11",
22006
+ version: "1.1.13",
21938
22007
  bin: {
21939
22008
  sg: "./dist/cli.js"
21940
22009
  },
@@ -22459,8 +22528,13 @@ async function choose(message, options, defaultIndex = 0) {
22459
22528
 
22460
22529
  // src/commands/init.ts
22461
22530
  function registerInitCommand(program2) {
22462
- program2.command("init").description("Set up superglue CLI configuration").option("--api-key <key>", "API key (skips interactive prompt)").option("--endpoint <url>", "API endpoint", "https://api.superglue.cloud").option("--web-endpoint <url>", "Web endpoint for OAuth callbacks").option("--output-mode <mode>", "Output mode: stdout or stdout+file", "stdout").option("--output-dir <dir>", "Output directory for stdout+file mode", ".superglue/output").option("--global", "Save config globally (~/.superglue/) instead of locally").action(async (opts) => {
22463
- const isNonInteractive = opts.apiKey || !process.stdin.isTTY;
22531
+ program2.command("init").description("Set up superglue CLI configuration").option("--web-endpoint <url>", "Web endpoint for OAuth callbacks").addOption(
22532
+ new import_commander.Option("--output-mode <mode>", "Output mode: stdout or stdout+file").choices(["stdout", "stdout+file"]).default("stdout")
22533
+ ).option("--output-dir <dir>", "Output directory for stdout+file mode", ".superglue/output").option("--global", "Save config globally (~/.superglue/) instead of locally").action(async function(opts) {
22534
+ const parentOpts = this.parent?.opts() ?? {};
22535
+ const resolvedApiKey = parentOpts.apiKey || process.env.SUPERGLUE_API_KEY;
22536
+ const resolvedEndpoint = parentOpts.endpoint || process.env.SUPERGLUE_API_ENDPOINT;
22537
+ const isNonInteractive = resolvedApiKey || !process.stdin.isTTY;
22464
22538
  let apiKey;
22465
22539
  let endpoint;
22466
22540
  let webEndpoint;
@@ -22468,12 +22542,12 @@ function registerInitCommand(program2) {
22468
22542
  let outputDir;
22469
22543
  let preferLocal;
22470
22544
  if (isNonInteractive) {
22471
- apiKey = opts.apiKey || process.env.SUPERGLUE_API_KEY;
22545
+ apiKey = resolvedApiKey;
22472
22546
  if (!apiKey) {
22473
22547
  error("API key is required (--api-key or SUPERGLUE_API_KEY)");
22474
22548
  process.exit(1);
22475
22549
  }
22476
- endpoint = opts.endpoint;
22550
+ endpoint = resolvedEndpoint || "https://api.superglue.cloud";
22477
22551
  const defaultWeb = endpoint.replace(/:3002\b/, ":3001").replace(/api\.superglue/, "app.superglue");
22478
22552
  webEndpoint = opts.webEndpoint || defaultWeb;
22479
22553
  outputMode = opts.outputMode === "stdout+file" ? "stdout+file" : "stdout";
@@ -22504,7 +22578,10 @@ function registerInitCommand(program2) {
22504
22578
  error("API key is required");
22505
22579
  process.exit(1);
22506
22580
  }
22507
- endpoint = await prompt(" API Endpoint", opts.endpoint);
22581
+ endpoint = await prompt(
22582
+ " API Endpoint",
22583
+ resolvedEndpoint || "https://api.superglue.cloud"
22584
+ );
22508
22585
  const defaultWeb = endpoint.replace(/:3002\b/, ":3001").replace(/api\.superglue/, "app.superglue");
22509
22586
  webEndpoint = await prompt(" Web Endpoint (for OAuth callbacks)", defaultWeb);
22510
22587
  const spin = spinner("Verifying connection...");
@@ -23030,10 +23107,9 @@ function registerFindCommand(parent, getContext2) {
23030
23107
  parent.command("list").description("List all tools").action(async () => {
23031
23108
  const { client } = getContext2();
23032
23109
  try {
23033
- const { items } = await client.listWorkflows(100);
23034
- const tools = items.filter((t) => !t.archived);
23110
+ const { items } = await client.listWorkflows(1e3);
23035
23111
  table(
23036
- tools.map((t) => ({
23112
+ items.map((t) => ({
23037
23113
  id: t.id,
23038
23114
  instruction: (t.instruction || "").slice(0, 60),
23039
23115
  steps: t.steps?.length || 0
@@ -23058,25 +23134,29 @@ function registerFindCommand(parent, getContext2) {
23058
23134
  return;
23059
23135
  }
23060
23136
  const searchQuery = (query || "").trim() || "*";
23061
- if (searchQuery === "*") {
23062
- const { items } = await client.listWorkflows(100);
23063
- const tools = items.filter((t) => !t.archived).map((t) => ({
23137
+ const { items } = await client.listWorkflows(1e3);
23138
+ const filtered = searchQuery === "*" ? items : (() => {
23139
+ const keywords = searchQuery.toLowerCase().split(/\s+/).filter((k) => k.length > 0);
23140
+ const scored = items.map((t) => {
23141
+ const text = [t.id, t.name, t.instruction].filter(Boolean).join(" ").toLowerCase();
23142
+ return {
23143
+ tool: t,
23144
+ score: keywords.filter((kw) => text.includes(kw)).length
23145
+ };
23146
+ });
23147
+ const matches = scored.filter((s) => s.score > 0);
23148
+ if (matches.length === 0) return items;
23149
+ matches.sort((a, b) => b.score - a.score);
23150
+ return matches.map((m) => m.tool);
23151
+ })();
23152
+ output({
23153
+ success: true,
23154
+ tools: filtered.map((t) => ({
23064
23155
  id: t.id,
23065
23156
  instruction: (t.instruction || "").slice(0, 80),
23066
23157
  steps: t.steps?.length || 0
23067
- }));
23068
- output({ success: true, tools });
23069
- } else {
23070
- const tools = await client.findRelevantTools(searchQuery);
23071
- output({
23072
- success: true,
23073
- tools: tools.map((t) => ({
23074
- id: t.id,
23075
- instruction: (t.instruction || "").slice(0, 80),
23076
- steps: t.steps?.length || 0
23077
- }))
23078
- });
23079
- }
23158
+ }))
23159
+ });
23080
23160
  } catch (err) {
23081
23161
  error(err.message);
23082
23162
  process.exit(1);
@@ -23096,7 +23176,7 @@ function registerToolCommands(program2, getContext2) {
23096
23176
 
23097
23177
  // src/commands/system/create.ts
23098
23178
  var fs8 = __toESM(require("fs"));
23099
- var import_commander = require("commander");
23179
+ var import_commander2 = require("commander");
23100
23180
  var import_shared6 = __toESM(require_dist2());
23101
23181
  async function collectSensitiveCredentials(fields) {
23102
23182
  const creds = {};
@@ -23119,7 +23199,7 @@ function registerCreateCommand(parent, getContext2) {
23119
23199
  "--template <id>",
23120
23200
  "Template ID \u2014 auto-fills URL, OAuth config, and credentials. Auto-detected from URL if omitted."
23121
23201
  ).option("--instructions <text>", "Specific instructions").option("--credentials <json>", "Non-sensitive credentials JSON").option("--sensitive-credentials <fields>", "Comma-separated sensitive credential field names").option("--docs-url <url>", "Documentation URL to scrape").option("--openapi-url <url>", "OpenAPI spec URL").addOption(
23122
- new import_commander.Option("--env <environment>", "Environment: dev or prod (default: prod)").choices([
23202
+ new import_commander2.Option("--env <environment>", "Environment: dev or prod (default: prod)").choices([
23123
23203
  "dev",
23124
23204
  "prod"
23125
23205
  ])
@@ -23258,10 +23338,10 @@ ${oauthTemplates}
23258
23338
  }
23259
23339
 
23260
23340
  // src/commands/system/edit.ts
23261
- var import_commander2 = require("commander");
23341
+ var import_commander3 = require("commander");
23262
23342
  function registerEditCommand2(parent, getContext2) {
23263
23343
  parent.command("edit").description("Edit an existing system").requiredOption("--id <id>", "System ID").option("--name <name>", "New name").option("--url <url>", "New URL").option("--instructions <text>", "New specific instructions").option("--credentials <json>", "Non-sensitive credentials JSON to merge").option("--sensitive-credentials <fields>", "Comma-separated sensitive credential field names").option("--scrape-url <url>", "Documentation URL to scrape").option("--scrape-keywords <keywords>", "Space-separated scrape keywords").addOption(
23264
- new import_commander2.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23344
+ new import_commander3.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23265
23345
  ).action(async (opts) => {
23266
23346
  const { client } = getContext2();
23267
23347
  const patchPayload = { id: opts.id };
@@ -23332,7 +23412,7 @@ function registerEditCommand2(parent, getContext2) {
23332
23412
  }
23333
23413
 
23334
23414
  // src/commands/system/find.ts
23335
- var import_commander3 = require("commander");
23415
+ var import_commander4 = require("commander");
23336
23416
  var import_shared7 = __toESM(require_dist2());
23337
23417
  function filterSystemFields(system) {
23338
23418
  const credentialKeys = Object.keys(system.credentials || {});
@@ -23366,7 +23446,7 @@ function registerFindCommand2(parent, getContext2) {
23366
23446
  }
23367
23447
  });
23368
23448
  parent.command("find [query]").description("Find systems by query or exact ID").option("--id <exactId>", "Exact system ID lookup").addOption(
23369
- new import_commander3.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23449
+ new import_commander4.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23370
23450
  ).action(async (query, opts) => {
23371
23451
  const { client } = getContext2();
23372
23452
  try {
@@ -23412,7 +23492,7 @@ function registerFindCommand2(parent, getContext2) {
23412
23492
  }
23413
23493
 
23414
23494
  // src/commands/system/call.ts
23415
- var import_commander4 = require("commander");
23495
+ var import_commander5 = require("commander");
23416
23496
  var import_shared8 = __toESM(require_dist2());
23417
23497
  function registerCallCommand(parent, getContext2) {
23418
23498
  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(
@@ -23424,7 +23504,7 @@ function registerCallCommand(parent, getContext2) {
23424
23504
  },
23425
23505
  []
23426
23506
  ).addOption(
23427
- new import_commander4.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23507
+ new import_commander5.Option("--env <environment>", "Environment: dev or prod").choices(["dev", "prod"])
23428
23508
  ).action(async (opts) => {
23429
23509
  const { client } = getContext2();
23430
23510
  const method = opts.method || "GET";
@@ -23861,9 +23941,7 @@ function registerSkillCommand(program2) {
23861
23941
  if (topic) {
23862
23942
  const refsDir = path6.join(SKILLS_DIR, "references");
23863
23943
  const available = fs9.existsSync(refsDir) ? fs9.readdirSync(refsDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", "")) : [];
23864
- error(
23865
- `Topic not found: ${topic}. Available: ${available.join(", ") || "none"}`
23866
- );
23944
+ error(`Topic not found: ${topic}. Available: ${available.join(", ") || "none"}`);
23867
23945
  } else {
23868
23946
  error(`Skill file not found: ${file}`);
23869
23947
  }
@@ -23874,7 +23952,7 @@ function registerSkillCommand(program2) {
23874
23952
  }
23875
23953
 
23876
23954
  // src/cli.ts
23877
- var program = new import_commander5.Command();
23955
+ var program = new import_commander6.Command();
23878
23956
  program.name("sg").description("superglue CLI \u2014 build, run, and manage integration tools").version(CLI_VERSION).option("--api-key <key>", "superglue API key").option("--endpoint <url>", "superglue API endpoint").option("--json", "force JSON output").addHelpText(
23879
23957
  "after",
23880
23958
  `