@erdoai/cli 0.183.0 → 0.184.1

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 +58 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -428,6 +428,12 @@ var ErdoClient = class {
428
428
  creditBalance() {
429
429
  return this.request("GET", "/v1/credits/balance");
430
430
  }
431
+ getManagerCreditFunding() {
432
+ return this.request("GET", "/v1/credits/manager-funding");
433
+ }
434
+ setManagerCreditFunding(enabled) {
435
+ return this.request("PATCH", "/v1/credits/manager-funding", { enabled });
436
+ }
431
437
  listMCPToolsets() {
432
438
  return this.request("GET", "/v1/mcp/toolsets");
433
439
  }
@@ -506,6 +512,14 @@ var ErdoClient = class {
506
512
  `/v1/managed-organizations/${encodeURIComponent(slug)}`
507
513
  );
508
514
  }
515
+ // Turn an allow-listed feature flag on (or back to its normal resolution) for
516
+ // a managed org. Only flags Erdo declares manager-settable are accepted.
517
+ setManagedOrganizationFeatureFlag(slug, key, enabled) {
518
+ return this.request(
519
+ enabled ? "PUT" : "DELETE",
520
+ `/v1/managed-organizations/${encodeURIComponent(slug)}/feature-flags/${encodeURIComponent(key)}`
521
+ );
522
+ }
509
523
  createManagerKey() {
510
524
  return this.request("POST", "/v1/manager-key");
511
525
  }
@@ -2906,6 +2920,20 @@ credits.command("balance").description("Read the current organization's credit b
2906
2920
  fail(error);
2907
2921
  }
2908
2922
  });
2923
+ credits.command("manager-funding").description("Read or change manager execution-credit funding for the current organization").option("--enabled <true|false>", "Set whether this organization funds managed organizations").action(async (options) => {
2924
+ try {
2925
+ if (options.enabled === void 0) {
2926
+ print(await new ErdoClient().getManagerCreditFunding());
2927
+ return;
2928
+ }
2929
+ if (options.enabled !== "true" && options.enabled !== "false") {
2930
+ throw new Error("--enabled must be exactly true or false");
2931
+ }
2932
+ print(await new ErdoClient().setManagerCreditFunding(options.enabled === "true"));
2933
+ } catch (error) {
2934
+ fail(error);
2935
+ }
2936
+ });
2909
2937
  var admin = program.command("admin").description("Erdo staff administration");
2910
2938
  admin.command("credits").description("Staff-only manual credit grants").command("grant <orgSlugOrId>").description("Grant non-expiring credits without payment; requires an authenticated staff user").requiredOption("--amount <integer>", "Positive integer credits to grant").requiredOption("--reason <text>", "Audit reason").action(async (organization, options) => {
2911
2939
  try {
@@ -3644,6 +3672,18 @@ managed.command("revoke <slug>").description("Stop managing a client org (remove
3644
3672
  fail(e);
3645
3673
  }
3646
3674
  });
3675
+ managed.command("flag <slug> <key> <state>").description("Turn a manager-settable feature flag on or off for a client org (state: on|off)").action(async (slug, key, state) => {
3676
+ if (state !== "on" && state !== "off") {
3677
+ fail(new Error("state must be on or off"));
3678
+ }
3679
+ try {
3680
+ const res = await new ErdoClient().setManagedOrganizationFeatureFlag(slug, key, state === "on");
3681
+ const source = res.set_by === "staff" ? "set by Erdo staff" : res.set_by ? "set by your manager org" : "normal resolution";
3682
+ console.log(`${res.flag_key} for ${res.org_slug}: ${res.enabled ? "on" : "off"} (${source})`);
3683
+ } catch (e) {
3684
+ fail(e);
3685
+ }
3686
+ });
3647
3687
  managed.command("key").description("Mint (or rotate) your manager key \u2014 one credential for every managed org; shown ONCE").action(async () => {
3648
3688
  try {
3649
3689
  const res = await new ErdoClient().createManagerKey();
@@ -7997,6 +8037,21 @@ providerLeadSourcesCmd.command("set").description(
7997
8037
  fail(e);
7998
8038
  }
7999
8039
  });
8040
+ var leadSourcePreviewSample = 5;
8041
+ function newestLeadSample(batches) {
8042
+ const ts = (lead) => typeof lead.ts === "string" ? lead.ts : "";
8043
+ const seen = /* @__PURE__ */ new Set();
8044
+ const kept = batches.map(
8045
+ (sample) => sample.filter((lead) => {
8046
+ const id = typeof lead.provider_lead_id === "string" ? lead.provider_lead_id : "";
8047
+ if (id === "") return true;
8048
+ if (seen.has(id)) return false;
8049
+ seen.add(id);
8050
+ return true;
8051
+ })
8052
+ );
8053
+ return kept.reverse().flat().sort((a, b) => ts(a) < ts(b) ? 1 : ts(a) > ts(b) ? -1 : 0).slice(0, leadSourcePreviewSample);
8054
+ }
8000
8055
  providerLeadSourcesCmd.command("import <name> <file>").description(
8001
8056
  "Import a CSV file into an import lead source. Every row is written as history: never alerted on, billed or followed up until started. Without --commit this is a dry run that previews the file and writes nothing."
8002
8057
  ).option("--commit", "write the rows (without it, only a preview)").option("--default-submitted-at <date>", "when these people got in touch, for rows the file does not date (YYYY-MM-DD or RFC 3339)").option("--start-follow-up", "after writing, start follow-up on each lead the import created (with --commit)").action(async (name, file, opts) => {
@@ -8012,6 +8067,7 @@ providerLeadSourcesCmd.command("import <name> <file>").description(
8012
8067
  const skipped = {};
8013
8068
  const created = /* @__PURE__ */ new Set();
8014
8069
  let preview;
8070
+ const samples = [];
8015
8071
  for (let start = 0; start < rows.length || start === 0; start += batch) {
8016
8072
  const result = await client.importLeadSourceRows({
8017
8073
  name,
@@ -8022,6 +8078,7 @@ providerLeadSourcesCmd.command("import <name> <file>").description(
8022
8078
  });
8023
8079
  if (result.preview) {
8024
8080
  preview ??= result.preview;
8081
+ samples.push(result.preview.sample);
8025
8082
  totals.history += result.preview.history;
8026
8083
  totals.already_written += result.preview.already_written;
8027
8084
  totals.test += result.preview.test;
@@ -8038,7 +8095,7 @@ providerLeadSourcesCmd.command("import <name> <file>").description(
8038
8095
  if (rows.length === 0) break;
8039
8096
  }
8040
8097
  if (!opts.commit) {
8041
- print({ dry_run: true, rows: totals.rows, history: totals.history, already_written: totals.already_written, test: totals.test, skipped, not_read: preview?.not_read ?? [], missing_fields: preview?.missing_fields ?? [], sample: preview?.sample ?? [] });
8098
+ print({ dry_run: true, rows: totals.rows, history: totals.history, already_written: totals.already_written, test: totals.test, skipped, not_read: preview?.not_read ?? [], missing_fields: preview?.missing_fields ?? [], sample: newestLeadSample(samples) });
8042
8099
  process.stderr.write(`Dry run: nothing written. ${totals.history} rows would be written as history. Run again with --commit to write them.
8043
8100
  `);
8044
8101
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.183.0",
3
+ "version": "0.184.1",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {