@engini/cli 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +29 -0
  2. package/dist/cli.js +619 -86
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -30,6 +30,13 @@ var PromptStreamEnded = class extends Error {
30
30
  this.name = "PromptStreamEnded";
31
31
  }
32
32
  };
33
+ async function readStdin(stream = process.stdin) {
34
+ const chunks = [];
35
+ for await (const chunk of stream) {
36
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
37
+ }
38
+ return Buffer.concat(chunks).toString("utf8").replace(/\r?\n$/, "");
39
+ }
33
40
  function ask(rl, question) {
34
41
  return new Promise((resolve, reject) => {
35
42
  let answered = false;
@@ -383,6 +390,7 @@ import {
383
390
  ENV_COMPANY_TOKEN_VAR,
384
391
  ENV_TOKEN_VAR,
385
392
  EnginiAuthError,
393
+ EnginiConflictError,
386
394
  EnginiError,
387
395
  EnginiMcpServerNotFoundError,
388
396
  EnginiNotFoundError,
@@ -442,7 +450,7 @@ function saveConfig(config, path = configPath()) {
442
450
  }
443
451
 
444
452
  // src/version.ts
445
- var VERSION = true ? "0.24.0" : "0.0.0";
453
+ var VERSION = true ? "0.26.0" : "0.0.0";
446
454
 
447
455
  // src/http.ts
448
456
  var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
@@ -464,10 +472,19 @@ function buildClient(overrides = {}) {
464
472
  userAgentPrefix: USER_AGENT_PREFIX
465
473
  });
466
474
  }
475
+ var AUTH_PROVIDER_CONFLICT_CODES = /* @__PURE__ */ new Set([
476
+ "AUTH_PROVIDER_IN_USE",
477
+ "AUTH_PROVIDER_NOT_SUPPORTED",
478
+ "AUTH_PROVIDER_NAME_TAKEN",
479
+ "CONNECTOR_REMOVED"
480
+ ]);
467
481
  function exitForError(err) {
468
482
  if (err instanceof EnginiAuthError) return 3 /* AUTH */;
469
483
  if (err instanceof EnginiOpaApplicationAmbiguousError) return 5 /* VALIDATION */;
470
484
  if (err instanceof EnginiOpaAgentTimeoutError) return 124 /* TIMEOUT */;
485
+ if (err instanceof EnginiConflictError && err.errorCode !== void 0 && AUTH_PROVIDER_CONFLICT_CODES.has(err.errorCode)) {
486
+ return 5 /* VALIDATION */;
487
+ }
471
488
  if (err instanceof EnginiToolsetNotFoundError) return 4 /* NOT_FOUND */;
472
489
  if (err instanceof EnginiMcpServerNotFoundError) return 4 /* NOT_FOUND */;
473
490
  if (err instanceof EnginiTriggerGapError) return 4 /* NOT_FOUND */;
@@ -568,6 +585,42 @@ function registerApplications(program) {
568
585
  registerApplicationsGet(applications);
569
586
  }
570
587
 
588
+ // src/connections/auth-providers/resolve.ts
589
+ var PROVIDER_OPTION_HELP = "Auth provider: a name, a numeric id, or 'none' for the connector's own OAuth client";
590
+ async function resolveProvider(client, spec) {
591
+ if (spec === void 0) return void 0;
592
+ const value = spec.trim();
593
+ if (value === "") fail(2 /* USAGE */, "--provider needs a name, an id, or 'none'.");
594
+ if (value.toLowerCase() === "none" || value === "0") return { id: 0 };
595
+ const usable = await client.authProviders.usable();
596
+ const matches = /^\d+$/.test(value) ? usable.filter((p) => p.id === Number(value)) : usable.filter((p) => p.providerName === value);
597
+ if (matches.length === 0) {
598
+ fail(
599
+ 4 /* NOT_FOUND */,
600
+ `No usable auth provider '${value}'. It may not exist, be disabled, or be unavailable to you.`,
601
+ "Run `engini connections auth-providers usable` to list the providers you can use."
602
+ );
603
+ }
604
+ if (matches.length > 1) {
605
+ fail(
606
+ 2 /* USAGE */,
607
+ `Several auth providers are named '${value}': ids ${matches.map((p) => p.id).join(", ")}.`,
608
+ "Pass the numeric id to --provider."
609
+ );
610
+ }
611
+ return { id: matches[0].id, sourceAuthenticationId: matches[0].sourceAuthenticationId };
612
+ }
613
+ function assertProviderFitsMethod(provider, authenticationId) {
614
+ if (provider?.sourceAuthenticationId === void 0) return;
615
+ if (provider.sourceAuthenticationId !== authenticationId) {
616
+ fail(
617
+ 2 /* USAGE */,
618
+ `Auth provider ${provider.id} is for authentication method ${provider.sourceAuthenticationId}, not ${authenticationId}.`,
619
+ "Drop --auth to use the provider's own method, or pick a provider for this method."
620
+ );
621
+ }
622
+ }
623
+
571
624
  // src/connections/shared.ts
572
625
  import { EnginiNetworkError, EnginiServerError, refreshFailed } from "@engini/sdk";
573
626
  var GATEWAY_TIMEOUT_MARKERS = ["502", "503", "504", "gateway", "timeout"];
@@ -708,27 +761,52 @@ async function connectBody(application, opts) {
708
761
  }
709
762
  if (!application) fail(2 /* USAGE */, "Missing required argument 'application'.");
710
763
  const detail4 = await client.applications.get(application);
711
- const method = await chooseAuth(detail4.authenticationMethods ?? [], opts.auth, application);
764
+ const provider = await resolveProvider(client, opts.provider);
765
+ if (provider?.sourceAuthenticationId !== void 0) {
766
+ const methods = detail4.authenticationMethods ?? [];
767
+ if (!methods.some((m) => m.authenticationId === provider.sourceAuthenticationId)) {
768
+ fail(
769
+ 2 /* USAGE */,
770
+ `Auth provider ${provider.id} is not for '${application}'.`,
771
+ "Run `engini connections auth-providers usable` to see which application each provider is for."
772
+ );
773
+ }
774
+ }
775
+ const method = await chooseAuth(
776
+ detail4.authenticationMethods ?? [],
777
+ opts.auth ?? (provider?.sourceAuthenticationId !== void 0 ? String(provider.sourceAuthenticationId) : void 0),
778
+ application,
779
+ provider
780
+ );
781
+ assertProviderFitsMethod(provider, method.authenticationId);
712
782
  if (dryRun()) {
713
783
  printOutput({
714
784
  would_connect: {
715
785
  application,
716
786
  authentication_id: method.authenticationId,
717
- oauth: Boolean(method.requiresOAuthSignIn)
787
+ oauth: Boolean(method.requiresOAuthSignIn),
788
+ ...provider ? { auth_provider_id: provider.id } : {}
718
789
  }
719
790
  });
720
791
  return;
721
792
  }
722
793
  const name = await resolveName(opts.name, application);
723
- const credentials = method.requiresOAuthSignIn ? await oauthFieldsFor(client, application, method, opts.oauthState, opts.field, timing) : { fields: await collectFields(method, application, parseFields(opts.field)) };
794
+ const credentials = method.requiresOAuthSignIn ? await oauthFieldsFor(client, application, method, opts.oauthState, opts.field, timing, provider) : {
795
+ fields: await collectFields(method, application, parseFields(opts.field), void 0, void 0, provider)
796
+ };
724
797
  progress(`Creating connection '${name}'\u2026`);
725
798
  const created = await client.connections.create(
726
799
  application,
727
800
  name,
728
801
  method.authenticationId,
729
802
  credentials.fields,
730
- // Present only for OAuth methods; a non-OAuth create has no sign-in to point at.
731
- credentials.state ? { oauthState: credentials.state } : {}
803
+ {
804
+ // Present only for OAuth methods; a non-OAuth create has no sign-in to point at.
805
+ ...credentials.state ? { oauthState: credentials.state } : {},
806
+ // On create the provider is a query parameter the server honours only for a method
807
+ // with no sign-in; an OAuth sign-in already pinned it in get-sign-in-url.
808
+ ...provider && !method.requiresOAuthSignIn ? { authProviderId: provider.id } : {}
809
+ }
732
810
  );
733
811
  const connectionId = created.connectionId;
734
812
  progress(`Checking connection ${connectionId}\u2026`);
@@ -762,7 +840,7 @@ function parseObjectIds(specs) {
762
840
  return n;
763
841
  });
764
842
  }
765
- async function chooseAuth(methods, auth, application) {
843
+ async function chooseAuth(methods, auth, application, provider) {
766
844
  if (methods.length === 0) {
767
845
  fail(1 /* GENERIC */, `Application '${application}' exposes no authentication methods.`);
768
846
  }
@@ -806,10 +884,10 @@ async function chooseAuth(methods, auth, application) {
806
884
  need: "auth",
807
885
  application,
808
886
  methods: methods.map(methodSummary),
809
- resume: `engini connect ${application} --auth <id>`
887
+ resume: `engini connect ${application} --auth <id>${providerResumeFlag(provider)}`
810
888
  });
811
889
  }
812
- async function collectFields(method, application, provided, oauthState, fieldOptions) {
890
+ async function collectFields(method, application, provided, oauthState, fieldOptions, provider) {
813
891
  async function readSecretField(label) {
814
892
  const { value, truncated } = await promptHidden(label);
815
893
  if (truncated) {
@@ -821,8 +899,11 @@ async function collectFields(method, application, provided, oauthState, fieldOpt
821
899
  }
822
900
  return value;
823
901
  }
824
- const schema = method.connectionFields.filter((f) => !f.isHidden);
825
- const resumeHint = oauthState ? `Resume with: engini connect ${application} --auth ${method.authenticationId} --oauth-state ${oauthState}` : void 0;
902
+ const providerPinned = provider !== void 0 && provider.id > 0;
903
+ const schema = method.connectionFields.filter(
904
+ (f) => !f.isHidden && !(providerPinned && f.setOnProvider)
905
+ );
906
+ const resumeHint = oauthState ? `Resume with: engini connect ${application} --auth ${method.authenticationId} --oauth-state ${oauthState}${providerResumeFlag(provider)}` : void 0;
826
907
  for (const [k, v] of Object.entries(provided)) {
827
908
  if (v === PLACEHOLDER) delete provided[k];
828
909
  }
@@ -859,6 +940,7 @@ async function collectFields(method, application, provided, oauthState, fieldOpt
859
940
  `engini connect ${application}`,
860
941
  `--auth ${method.authenticationId}`,
861
942
  ...oauthState ? [`--oauth-state ${oauthState}`] : [],
943
+ ...provider ? [`--provider ${provider.id}`] : [],
862
944
  fieldsFlags
863
945
  ].filter(Boolean);
864
946
  return need({
@@ -921,18 +1003,19 @@ async function resolveObjects(objs, connectionId, application) {
921
1003
  resume: `engini connect ${app} --connection ${connectionId} --object <id>`
922
1004
  });
923
1005
  }
924
- async function oauthFieldsFor(client, application, method, oauthState, field, timing) {
1006
+ async function oauthFieldsFor(client, application, method, oauthState, field, timing, provider) {
925
1007
  const cliFields = parseFields(field);
926
1008
  if (oauthState) {
927
1009
  const token = await pollAccessToken(client, oauthState, timing);
928
1010
  const merged = { ...cliFields, ...oauthFields(token) };
929
1011
  return {
930
- fields: await collectFields(method, application, merged, oauthState, token.fieldOptions),
1012
+ fields: await collectFields(method, application, merged, oauthState, token.fieldOptions, provider),
931
1013
  state: oauthState
932
1014
  };
933
1015
  }
934
1016
  const resp = await client.connections.getSignInUrl(application, method.authenticationId, {
935
- fields: field && field.length > 0 ? cliFields : void 0
1017
+ fields: field && field.length > 0 ? cliFields : void 0,
1018
+ authProviderId: provider?.id
936
1019
  });
937
1020
  if (isTty() && timing.wait) {
938
1021
  openBrowser(resp.signInUrl);
@@ -940,7 +1023,7 @@ async function oauthFieldsFor(client, application, method, oauthState, field, ti
940
1023
  const token = await pollAccessToken(client, resp.state, timing);
941
1024
  const merged = { ...cliFields, ...oauthFields(token) };
942
1025
  return {
943
- fields: await collectFields(method, application, merged, resp.state, token.fieldOptions),
1026
+ fields: await collectFields(method, application, merged, resp.state, token.fieldOptions, provider),
944
1027
  state: resp.state
945
1028
  };
946
1029
  }
@@ -967,10 +1050,16 @@ async function oauthFieldsFor(client, application, method, oauthState, field, ti
967
1050
  `engini connect ${application}`,
968
1051
  `--auth ${method.authenticationId}`,
969
1052
  `--oauth-state ${resp.state}`,
1053
+ // The state pins the provider server-side, but the replay still needs it client-side to
1054
+ // know which "Set on provider" fields not to ask for again.
1055
+ ...provider ? [`--provider ${provider.id}`] : [],
970
1056
  ...(field ?? []).map((spec) => resumeFieldFlag(spec, secretFields))
971
1057
  ].join(" ")
972
1058
  });
973
1059
  }
1060
+ function providerResumeFlag(provider) {
1061
+ return provider ? ` --provider ${provider.id}` : "";
1062
+ }
974
1063
  var SAFE_BAREWORD = /^[A-Za-z0-9_@%+:,./=-]+$/;
975
1064
  function shellQuoteFieldSpec(spec) {
976
1065
  if (SAFE_BAREWORD.test(spec)) return spec;
@@ -1036,7 +1125,7 @@ function objectSummary(o) {
1036
1125
  };
1037
1126
  }
1038
1127
  function registerConnect(program) {
1039
- const cmd = program.command("connect").description("Create a connection (interactive/agent-resumable), or open the connections page.").argument("[application]", "Application slug to connect").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--object <id>", "Object id to select (repeatable)", collect).option("--no-objects", "Skip object selection").option("--oauth-state <state>", "Resume an OAuth2 sign-in by its state token").option("--connection <id>", "Resume object selection for an existing connection id").option("--no-wait", "Return early instead of waiting for async jobs").option("--timeout <seconds>", "Seconds to wait before timing out").option("--poll-interval <seconds>", "Seconds between polls");
1128
+ const cmd = program.command("connect").description("Create a connection (interactive/agent-resumable), or open the connections page.").argument("[application]", "Application slug to connect").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--object <id>", "Object id to select (repeatable)", collect).option("--no-objects", "Skip object selection").option("--provider <name|id|none>", PROVIDER_OPTION_HELP).option("--oauth-state <state>", "Resume an OAuth2 sign-in by its state token").option("--connection <id>", "Resume object selection for an existing connection id").option("--no-wait", "Return early instead of waiting for async jobs").option("--timeout <seconds>", "Seconds to wait before timing out").option("--poll-interval <seconds>", "Seconds between polls");
1040
1129
  cmd.addHelpText(
1041
1130
  "after",
1042
1131
  [
@@ -1046,6 +1135,8 @@ function registerConnect(program) {
1046
1135
  " engini connect monday # interactive walkthrough (TTY)",
1047
1136
  " engini connect monday --field ApiKey=\u2026 --name 'My Monday'",
1048
1137
  " engini connect monday --json # agent: prints the next step + exit 5",
1138
+ " engini connect salesforce --provider 'Acme prod' # sign in through your own OAuth app",
1139
+ " engini connect salesforce --provider none # the connector's own OAuth client",
1049
1140
  " engini connect outlook --oauth-state <state> # resume an OAuth sign-in",
1050
1141
  " engini connect monday --connection 42 --object 5 # resume object selection"
1051
1142
  ].join("\n")
@@ -1061,6 +1152,411 @@ function registerConnect(program) {
1061
1152
  });
1062
1153
  }
1063
1154
 
1155
+ // src/connections/auth-providers/shared.ts
1156
+ var SLOTS = [
1157
+ ...Array.from({ length: 10 }, (_, i) => `Key${i + 1}`),
1158
+ "ApiUser",
1159
+ "ApiPassword",
1160
+ "BaseUrl"
1161
+ ];
1162
+ var SLOT_HINT = `Valid slots: ${SLOTS.join(", ")}.`;
1163
+ function parseProviderId(value) {
1164
+ if (!value) fail(2 /* USAGE */, "Missing required argument 'id'.");
1165
+ if (!/^[1-9]\d*$/.test(value)) fail(2 /* USAGE */, "id must be a positive integer.");
1166
+ return Number(value);
1167
+ }
1168
+ function renderField(f) {
1169
+ return {
1170
+ slot: f.slot,
1171
+ label: clean(f.label),
1172
+ is_password: f.isPassword,
1173
+ is_required: f.isRequired,
1174
+ // A secret is write-only: never render a value for it, whatever the server sent.
1175
+ value: f.isPassword ? null : clean(f.value) ?? null,
1176
+ has_value: Boolean(f.hasValue)
1177
+ };
1178
+ }
1179
+ function renderProvider(p) {
1180
+ return {
1181
+ id: p.id,
1182
+ provider_name: p.providerName,
1183
+ application_id: p.applicationId,
1184
+ application_name: clean(p.applicationName),
1185
+ source_authentication_id: p.sourceAuthenticationId,
1186
+ source_authentication_name: clean(p.sourceAuthenticationName),
1187
+ is_default: p.isDefault,
1188
+ is_sandbox: p.isSandbox,
1189
+ status: p.status === 1 ? "active" : "disabled",
1190
+ scopes_override: clean(p.scopesOverride),
1191
+ extra_options: clean(p.extraOptions),
1192
+ connection_count: p.connectionCount,
1193
+ connector_removed: p.connectorRemoved,
1194
+ no_longer_supported: p.noLongerSupported,
1195
+ fields_need_review: p.fieldsNeedReview,
1196
+ fields: p.fields.map(renderField)
1197
+ };
1198
+ }
1199
+ function requireSlot(slot) {
1200
+ if (!SLOTS.includes(slot)) {
1201
+ fail(2 /* USAGE */, `Not a valid provider field slot. ${SLOT_HINT}`);
1202
+ }
1203
+ return slot;
1204
+ }
1205
+ async function collectFieldValues(specs, stdinSlots, opts) {
1206
+ const requests = [];
1207
+ for (const spec of specs ?? []) {
1208
+ const eq = spec.indexOf("=");
1209
+ if (eq === 0) fail(2 /* USAGE */, `--field needs a slot name before '='. ${SLOT_HINT}`);
1210
+ if (eq > 0) {
1211
+ requests.push({ slot: requireSlot(spec.slice(0, eq)), value: spec.slice(eq + 1), source: "inline" });
1212
+ } else {
1213
+ requests.push({ slot: requireSlot(spec), source: "prompt" });
1214
+ }
1215
+ }
1216
+ if ((stdinSlots?.length ?? 0) > 1) fail(2 /* USAGE */, "--field-stdin can be given only once.");
1217
+ for (const slot of stdinSlots ?? []) requests.push({ slot: requireSlot(slot), source: "stdin" });
1218
+ if (requests.length === 0) return void 0;
1219
+ const seen = /* @__PURE__ */ new Set();
1220
+ for (const r of requests) {
1221
+ if (seen.has(r.slot)) fail(2 /* USAGE */, `Field slot ${r.slot} was given more than once.`);
1222
+ seen.add(r.slot);
1223
+ }
1224
+ const out = {};
1225
+ for (const r of requests) {
1226
+ if (opts.dryRun) {
1227
+ out[r.slot] = "";
1228
+ continue;
1229
+ }
1230
+ if (r.source === "inline") {
1231
+ out[r.slot] = r.value;
1232
+ } else if (r.source === "prompt") {
1233
+ if (!isInteractive()) {
1234
+ fail(
1235
+ 2 /* USAGE */,
1236
+ `--field ${r.slot} has no value and there is no terminal to prompt on.`,
1237
+ `Pass --field ${r.slot}=<value>, or pipe the secret in: --field-stdin ${r.slot}`
1238
+ );
1239
+ }
1240
+ const { value, truncated } = await promptHidden(r.slot);
1241
+ if (truncated) {
1242
+ fail(2 /* USAGE */, `${r.slot} contained a line break - only the first line was captured.`);
1243
+ }
1244
+ out[r.slot] = nonBlank(value, r.slot);
1245
+ } else {
1246
+ if (process.stdin.isTTY) {
1247
+ fail(2 /* USAGE */, `--field-stdin ${r.slot} reads a piped value, but stdin is a terminal.`);
1248
+ }
1249
+ out[r.slot] = nonBlank(await readStdin(), r.slot);
1250
+ }
1251
+ }
1252
+ return out;
1253
+ }
1254
+ function nonBlank(value, slot) {
1255
+ if (value === "") {
1256
+ fail(
1257
+ 2 /* USAGE */,
1258
+ `No value for ${slot}; aborting.`,
1259
+ `To clear a slot on update, pass --field ${slot}= explicitly.`
1260
+ );
1261
+ }
1262
+ return value;
1263
+ }
1264
+ async function resolveApplicationId(client, app) {
1265
+ if (/^\d+$/.test(app)) return Number(app);
1266
+ const detail4 = await client.applications.get(app);
1267
+ const name = clean(detail4.applicationName) ?? detail4.slug;
1268
+ const matches = (await client.authProviders.sources()).filter(
1269
+ (s) => (s.applicationName ?? "").toLowerCase() === name.toLowerCase()
1270
+ );
1271
+ if (matches.length === 1) return matches[0].applicationId;
1272
+ if (matches.length === 0) {
1273
+ fail(
1274
+ 4 /* NOT_FOUND */,
1275
+ `Application '${app}' has no authentication method that allows auth providers.`,
1276
+ "Run `engini connections auth-providers sources` to list eligible applications."
1277
+ );
1278
+ }
1279
+ return fail(
1280
+ 2 /* USAGE */,
1281
+ `'${app}' matches several applications named '${name}': ids ${matches.map((m) => m.applicationId).join(", ")}.`,
1282
+ "Pass the numeric id to --app."
1283
+ );
1284
+ }
1285
+ function parseIntOption(name, value) {
1286
+ if (!/^\d+$/.test(value)) fail(2 /* USAGE */, `${name} must be a non-negative integer.`);
1287
+ return Number(value);
1288
+ }
1289
+ async function defaultAuthenticationId(client, applicationId) {
1290
+ const source = (await client.authProviders.sources()).find((s) => s.applicationId === applicationId);
1291
+ if (!source) {
1292
+ fail(
1293
+ 4 /* NOT_FOUND */,
1294
+ `Application ${applicationId} has no authentication method that allows auth providers.`,
1295
+ "Run `engini connections auth-providers sources` to list eligible applications."
1296
+ );
1297
+ }
1298
+ if (source.methods.length === 1) return source.methods[0].authenticationId;
1299
+ return fail(
1300
+ 2 /* USAGE */,
1301
+ `Application ${applicationId} has several eligible methods; pass --auth <id>: ${source.methods.map((m) => `${m.authenticationId} (${m.displayName ?? m.authenticationType})`).join(", ")}.`
1302
+ );
1303
+ }
1304
+
1305
+ // src/connections/auth-providers/create.ts
1306
+ async function createBody(opts) {
1307
+ if (!opts.app) fail(2 /* USAGE */, "Missing required option '--app'.");
1308
+ if (!opts.name) fail(2 /* USAGE */, "Missing required option '--name'.");
1309
+ const app = opts.app;
1310
+ const name = opts.name;
1311
+ const auth = opts.auth !== void 0 ? parseIntOption("--auth", opts.auth) : void 0;
1312
+ const fieldValues = await collectFieldValues(opts.field, opts.fieldStdin, { dryRun: dryRun() });
1313
+ if (dryRun()) {
1314
+ printOutput({
1315
+ would_create: {
1316
+ application: app,
1317
+ authentication_id: auth ?? null,
1318
+ provider_name: name,
1319
+ is_default: Boolean(opts.default),
1320
+ is_sandbox: Boolean(opts.sandbox),
1321
+ scopes_override: opts.scopes ?? null,
1322
+ extra_options: opts.extraOptions ?? null,
1323
+ // Slot names only - a dry run must never print a value.
1324
+ field_slots: Object.keys(fieldValues ?? {})
1325
+ }
1326
+ });
1327
+ return;
1328
+ }
1329
+ const created = await apiErrors(async () => {
1330
+ const client = buildClient();
1331
+ const applicationId = await resolveApplicationId(client, app);
1332
+ const sourceAuthenticationId = auth ?? await defaultAuthenticationId(client, applicationId);
1333
+ return client.authProviders.create({
1334
+ providerName: name,
1335
+ applicationId,
1336
+ sourceAuthenticationId,
1337
+ isDefault: Boolean(opts.default),
1338
+ isSandbox: Boolean(opts.sandbox),
1339
+ ...opts.scopes !== void 0 ? { scopesOverride: opts.scopes } : {},
1340
+ ...opts.extraOptions !== void 0 ? { extraOptions: opts.extraOptions } : {},
1341
+ ...fieldValues !== void 0 ? { fieldValues } : {}
1342
+ });
1343
+ });
1344
+ printOutput(renderProvider(created));
1345
+ }
1346
+ function registerAuthProvidersCreate(group) {
1347
+ const cmd = group.command("create").description("Create an auth provider for one authentication method of an application.").option("--app <slug|id>", "Application slug, or numeric application id").option("--auth <id>", "Authentication method id (optional when the app has one eligible method)").option("--name <name>", "Provider name (unique within the account)").option("--default", "Make this the application's default provider").option("--sandbox", "The provider is for the vendor's sandbox environment").option("--scopes <scopes>", "Scopes that replace the method's own scope option").option("--extra-options <json>", "Extra OAuth options as a JSON object of strings").option("--field <slot[=value]>", "Provider field: Slot=value, or a bare Slot to prompt (repeatable)", collect).option("--field-stdin <slot>", "Read one provider field value from stdin (e.g. a secret)", collect);
1348
+ cmd.addHelpText(
1349
+ "after",
1350
+ [
1351
+ "",
1352
+ "Examples:",
1353
+ " engini connections auth-providers sources # find the app, method and slots",
1354
+ " engini connections auth-providers redirect-uri --app salesforce",
1355
+ " engini connections auth-providers create --app salesforce --name 'Acme prod' \\",
1356
+ " --field Key1=<client-id> --field Key2 # Key2 prompts, hidden",
1357
+ ' printf %s "$SECRET" | engini connections auth-providers create --app salesforce \\',
1358
+ " --name 'Acme prod' --field Key1=<client-id> --field-stdin Key2"
1359
+ ].join("\n")
1360
+ );
1361
+ addUniversalOptions(cmd, { mutating: true });
1362
+ cmd.action(async (opts, command) => {
1363
+ await runCommand(command, opts, true, () => createBody(opts));
1364
+ });
1365
+ }
1366
+
1367
+ // src/connections/auth-providers/delete.ts
1368
+ async function deleteBody(idArg, opts) {
1369
+ const id = parseProviderId(idArg);
1370
+ if (dryRun()) {
1371
+ printOutput({ would_delete: id });
1372
+ return;
1373
+ }
1374
+ await confirmOrFail(`Delete auth provider ${id}?`, { force: Boolean(opts.force) });
1375
+ await apiErrors(async () => buildClient().authProviders.delete(id));
1376
+ printOutput({ deleted: id });
1377
+ }
1378
+ function registerAuthProvidersDelete(group) {
1379
+ const cmd = group.command("delete").description("Remove an auth provider (refused while a connection uses it).").argument("[id]", "Auth provider id").option("--force", "Delete without confirming");
1380
+ cmd.addHelpText("after", "\nExamples:\n engini connections auth-providers delete 7 --force");
1381
+ addUniversalOptions(cmd, { mutating: true });
1382
+ cmd.action(async (id, opts, command) => {
1383
+ await runCommand(command, opts, true, () => deleteBody(id, opts));
1384
+ });
1385
+ }
1386
+
1387
+ // src/connections/auth-providers/get.ts
1388
+ async function getBody2(idArg) {
1389
+ const id = parseProviderId(idArg);
1390
+ const provider = await apiErrors(async () => buildClient().authProviders.get(id));
1391
+ printOutput(renderProvider(provider));
1392
+ }
1393
+ function registerAuthProvidersGet(group) {
1394
+ const cmd = group.command("get").description("Show one auth provider.").argument("[id]", "Auth provider id");
1395
+ addUniversalOptions(cmd);
1396
+ cmd.action(async (id, opts, command) => {
1397
+ await runCommand(command, opts, false, () => getBody2(id));
1398
+ });
1399
+ }
1400
+
1401
+ // src/connections/auth-providers/list.ts
1402
+ async function listBody2() {
1403
+ const providers = await apiErrors(async () => buildClient().authProviders.list());
1404
+ printOutput(providers.map(renderProvider));
1405
+ }
1406
+ function registerAuthProvidersList(group) {
1407
+ const cmd = group.command("list").description("List the account's auth providers (needs permission to manage them).");
1408
+ cmd.addHelpText(
1409
+ "after",
1410
+ "\nA secret slot reads back as has_value: true with a null value.\nPlain members can resolve a provider by name with `auth-providers usable`."
1411
+ );
1412
+ addUniversalOptions(cmd);
1413
+ cmd.action(async (opts, command) => {
1414
+ await runCommand(command, opts, false, listBody2);
1415
+ });
1416
+ }
1417
+
1418
+ // src/connections/auth-providers/redirect-uri.ts
1419
+ async function redirectUriBody(opts) {
1420
+ if (!opts.app) fail(2 /* USAGE */, "Missing required option '--app'.");
1421
+ const authenticationId = opts.auth !== void 0 ? parseIntOption("--auth", opts.auth) : void 0;
1422
+ const result = await apiErrors(async () => {
1423
+ const client = buildClient();
1424
+ const applicationId = await resolveApplicationId(client, opts.app);
1425
+ return client.authProviders.redirectUri(applicationId, {
1426
+ authenticationId,
1427
+ sandbox: Boolean(opts.sandbox)
1428
+ });
1429
+ });
1430
+ printOutput({ redirect_uri: result.redirectUri });
1431
+ }
1432
+ function registerAuthProvidersRedirectUri(group) {
1433
+ const cmd = group.command("redirect-uri").description("Show the callback URL to register in your own OAuth app.").option("--app <slug|id>", "Application slug, or numeric application id").option("--auth <id>", "Authentication method id (optional when the app has one eligible method)").option("--sandbox", "Use the vendor's sandbox environment");
1434
+ cmd.addHelpText(
1435
+ "after",
1436
+ "\nExamples:\n engini connections auth-providers redirect-uri --app salesforce --sandbox"
1437
+ );
1438
+ addUniversalOptions(cmd);
1439
+ cmd.action(async (opts, command) => {
1440
+ await runCommand(command, opts, false, () => redirectUriBody(opts));
1441
+ });
1442
+ }
1443
+
1444
+ // src/connections/auth-providers/sources.ts
1445
+ async function sourcesBody() {
1446
+ const sources = await apiErrors(async () => buildClient().authProviders.sources());
1447
+ printOutput(
1448
+ sources.map((s) => ({
1449
+ application_id: s.applicationId,
1450
+ application_name: clean(s.applicationName),
1451
+ methods: s.methods.map((m) => ({
1452
+ authentication_id: m.authenticationId,
1453
+ display_name: clean(m.displayName),
1454
+ authentication_type: m.authenticationType,
1455
+ fields: m.fields.map((f) => ({
1456
+ slot: f.slot,
1457
+ label: clean(f.label),
1458
+ is_password: f.isPassword,
1459
+ is_required: f.isRequired
1460
+ }))
1461
+ }))
1462
+ }))
1463
+ );
1464
+ }
1465
+ function registerAuthProvidersSources(group) {
1466
+ const cmd = group.command("sources").description("List applications and methods a provider can be based on, with their field slots.");
1467
+ cmd.addHelpText(
1468
+ "after",
1469
+ "\nUse the application_id / authentication_id / slots with `auth-providers create`."
1470
+ );
1471
+ addUniversalOptions(cmd);
1472
+ cmd.action(async (opts, command) => {
1473
+ await runCommand(command, opts, false, sourcesBody);
1474
+ });
1475
+ }
1476
+
1477
+ // src/connections/auth-providers/update.ts
1478
+ function parseStatus(value) {
1479
+ const v = value.toLowerCase();
1480
+ if (v === "active" || v === "1") return 1;
1481
+ if (v === "disabled" || v === "0") return 0;
1482
+ return fail(2 /* USAGE */, "--status must be 'active' or 'disabled'.");
1483
+ }
1484
+ async function updateBody(idArg, opts) {
1485
+ const id = parseProviderId(idArg);
1486
+ const fieldValues = await collectFieldValues(opts.field, opts.fieldStdin, { dryRun: dryRun() });
1487
+ const body = {
1488
+ ...opts.name !== void 0 ? { providerName: opts.name } : {},
1489
+ ...opts.default !== void 0 ? { isDefault: opts.default } : {},
1490
+ ...opts.sandbox !== void 0 ? { isSandbox: opts.sandbox } : {},
1491
+ ...opts.status !== void 0 ? { status: parseStatus(opts.status) } : {},
1492
+ ...opts.scopes !== void 0 ? { scopesOverride: opts.scopes } : {},
1493
+ ...opts.extraOptions !== void 0 ? { extraOptions: opts.extraOptions } : {},
1494
+ ...fieldValues !== void 0 ? { fieldValues } : {}
1495
+ };
1496
+ if (Object.keys(body).length === 0) fail(2 /* USAGE */, "Nothing to update: pass at least one option.");
1497
+ if (dryRun()) {
1498
+ const { fieldValues: fv, ...rest } = body;
1499
+ printOutput({ would_update: { id, ...rest, ...fv ? { field_slots: Object.keys(fv) } : {} } });
1500
+ return;
1501
+ }
1502
+ const updated = await apiErrors(async () => buildClient().authProviders.update(id, body));
1503
+ printOutput(renderProvider(updated));
1504
+ }
1505
+ function registerAuthProvidersUpdate(group) {
1506
+ const cmd = group.command("update").description("Update an auth provider; omitted options and field slots are left unchanged.").argument("[id]", "Auth provider id").option("--name <name>", "New provider name").option("--default", "Make this the application's default provider").option("--no-default", "Stop this being the default provider").option("--sandbox", "Mark as the vendor's sandbox environment").option("--no-sandbox", "Mark as the vendor's production environment").option("--status <active|disabled>", "Enable or disable the provider").option("--scopes <scopes>", "New scopes override ('' clears it)").option("--extra-options <json>", "New extra OAuth options ('' clears them)").option("--field <slot[=value]>", "Field to change: Slot=value, bare Slot to prompt, Slot= to clear (repeatable)", collect).option("--field-stdin <slot>", "Read one field value from stdin (e.g. a secret)", collect);
1507
+ cmd.addHelpText(
1508
+ "after",
1509
+ [
1510
+ "",
1511
+ "Examples:",
1512
+ " engini connections auth-providers update 7 --status disabled",
1513
+ " engini connections auth-providers update 7 --field Key1=<new-client-id>",
1514
+ " engini connections auth-providers update 7 --field Key3= # clears Key3"
1515
+ ].join("\n")
1516
+ );
1517
+ addUniversalOptions(cmd, { mutating: true });
1518
+ cmd.action(async (id, opts, command) => {
1519
+ await runCommand(command, opts, true, () => updateBody(id, opts));
1520
+ });
1521
+ }
1522
+
1523
+ // src/connections/auth-providers/usable.ts
1524
+ async function usableBody() {
1525
+ const usable = await apiErrors(async () => buildClient().authProviders.usable());
1526
+ printOutput(
1527
+ usable.map((p) => ({
1528
+ id: p.id,
1529
+ provider_name: p.providerName,
1530
+ application_id: p.applicationId,
1531
+ application_name: clean(p.applicationName),
1532
+ source_authentication_id: p.sourceAuthenticationId,
1533
+ source_authentication_name: clean(p.sourceAuthenticationName),
1534
+ is_default: p.isDefault
1535
+ }))
1536
+ );
1537
+ }
1538
+ function registerAuthProvidersUsable(group) {
1539
+ const cmd = group.command("usable").description("List active providers you can use for a connection (ids and names only).");
1540
+ cmd.addHelpText("after", "\nThe id is what `connect --provider <id>` takes; no field values are shown.");
1541
+ addUniversalOptions(cmd);
1542
+ cmd.action(async (opts, command) => {
1543
+ await runCommand(command, opts, false, usableBody);
1544
+ });
1545
+ }
1546
+
1547
+ // src/connections/auth-providers/index.ts
1548
+ function registerAuthProviders(connections) {
1549
+ const group = connections.command("auth-providers").description("Manage your own OAuth/credential providers for connections.");
1550
+ registerAuthProvidersList(group);
1551
+ registerAuthProvidersGet(group);
1552
+ registerAuthProvidersCreate(group);
1553
+ registerAuthProvidersUpdate(group);
1554
+ registerAuthProvidersDelete(group);
1555
+ registerAuthProvidersRedirectUri(group);
1556
+ registerAuthProvidersSources(group);
1557
+ registerAuthProvidersUsable(group);
1558
+ }
1559
+
1064
1560
  // src/connections/check.ts
1065
1561
  async function checkBody(connectionId) {
1066
1562
  const id = parseId(connectionId);
@@ -1093,7 +1589,7 @@ function summary(c) {
1093
1589
  use_select_db_objects: clean(c.useSelectDBObjects)
1094
1590
  };
1095
1591
  }
1096
- async function createBody(application, opts) {
1592
+ async function createBody2(application, opts) {
1097
1593
  if (!application) fail(2 /* USAGE */, "Missing required argument 'application'.");
1098
1594
  if (!opts.auth) fail(2 /* USAGE */, "Missing required option '--auth'.");
1099
1595
  if (!opts.name) fail(2 /* USAGE */, "Missing required option '--name'.");
@@ -1107,21 +1603,25 @@ async function createBody(application, opts) {
1107
1603
  connection_name: opts.name,
1108
1604
  authentication_id: auth,
1109
1605
  fields: Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, maskSecret(v)])),
1110
- description: opts.description ?? null
1606
+ description: opts.description ?? null,
1607
+ ...opts.provider !== void 0 ? { provider: opts.provider } : {}
1111
1608
  }
1112
1609
  });
1113
1610
  return;
1114
1611
  }
1115
1612
  const conn = await apiErrors(async () => {
1116
1613
  const client = buildClient();
1614
+ const provider = await resolveProvider(client, opts.provider);
1615
+ assertProviderFitsMethod(provider, auth);
1117
1616
  return client.connections.create(application, opts.name, auth, fields, {
1118
- description: opts.description
1617
+ description: opts.description,
1618
+ authProviderId: provider?.id
1119
1619
  });
1120
1620
  });
1121
1621
  printOutput(summary(conn));
1122
1622
  }
1123
1623
  function registerConnectionsCreate(connections) {
1124
- const cmd = connections.command("create").description("Create a direct-credential connection.").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--description <text>", "Connection description");
1624
+ const cmd = connections.command("create").description("Create a direct-credential connection.").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--description <text>", "Connection description").option("--provider <name|id|none>", PROVIDER_OPTION_HELP);
1125
1625
  cmd.addHelpText(
1126
1626
  "after",
1127
1627
  "\nExamples:\n engini connections create slack --auth 2 --name Sales --field token=xoxb-1"
@@ -1132,7 +1632,7 @@ function registerConnectionsCreate(connections) {
1132
1632
  command,
1133
1633
  opts,
1134
1634
  true,
1135
- () => createBody(application, opts)
1635
+ () => createBody2(application, opts)
1136
1636
  );
1137
1637
  });
1138
1638
  }
@@ -1145,7 +1645,7 @@ function summarize2(d) {
1145
1645
  connection_name: clean(d.connectionName)
1146
1646
  };
1147
1647
  }
1148
- async function listBody2() {
1648
+ async function listBody3() {
1149
1649
  const rows = await apiErrors(async () => {
1150
1650
  const client = buildClient();
1151
1651
  return client.connections.defaults();
@@ -1184,7 +1684,7 @@ function registerConnectionsDefaults(connections) {
1184
1684
  );
1185
1685
  addUniversalOptions(list);
1186
1686
  list.action(async (opts, command) => {
1187
- await runCommand(command, opts, false, () => listBody2());
1687
+ await runCommand(command, opts, false, () => listBody3());
1188
1688
  });
1189
1689
  const set = connections.command("set-default").description("Make a connection the default for its application.").argument("[connection_id]", "Connection id");
1190
1690
  set.addHelpText("after", "\nExamples:\n engini connections set-default 481");
@@ -1203,7 +1703,7 @@ function registerConnectionsDefaults(connections) {
1203
1703
  }
1204
1704
 
1205
1705
  // src/connections/delete.ts
1206
- async function deleteBody(connectionId, opts) {
1706
+ async function deleteBody2(connectionId, opts) {
1207
1707
  const id = parseId(connectionId);
1208
1708
  if (dryRun()) {
1209
1709
  printOutput({ would_delete: id });
@@ -1221,7 +1721,7 @@ function registerConnectionsDelete(connections) {
1221
1721
  cmd.addHelpText("after", "\nExamples:\n engini connections delete 42 --force");
1222
1722
  addUniversalOptions(cmd, { mutating: true });
1223
1723
  cmd.action(async (id, opts, command) => {
1224
- await runCommand(command, opts, true, () => deleteBody(id, opts));
1724
+ await runCommand(command, opts, true, () => deleteBody2(id, opts));
1225
1725
  });
1226
1726
  }
1227
1727
 
@@ -1252,7 +1752,7 @@ function parseId2(value) {
1252
1752
  }
1253
1753
  return id;
1254
1754
  }
1255
- async function getBody2(connectionId) {
1755
+ async function getBody3(connectionId) {
1256
1756
  const id = parseId2(connectionId);
1257
1757
  const connection = await apiErrors(async () => {
1258
1758
  const client = buildClient();
@@ -1265,7 +1765,7 @@ function registerConnectionsGet(connections) {
1265
1765
  cmd.addHelpText("after", "\nExamples:\n engini connections get 42 --json");
1266
1766
  addUniversalOptions(cmd);
1267
1767
  cmd.action(async (id, opts, command) => {
1268
- await runCommand(command, opts, false, () => getBody2(id));
1768
+ await runCommand(command, opts, false, () => getBody3(id));
1269
1769
  });
1270
1770
  }
1271
1771
 
@@ -1282,7 +1782,7 @@ function summarize3(c) {
1282
1782
  created_date: c.createdDate
1283
1783
  };
1284
1784
  }
1285
- async function listBody3(opts) {
1785
+ async function listBody4(opts) {
1286
1786
  const conns = await apiErrors(async () => {
1287
1787
  const client = buildClient();
1288
1788
  return client.connections.list(opts.application, opts.kind);
@@ -1302,7 +1802,7 @@ Examples:
1302
1802
  );
1303
1803
  addUniversalOptions(cmd);
1304
1804
  cmd.action(async (opts, command) => {
1305
- await runCommand(command, opts, false, () => listBody3(opts));
1805
+ await runCommand(command, opts, false, () => listBody4(opts));
1306
1806
  });
1307
1807
  }
1308
1808
 
@@ -1503,7 +2003,12 @@ async function signInUrlBody(application, opts) {
1503
2003
  const fields = opts.field ? parseFields(opts.field) : void 0;
1504
2004
  const resp = await apiErrors(async () => {
1505
2005
  const client = buildClient();
1506
- return client.connections.getSignInUrl(application, auth, { fields });
2006
+ const provider = await resolveProvider(client, opts.provider);
2007
+ assertProviderFitsMethod(provider, auth);
2008
+ return client.connections.getSignInUrl(application, auth, {
2009
+ fields,
2010
+ authProviderId: provider?.id
2011
+ });
1507
2012
  });
1508
2013
  printOutput({
1509
2014
  sign_in_url: resp.signInUrl,
@@ -1512,7 +2017,7 @@ async function signInUrlBody(application, opts) {
1512
2017
  });
1513
2018
  }
1514
2019
  function registerConnectionsSignInUrl(connections) {
1515
- const cmd = connections.command("sign-in-url").description("Start an OAuth2 sign-in (returns the URL + state).").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--field <spec>", "Pre-sign-in field: key=value (repeatable)", collect);
2020
+ const cmd = connections.command("sign-in-url").description("Start an OAuth2 sign-in (returns the URL + state).").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--field <spec>", "Pre-sign-in field: key=value (repeatable)", collect).option("--provider <name|id|none>", PROVIDER_OPTION_HELP);
1516
2021
  cmd.addHelpText("after", "\nExamples:\n engini connections sign-in-url outlook --auth 0");
1517
2022
  addUniversalOptions(cmd);
1518
2023
  cmd.action(async (application, opts, command) => {
@@ -1536,7 +2041,7 @@ function summary4(c) {
1536
2041
  is_alive: clean(c.isAlive)
1537
2042
  };
1538
2043
  }
1539
- async function updateBody(idRaw, opts) {
2044
+ async function updateBody2(idRaw, opts) {
1540
2045
  const connectionId = parseId(idRaw);
1541
2046
  const patch = {};
1542
2047
  if (opts.name !== void 0) patch.name = opts.name;
@@ -1589,7 +2094,7 @@ function registerConnectionsUpdate(connections) {
1589
2094
  command,
1590
2095
  opts,
1591
2096
  true,
1592
- () => updateBody(idRaw, opts)
2097
+ () => updateBody2(idRaw, opts)
1593
2098
  );
1594
2099
  });
1595
2100
  }
@@ -1610,6 +2115,7 @@ function registerConnections(program) {
1610
2115
  registerConnectionsSelectObjects(connections);
1611
2116
  registerConnectionsSignInUrl(connections);
1612
2117
  registerConnectionsOauthComplete(connections);
2118
+ registerAuthProviders(connections);
1613
2119
  }
1614
2120
 
1615
2121
  // src/help.ts
@@ -1668,17 +2174,20 @@ ACCOUNT
1668
2174
  whoami Show the authenticated user/company.
1669
2175
 
1670
2176
  CONNECTIONS
1671
- connect [<app>] Create a connection \u2014 interactive on a TTY, or
2177
+ connect [<app>] [--provider <name|id|none>]
2178
+ Create a connection \u2014 interactive on a TTY, or
1672
2179
  agent-resumable when piped (prints {need, resume}).
1673
2180
  Resume with --oauth-state <state> (OAuth) or
1674
2181
  --connection <id> (object selection). No app \u2192 web page.
2182
+ --provider signs in through your own auth provider
2183
+ (see AUTH PROVIDERS); 'none' = the connector's own client.
1675
2184
  connections list [--application <slug>] [--kind <kind>]
1676
2185
  List your connections. --kind filters on
1677
2186
  Regular | Key | MCPClient. The web UI's
1678
2187
  "Keys" tab is --kind Key. On-premise agents are
1679
2188
  not connections - see ON-PREMISE AGENTS.
1680
2189
  connections get <id> Inspect a connection.
1681
- connections create <app> --auth <id> --name <n> --field k=v
2190
+ connections create <app> --auth <id> --name <n> --field k=v [--provider <name|id|none>]
1682
2191
  Create a direct-credential connection.
1683
2192
  connections update <id> [--name <n>] [--description <t>] [--field k=v] [--metadata k=v]
1684
2193
  Update a connection. --field/--metadata REPLACE
@@ -1688,7 +2197,8 @@ CONNECTIONS
1688
2197
  connections defaults List your per-application default connections.
1689
2198
  connections set-default <id> Make a connection its application's default.
1690
2199
  connections clear-default <app> Clear an application's default (takes a slug).
1691
- connections sign-in-url <app> --auth <id> Start an OAuth2 sign-in (returns URL + state).
2200
+ connections sign-in-url <app> --auth <id> [--provider <name|id|none>]
2201
+ Start an OAuth2 sign-in (returns URL + state).
1692
2202
  connections oauth-complete <app> --auth <id> --state <state>
1693
2203
  Finish an OAuth2 sign-in and create the connection.
1694
2204
  connections check <id> Test a connection's liveness.
@@ -1697,6 +2207,29 @@ CONNECTIONS
1697
2207
  connections select-objects <id> --object <id> Choose which objects to sync (async).
1698
2208
  connections delete <id> [--force] Remove a connection.
1699
2209
 
2210
+ AUTH PROVIDERS
2211
+ Your own OAuth app / credentials for one authentication method of an app, filled once and
2212
+ used by every connection signed in through it. A provider is a name plus values for the
2213
+ connector's "Set on provider" fields, addressed by slot (Key1..Key10, ApiUser, ApiPassword,
2214
+ BaseUrl) - there is no client-id/client-secret flag; every value is a --field.
2215
+ connections auth-providers sources Which apps/methods can have a provider, and the slots to fill.
2216
+ connections auth-providers redirect-uri --app <slug|id> [--auth <id>] [--sandbox]
2217
+ The callback URL to register in your OAuth app FIRST.
2218
+ connections auth-providers create --app <slug|id> --name <n> [--auth <id>] [--default] [--sandbox]
2219
+ [--scopes <s>] [--extra-options <json>] [--field Slot=value ...] [--field-stdin Slot]
2220
+ Create a provider. A bare "--field Slot" prompts hidden on a
2221
+ terminal; "--field-stdin Slot" reads a secret from a pipe, so it
2222
+ never reaches shell history or ps.
2223
+ connections auth-providers update <id> [--name <n>] [--status active|disabled] [--default|--no-default]
2224
+ [--sandbox|--no-sandbox] [--scopes <s>] [--extra-options <json>] [--field ...]
2225
+ Change a provider. Omitted fields/slots are kept; "--field Slot="
2226
+ (empty) clears that slot. A secret reads back as has_value only.
2227
+ connections auth-providers list List providers with their field values (manager-only).
2228
+ connections auth-providers get <id> Show one provider.
2229
+ connections auth-providers usable Providers you may connect through (ids + names only).
2230
+ connections auth-providers delete <id> [--force]
2231
+ Remove a provider (refused while a connection uses it).
2232
+
1700
2233
  TOOLSETS
1701
2234
  toolsets list List your toolsets.
1702
2235
  toolsets get <id> Show full detail for one toolset.
@@ -2296,7 +2829,7 @@ function registerMcpConnections(mcp) {
2296
2829
  }
2297
2830
 
2298
2831
  // src/mcp/get.ts
2299
- async function getBody3(token) {
2832
+ async function getBody4(token) {
2300
2833
  const mcpServerToken = parseMcpServerToken(token);
2301
2834
  const server = await apiErrors(async () => {
2302
2835
  const client = buildClient();
@@ -2315,12 +2848,12 @@ function registerMcpGet(mcp) {
2315
2848
  cmd.addHelpText("after", "\nExamples:\n engini mcp get <mcp_server_token> --json");
2316
2849
  addUniversalOptions(cmd);
2317
2850
  cmd.action(async (token, opts, command) => {
2318
- await runCommand(command, opts, false, () => getBody3(token));
2851
+ await runCommand(command, opts, false, () => getBody4(token));
2319
2852
  });
2320
2853
  }
2321
2854
 
2322
2855
  // src/mcp/list.ts
2323
- async function listBody4() {
2856
+ async function listBody5() {
2324
2857
  const servers = await apiErrors(async () => {
2325
2858
  const client = buildClient();
2326
2859
  return client.mcp.list();
@@ -2335,7 +2868,7 @@ function registerMcpList(mcp) {
2335
2868
  );
2336
2869
  addUniversalOptions(cmd);
2337
2870
  cmd.action(async (opts, command) => {
2338
- await runCommand(command, opts, false, () => listBody4());
2871
+ await runCommand(command, opts, false, () => listBody5());
2339
2872
  });
2340
2873
  }
2341
2874
 
@@ -2373,7 +2906,7 @@ function registerMcpStatus(mcp) {
2373
2906
  }
2374
2907
 
2375
2908
  // src/mcp/tools.ts
2376
- async function listBody5(token, connectionIdRaw) {
2909
+ async function listBody6(token, connectionIdRaw) {
2377
2910
  const mcpServerToken = parseMcpServerToken(token);
2378
2911
  if (!connectionIdRaw) fail(2 /* USAGE */, "Missing required option '--connection-id'.");
2379
2912
  const [connectionId] = parseConnectionIds([connectionIdRaw]);
@@ -2437,7 +2970,7 @@ function registerMcpTools(mcp) {
2437
2970
  command,
2438
2971
  opts,
2439
2972
  false,
2440
- () => listBody5(token, opts.connectionId)
2973
+ () => listBody6(token, opts.connectionId)
2441
2974
  );
2442
2975
  }
2443
2976
  );
@@ -2608,7 +3141,7 @@ function addSettingsOptions(cmd) {
2608
3141
  }
2609
3142
 
2610
3143
  // src/opa/create.ts
2611
- async function createBody2(opts) {
3144
+ async function createBody3(opts) {
2612
3145
  if (opts.name === void 0 || opts.name.trim() === "") fail(2 /* USAGE */, "--name is required.");
2613
3146
  const settings = parseSettingsFlags(opts);
2614
3147
  const preview = settingsPreview(settings);
@@ -2651,12 +3184,12 @@ function registerOpaCreate(opa) {
2651
3184
  );
2652
3185
  addUniversalOptions(cmd, { mutating: true });
2653
3186
  cmd.action(async (opts, command) => {
2654
- await runCommand(command, opts, true, () => createBody2(opts));
3187
+ await runCommand(command, opts, true, () => createBody3(opts));
2655
3188
  });
2656
3189
  }
2657
3190
 
2658
3191
  // src/opa/delete.ts
2659
- async function deleteBody2(raw, opts) {
3192
+ async function deleteBody3(raw, opts) {
2660
3193
  const agentId = parseAgentId(raw);
2661
3194
  if (dryRun()) {
2662
3195
  printOutput({ would_delete: agentId });
@@ -2678,7 +3211,7 @@ function registerOpaDelete(opa) {
2678
3211
  command,
2679
3212
  opts,
2680
3213
  true,
2681
- () => deleteBody2(raw, opts)
3214
+ () => deleteBody3(raw, opts)
2682
3215
  );
2683
3216
  });
2684
3217
  }
@@ -2764,7 +3297,7 @@ function registerOpaDownload(opa) {
2764
3297
  }
2765
3298
 
2766
3299
  // src/opa/get.ts
2767
- async function getBody4(raw) {
3300
+ async function getBody5(raw) {
2768
3301
  const agentId = parseAgentId(raw);
2769
3302
  const agent = await apiErrors(async () => buildClient().opa.get(agentId));
2770
3303
  printOutput({
@@ -2780,12 +3313,12 @@ function registerOpaGet(opa) {
2780
3313
  cmd.addHelpText("after", "\nExamples:\n engini opa get 41 --json");
2781
3314
  addUniversalOptions(cmd);
2782
3315
  cmd.action(async (raw, opts, command) => {
2783
- await runCommand(command, opts, false, () => getBody4(raw));
3316
+ await runCommand(command, opts, false, () => getBody5(raw));
2784
3317
  });
2785
3318
  }
2786
3319
 
2787
3320
  // src/opa/list.ts
2788
- async function listBody6(opts) {
3321
+ async function listBody7(opts) {
2789
3322
  const agents = await apiErrors(
2790
3323
  async () => buildClient().opa.list({ status: opts.status, name: opts.name })
2791
3324
  );
@@ -2802,7 +3335,7 @@ function registerOpaList(opa) {
2802
3335
  );
2803
3336
  addUniversalOptions(cmd);
2804
3337
  cmd.action(async (opts, command) => {
2805
- await runCommand(command, opts, false, () => listBody6(opts));
3338
+ await runCommand(command, opts, false, () => listBody7(opts));
2806
3339
  });
2807
3340
  }
2808
3341
 
@@ -2877,7 +3410,7 @@ function registerOpaDisable(opa) {
2877
3410
  }
2878
3411
 
2879
3412
  // src/opa/token.ts
2880
- async function getBody5(raw) {
3413
+ async function getBody6(raw) {
2881
3414
  const agentId = parseAgentId(raw);
2882
3415
  const token = await apiErrors(async () => buildClient().opa.getToken(agentId));
2883
3416
  printOutput({ agent_id: token.agentId, token: token.token });
@@ -2905,7 +3438,7 @@ function registerOpaToken(opa) {
2905
3438
  get.addHelpText("after", "\nExamples:\n engini opa token get 41 --json");
2906
3439
  addUniversalOptions(get);
2907
3440
  get.action(async (raw, opts, command) => {
2908
- await runCommand(command, opts, false, () => getBody5(raw));
3441
+ await runCommand(command, opts, false, () => getBody6(raw));
2909
3442
  });
2910
3443
  const rotate = token.command("rotate").description(
2911
3444
  "Issue a new token, invalidating the current one. Stops the running agent until it is reconfigured."
@@ -2925,7 +3458,7 @@ function registerOpaToken(opa) {
2925
3458
  }
2926
3459
 
2927
3460
  // src/opa/update.ts
2928
- async function updateBody2(raw, opts) {
3461
+ async function updateBody3(raw, opts) {
2929
3462
  const agentId = parseAgentId(raw);
2930
3463
  const settings = parseSettingsFlags(opts);
2931
3464
  const preview = settingsPreview(settings);
@@ -2973,7 +3506,7 @@ function registerOpaUpdate(opa) {
2973
3506
  command,
2974
3507
  opts,
2975
3508
  true,
2976
- () => updateBody2(raw, opts)
3509
+ () => updateBody3(raw, opts)
2977
3510
  );
2978
3511
  });
2979
3512
  }
@@ -3415,7 +3948,7 @@ function detail3(schema) {
3415
3948
  max_sorts: clean(schema.maxSorts)
3416
3949
  };
3417
3950
  }
3418
- async function getBody6(toolId) {
3951
+ async function getBody7(toolId) {
3419
3952
  if (!toolId) {
3420
3953
  fail(2 /* USAGE */, "Missing required argument 'tool_id'.");
3421
3954
  }
@@ -3429,7 +3962,7 @@ function registerToolsGet(tools) {
3429
3962
  const cmd = tools.command("get").description("Show full canonical detail for one tool.").argument("[tool_id]", "Tool slug");
3430
3963
  addUniversalOptions(cmd);
3431
3964
  cmd.action(async (toolId, opts, command) => {
3432
- await runCommand(command, opts, false, () => getBody6(toolId));
3965
+ await runCommand(command, opts, false, () => getBody7(toolId));
3433
3966
  });
3434
3967
  }
3435
3968
 
@@ -3452,7 +3985,7 @@ function parseLimit2(value) {
3452
3985
  }
3453
3986
  return limit;
3454
3987
  }
3455
- async function listBody7(opts) {
3988
+ async function listBody8(opts) {
3456
3989
  if (opts.application && opts.toolset) {
3457
3990
  fail(2 /* USAGE */, "Pass only one of --application / --toolset.");
3458
3991
  }
@@ -3475,7 +4008,7 @@ function registerToolsList(tools) {
3475
4008
  const cmd = tools.command("list").description("List available tools, optionally filtered.").option("--application <slug>", "Filter by application slug (e.g. monday)").option("--toolset <id>", "List the tools of a server toolset (by id)").option("--limit <n>", "Cap the number of tools returned");
3476
4009
  addUniversalOptions(cmd);
3477
4010
  cmd.action(async (opts, command) => {
3478
- await runCommand(command, opts, false, () => listBody7(opts));
4011
+ await runCommand(command, opts, false, () => listBody8(opts));
3479
4012
  });
3480
4013
  }
3481
4014
 
@@ -3666,7 +4199,7 @@ function buildRequestBody(opts) {
3666
4199
  workflows: workflowsFromFlagsOrUndefined(opts.workflow)
3667
4200
  };
3668
4201
  }
3669
- async function createBody3(opts) {
4202
+ async function createBody4(opts) {
3670
4203
  const body = buildRequestBody(opts);
3671
4204
  if (dryRun()) {
3672
4205
  printOutput({
@@ -3700,12 +4233,12 @@ function registerToolsetsCreate(toolsets) {
3700
4233
  );
3701
4234
  addUniversalOptions(cmd, { mutating: true });
3702
4235
  cmd.action(async (opts, command) => {
3703
- await runCommand(command, opts, true, () => createBody3(opts));
4236
+ await runCommand(command, opts, true, () => createBody4(opts));
3704
4237
  });
3705
4238
  }
3706
4239
 
3707
4240
  // src/toolsets/delete.ts
3708
- async function deleteBody3(toolsetId, opts) {
4241
+ async function deleteBody4(toolsetId, opts) {
3709
4242
  const id = parseToolsetId(toolsetId);
3710
4243
  if (dryRun()) {
3711
4244
  printOutput({ would_delete: id });
@@ -3723,12 +4256,12 @@ function registerToolsetsDelete(toolsets) {
3723
4256
  cmd.addHelpText("after", "\nExamples:\n engini toolsets delete <toolset_id> --force");
3724
4257
  addUniversalOptions(cmd, { mutating: true });
3725
4258
  cmd.action(async (id, opts, command) => {
3726
- await runCommand(command, opts, true, () => deleteBody3(id, opts));
4259
+ await runCommand(command, opts, true, () => deleteBody4(id, opts));
3727
4260
  });
3728
4261
  }
3729
4262
 
3730
4263
  // src/toolsets/get.ts
3731
- async function getBody7(toolsetId) {
4264
+ async function getBody8(toolsetId) {
3732
4265
  const id = parseToolsetId(toolsetId);
3733
4266
  const toolset = await apiErrors(async () => {
3734
4267
  const client = buildClient();
@@ -3746,12 +4279,12 @@ function registerToolsetsGet(toolsets) {
3746
4279
  cmd.addHelpText("after", "\nExamples:\n engini toolsets get <toolset_id> --json");
3747
4280
  addUniversalOptions(cmd);
3748
4281
  cmd.action(async (id, opts, command) => {
3749
- await runCommand(command, opts, false, () => getBody7(id));
4282
+ await runCommand(command, opts, false, () => getBody8(id));
3750
4283
  });
3751
4284
  }
3752
4285
 
3753
4286
  // src/toolsets/list.ts
3754
- async function listBody8() {
4287
+ async function listBody9() {
3755
4288
  const toolsets = await apiErrors(async () => {
3756
4289
  const client = buildClient();
3757
4290
  return client.toolsets.list();
@@ -3766,7 +4299,7 @@ function registerToolsetsList(toolsets) {
3766
4299
  );
3767
4300
  addUniversalOptions(cmd);
3768
4301
  cmd.action(async (opts, command) => {
3769
- await runCommand(command, opts, false, () => listBody8());
4302
+ await runCommand(command, opts, false, () => listBody9());
3770
4303
  });
3771
4304
  }
3772
4305
 
@@ -3801,7 +4334,7 @@ async function previewDryRun(toolsetId, body) {
3801
4334
  }
3802
4335
  });
3803
4336
  }
3804
- async function updateBody3(toolsetId, opts) {
4337
+ async function updateBody4(toolsetId, opts) {
3805
4338
  const id = parseToolsetId(toolsetId);
3806
4339
  const body = buildRequestBody2(opts);
3807
4340
  if (body.name === void 0 && body.connections === void 0 && body.workflows === void 0) {
@@ -3838,7 +4371,7 @@ function registerToolsetsUpdate(toolsets) {
3838
4371
  );
3839
4372
  addUniversalOptions(cmd, { mutating: true });
3840
4373
  cmd.action(async (id, opts, command) => {
3841
- await runCommand(command, opts, true, () => updateBody3(id, opts));
4374
+ await runCommand(command, opts, true, () => updateBody4(id, opts));
3842
4375
  });
3843
4376
  }
3844
4377
 
@@ -4014,7 +4547,7 @@ async function hasAccountDefaultDestination() {
4014
4547
  throw err;
4015
4548
  }
4016
4549
  }
4017
- async function createBody4(triggerSlug, opts) {
4550
+ async function createBody5(triggerSlug, opts) {
4018
4551
  if (triggerSlug === void 0 || triggerSlug === "") fail(2 /* USAGE */, "A trigger_slug is required.");
4019
4552
  if (opts.connection === "") {
4020
4553
  fail(
@@ -4084,12 +4617,12 @@ function registerTriggerCreate(triggers) {
4084
4617
  );
4085
4618
  addUniversalOptions(create, { mutating: true });
4086
4619
  create.action(async (triggerSlug, opts, command) => {
4087
- await runCommand(command, opts, true, () => createBody4(triggerSlug, opts));
4620
+ await runCommand(command, opts, true, () => createBody5(triggerSlug, opts));
4088
4621
  });
4089
4622
  }
4090
4623
 
4091
4624
  // src/triggers/delete.ts
4092
- async function deleteBody4(raw, opts) {
4625
+ async function deleteBody5(raw, opts) {
4093
4626
  const triggerId = parseTriggerId(raw);
4094
4627
  if (dryRun()) {
4095
4628
  printOutput({ would_delete: triggerId });
@@ -4108,7 +4641,7 @@ function registerTriggerDelete(triggers) {
4108
4641
  addUniversalOptions(cmd, { mutating: true });
4109
4642
  cmd.action(
4110
4643
  async (raw, opts, command) => {
4111
- await runCommand(command, opts, true, () => deleteBody4(raw, opts));
4644
+ await runCommand(command, opts, true, () => deleteBody5(raw, opts));
4112
4645
  }
4113
4646
  );
4114
4647
  }
@@ -4153,7 +4686,7 @@ async function addBody(name, url, opts) {
4153
4686
  );
4154
4687
  printOutput(withSecret(created));
4155
4688
  }
4156
- async function listBody9() {
4689
+ async function listBody10() {
4157
4690
  const destinations = await apiErrors(async () => buildClient().triggers.destinations.list());
4158
4691
  printOutput(destinations.map(summarizeDestination));
4159
4692
  }
@@ -4219,7 +4752,7 @@ function registerTriggerDestinations(triggers) {
4219
4752
  list.addHelpText("after", "\nExamples:\n engini triggers destinations list --json");
4220
4753
  addUniversalOptions(list);
4221
4754
  list.action(async (opts, command) => {
4222
- await runCommand(command, opts, false, listBody9);
4755
+ await runCommand(command, opts, false, listBody10);
4223
4756
  });
4224
4757
  const show = destinations.command("show").description("One destination's failure counters and status.").argument("[name]", "Destination name");
4225
4758
  show.addHelpText("after", "\nExamples:\n engini triggers destinations show billing");
@@ -4255,13 +4788,13 @@ function registerTriggerDestinations(triggers) {
4255
4788
  }
4256
4789
 
4257
4790
  // src/triggers/events.ts
4258
- async function listBody10(triggerId, opts) {
4791
+ async function listBody11(triggerId, opts) {
4259
4792
  if (triggerId === void 0 || triggerId === "") fail(2 /* USAGE */, "A trigger_id is required.");
4260
4793
  const top = opts.limit !== void 0 ? Number(opts.limit) : void 0;
4261
4794
  const events = await apiErrors(async () => buildClient().triggers.events.list(triggerId, { top }));
4262
4795
  printOutput(events.map(summarizeEvent));
4263
4796
  }
4264
- async function getBody8(eventId) {
4797
+ async function getBody9(eventId) {
4265
4798
  if (eventId === void 0 || eventId === "") fail(2 /* USAGE */, "An event_id is required.");
4266
4799
  const detail4 = await apiErrors(async () => buildClient().triggers.events.get(eventId));
4267
4800
  printOutput({ event: summarizeEvent(detail4.event), attempts: detail4.attempts });
@@ -4284,14 +4817,14 @@ function registerTriggerEvents(triggers) {
4284
4817
  addUniversalOptions(events);
4285
4818
  events.action(
4286
4819
  async (triggerId, opts, command) => {
4287
- await runCommand(command, opts, false, () => listBody10(triggerId, opts));
4820
+ await runCommand(command, opts, false, () => listBody11(triggerId, opts));
4288
4821
  }
4289
4822
  );
4290
4823
  const get = events.command("get").description("One event plus its delivery attempts \u2014 the only place a real delivery state is read.").argument("[event_id]", "Event id (te_\u2026)");
4291
4824
  get.addHelpText("after", "\nExamples:\n engini triggers events get te_abc123 --json");
4292
4825
  addUniversalOptions(get);
4293
4826
  get.action(async (eventId, opts, command) => {
4294
- await runCommand(command, opts, false, () => getBody8(eventId));
4827
+ await runCommand(command, opts, false, () => getBody9(eventId));
4295
4828
  });
4296
4829
  const replay = events.command("replay").description("Re-deliver a captured event to its destination.").argument("[event_id]", "Event id (te_\u2026)");
4297
4830
  replay.addHelpText(
@@ -4305,7 +4838,7 @@ function registerTriggerEvents(triggers) {
4305
4838
  }
4306
4839
 
4307
4840
  // src/triggers/get.ts
4308
- async function getBody9(raw) {
4841
+ async function getBody10(raw) {
4309
4842
  const triggerId = parseTriggerId(raw);
4310
4843
  const trigger = await apiErrors(async () => buildClient().triggers.get(triggerId));
4311
4844
  printOutput(summarizeTrigger(trigger));
@@ -4315,7 +4848,7 @@ function registerTriggersGet(triggers) {
4315
4848
  get.addHelpText("after", "\nExamples:\n engini triggers get ti_abc123 --json");
4316
4849
  addUniversalOptions(get);
4317
4850
  get.action(async (raw, opts, command) => {
4318
- await runCommand(command, opts, false, () => getBody9(raw));
4851
+ await runCommand(command, opts, false, () => getBody10(raw));
4319
4852
  });
4320
4853
  }
4321
4854
 
@@ -4431,7 +4964,7 @@ function registerTriggerListen(triggers) {
4431
4964
  }
4432
4965
 
4433
4966
  // src/triggers/list.ts
4434
- async function listBody11(opts) {
4967
+ async function listBody12(opts) {
4435
4968
  const top = opts.top !== void 0 ? Number(opts.top) : void 0;
4436
4969
  const triggers = await apiErrors(
4437
4970
  async () => buildClient().triggers.list({
@@ -4460,7 +4993,7 @@ function registerTriggersList(triggers) {
4460
4993
  );
4461
4994
  addUniversalOptions(list);
4462
4995
  list.action(async (opts, command) => {
4463
- await runCommand(command, opts, false, () => listBody11(opts));
4996
+ await runCommand(command, opts, false, () => listBody12(opts));
4464
4997
  });
4465
4998
  }
4466
4999
 
@@ -4499,7 +5032,7 @@ function registerTriggerDisable(triggers) {
4499
5032
  }
4500
5033
 
4501
5034
  // src/triggers/types.ts
4502
- async function listBody12(opts) {
5035
+ async function listBody13(opts) {
4503
5036
  const types = await apiErrors(
4504
5037
  async () => buildClient().triggers.types.list({
4505
5038
  applicationSlug: opts.app,
@@ -4509,7 +5042,7 @@ async function listBody12(opts) {
4509
5042
  );
4510
5043
  printOutput(types);
4511
5044
  }
4512
- async function getBody10(slug, opts) {
5045
+ async function getBody11(slug, opts) {
4513
5046
  if (slug === void 0 || slug === "") fail(2 /* USAGE */, "A trigger_slug is required.");
4514
5047
  const type = await apiErrors(
4515
5048
  async () => buildClient().triggers.types.get(slug, { applicationSlug: opts.app })
@@ -4524,14 +5057,14 @@ function registerTriggerTypes(triggers) {
4524
5057
  );
4525
5058
  addUniversalOptions(types);
4526
5059
  types.action(async (opts, command) => {
4527
- await runCommand(command, opts, false, () => listBody12(opts));
5060
+ await runCommand(command, opts, false, () => listBody13(opts));
4528
5061
  });
4529
5062
  const get = types.command("get").description("One trigger type's config_schema, payload_schema and parameters.").argument("[trigger_slug]", "Trigger type slug").option("--app <slug>", "Disambiguate a slug shared by more than one application");
4530
5063
  get.addHelpText("after", "\nExamples:\n engini triggers types get monday_item_created --json");
4531
5064
  addUniversalOptions(get);
4532
5065
  get.action(
4533
5066
  async (slug, opts, command) => {
4534
- await runCommand(command, opts, false, () => getBody10(slug, opts));
5067
+ await runCommand(command, opts, false, () => getBody11(slug, opts));
4535
5068
  }
4536
5069
  );
4537
5070
  }