@erdoai/cli 0.34.0 → 0.35.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 (2) hide show
  1. package/dist/index.js +74 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -241,6 +241,25 @@ var ErdoClient = class {
241
241
  setAutonomyMode(mode) {
242
242
  return this.request("PUT", "/v1/autonomy-mode", { mode });
243
243
  }
244
+ // --- Manager accounts: operate many client (managed) orgs with ONE manager key ---
245
+ // The manager is your active org; you must be an admin/owner of it. A managed org
246
+ // is a client tenant you provision and operate. The manager key (createManagerKey)
247
+ // is a single credential that acts inside any managed org via X-Organization-ID.
248
+ listManagedOrganizations() {
249
+ return this.request("GET", "/v1/managed-organizations");
250
+ }
251
+ createManagedOrganization(input) {
252
+ return this.request("POST", "/v1/managed-organizations", input);
253
+ }
254
+ revokeManagedOrganization(slug) {
255
+ return this.request(
256
+ "DELETE",
257
+ `/v1/managed-organizations/${encodeURIComponent(slug)}`
258
+ );
259
+ }
260
+ createManagerKey() {
261
+ return this.request("POST", "/v1/manager-key");
262
+ }
244
263
  // Run a read-only HogQL query against the org's page-analytics events. Rows are
245
264
  // positional per columns; enabled:false means page analytics is off for the org
246
265
  // (not zero traffic). A rejected query surfaces PostHog's message as the error.
@@ -1239,6 +1258,61 @@ org.command("autonomy [mode]").description("Show or set the org's engine-autonom
1239
1258
  fail(e);
1240
1259
  }
1241
1260
  });
1261
+ var managed = org.command("managed").description("Operate client orgs via a manager account");
1262
+ managed.command("list").description("List the client orgs your org manages").action(async () => {
1263
+ try {
1264
+ const { organizations } = await new ErdoClient().listManagedOrganizations();
1265
+ if (organizations.length === 0) {
1266
+ console.log("No managed orgs. Create one with: erdo org managed create --name <name>");
1267
+ return;
1268
+ }
1269
+ for (const o of organizations) {
1270
+ console.log(`${o.slug || "-"} ${o.name} ${o.role} ${o.id}`);
1271
+ }
1272
+ } catch (e) {
1273
+ fail(e);
1274
+ }
1275
+ });
1276
+ managed.command("create").description("Provision a new client org managed by your org").requiredOption("--name <name>", "display name for the new managed org").option("--slug <slug>", "desired slug (a unique suffix is appended if it collides)").action(async (opts) => {
1277
+ try {
1278
+ const o = await new ErdoClient().createManagedOrganization({ name: opts.name, slug: opts.slug });
1279
+ console.log(`Created managed org: ${o.name}`);
1280
+ console.log(`slug: ${o.slug}
1281
+ id: ${o.id}`);
1282
+ process.stderr.write(
1283
+ `Operate it with the manager key by passing --org ${o.slug} on any command (e.g. erdo --org ${o.slug} datasets list).
1284
+ `
1285
+ );
1286
+ } catch (e) {
1287
+ fail(e);
1288
+ }
1289
+ });
1290
+ managed.command("revoke <slug>").description("Stop managing a client org (removes access; keeps an audit record)").action(async (slug) => {
1291
+ try {
1292
+ await new ErdoClient().revokeManagedOrganization(slug);
1293
+ console.log(`revoked: ${slug}`);
1294
+ } catch (e) {
1295
+ fail(e);
1296
+ }
1297
+ });
1298
+ managed.command("key").description("Mint (or rotate) your manager key \u2014 one credential for every managed org; shown ONCE").action(async () => {
1299
+ try {
1300
+ const res = await new ErdoClient().createManagerKey();
1301
+ process.stderr.write(
1302
+ "Store this manager key now \u2014 it is shown only once and cannot be retrieved again.\n"
1303
+ );
1304
+ console.log(res.token);
1305
+ process.stderr.write(
1306
+ `
1307
+ token id: ${res.token_id}
1308
+ expires: ${res.expires_at}
1309
+ This key operates every org you manage; target one with X-Organization-ID (or \`erdo --org <slug> \u2026\`). Running this again rotates the key.
1310
+ `
1311
+ );
1312
+ } catch (e) {
1313
+ fail(e);
1314
+ }
1315
+ });
1242
1316
  var tokenCmd = program.command("token").description("Manage your API tokens (account-level credentials)");
1243
1317
  tokenCmd.command("create").description("Mint a new API token; the secret is printed ONCE").requiredOption("--name <name>", "a label for the token").option("--expires-days <n>", "days until expiry (default: 30)", (v) => parseInt(v, 10)).option("--org <idOrSlug>", "the token's default org (defaults to your active org; must be one you belong to)").action(async (opts) => {
1244
1318
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {