nixflex 0.7.0 → 0.9.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.
- package/CHANGELOG.md +6 -0
- package/dist/cli/index.js +409 -114
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 0.8.0
|
|
2
|
+
- CLI now covers every SDK method: calls delete/delete-all, campaigns create (CSV) + launch, numbers import/delete/monitor/web-calls, sms campaigns, webhooks, keys rotate, storage/llm/tts. A guard test fails the build if an SDK method has no command.
|
|
3
|
+
- `--set field=value` (repeatable) and `--body @file.json` on every create/update/set - new API fields need no CLI update.
|
|
4
|
+
- `--yes` alias for `--confirm`; every destructive command previews first. `--base-url` for staging. `calls create --wait` polls until the call ends and prints the result. `completion <bash|zsh|pwsh>`. Did-you-mean on mistyped commands.
|
|
5
|
+
- Fixes: `login` uses a visible prompt (the hidden one dropped pasted input on Windows); `mcp setup` no longer writes a `\` env block desktop apps cannot expand - the MCP server reads ~/.nixflex/config.json.
|
|
6
|
+
|
|
1
7
|
## 0.7.0
|
|
2
8
|
- New: the `nixflex` CLI ships in this package - `npx nixflex --help`. Agents, calls, numbers, caller context (incl. CSV import), SMS, usage, doctor, `login` (key stored in ~/.nixflex/config.json) and `mcp setup`. Every command takes `--json`; deletes need `--confirm`. Zero dependencies - it calls this SDK. Docs: https://docs.nixflex.com/cli
|
|
3
9
|
|
package/dist/cli/index.js
CHANGED
|
@@ -90,7 +90,7 @@ function errorFromResponse(status, body, requestId, retryAfterSeconds) {
|
|
|
90
90
|
// src/client.ts
|
|
91
91
|
var DEFAULT_BASE_URL = "https://api.nixflex.com";
|
|
92
92
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
93
|
-
var SDK_VERSION = "0.
|
|
93
|
+
var SDK_VERSION = "0.8.0";
|
|
94
94
|
var HttpClient = class {
|
|
95
95
|
apiKey;
|
|
96
96
|
baseUrl;
|
|
@@ -627,7 +627,7 @@ var Nixflex = class {
|
|
|
627
627
|
var src_default = Nixflex;
|
|
628
628
|
|
|
629
629
|
// src/cli/index.ts
|
|
630
|
-
var VERSION = true ? "0.
|
|
630
|
+
var VERSION = true ? "0.9.0" : "0.0.0";
|
|
631
631
|
var CONFIG_DIR = join(homedir(), ".nixflex");
|
|
632
632
|
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
633
633
|
function readConfig() {
|
|
@@ -641,29 +641,24 @@ function writeConfig(cfg) {
|
|
|
641
641
|
if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
642
642
|
writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2) + "\n", { mode: 384 });
|
|
643
643
|
}
|
|
644
|
+
var KEY_RE = /^nxf_[a-z0-9]+:nxfs_[a-z0-9]+$/i;
|
|
644
645
|
function resolveKey(flagKey) {
|
|
645
646
|
const key = flagKey || process.env.NIXFLEX_API_KEY || readConfig().api_key;
|
|
646
647
|
if (!key) fail("No API key. Run `nixflex login`, or set NIXFLEX_API_KEY.", 2);
|
|
647
|
-
if (
|
|
648
|
+
if (!KEY_RE.test(key)) fail("The key must be the full pair: nxf_xxx:nxfs_xxx (key id, colon, secret).", 2);
|
|
648
649
|
return key;
|
|
649
650
|
}
|
|
650
|
-
function ask(question
|
|
651
|
+
function ask(question) {
|
|
651
652
|
return new Promise((resolve) => {
|
|
652
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout
|
|
653
|
-
if (hidden) {
|
|
654
|
-
const out2 = rl;
|
|
655
|
-
out2._writeToOutput = (s) => {
|
|
656
|
-
if (s.includes(question)) out2.output.write(question);
|
|
657
|
-
};
|
|
658
|
-
}
|
|
653
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
659
654
|
rl.question(question, (a) => {
|
|
660
655
|
rl.close();
|
|
661
|
-
if (hidden) process.stdout.write("\n");
|
|
662
656
|
resolve(a.trim());
|
|
663
657
|
});
|
|
664
658
|
});
|
|
665
659
|
}
|
|
666
660
|
var JSON_MODE = false;
|
|
661
|
+
var HIDE = /^(system_prompt|sms_prompt|web_prompt|transcript|custom_prompt|recording_url|api_key_id)$/;
|
|
667
662
|
function out(data) {
|
|
668
663
|
if (JSON_MODE) {
|
|
669
664
|
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
|
|
@@ -690,20 +685,87 @@ function table(rows) {
|
|
|
690
685
|
return;
|
|
691
686
|
}
|
|
692
687
|
const objs = rows.filter((r) => r && typeof r === "object");
|
|
693
|
-
|
|
688
|
+
if (objs.length === 0) {
|
|
689
|
+
for (const r of rows) process.stdout.write(cell(r) + "\n");
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const cols = Array.from(new Set(objs.flatMap((r) => Object.keys(r)))).filter((c) => !HIDE.test(c)).slice(0, 8);
|
|
694
693
|
const widths = cols.map((c) => Math.min(40, Math.max(c.length, ...objs.map((r) => cell(r[c]).length))));
|
|
695
694
|
const line = (vals) => vals.map((v, i) => v.slice(0, widths[i]).padEnd(widths[i])).join(" ") + "\n";
|
|
696
695
|
process.stdout.write(line(cols.map((c) => c.toUpperCase())));
|
|
697
696
|
for (const r of objs) process.stdout.write(line(cols.map((c) => cell(r[c]))));
|
|
698
697
|
}
|
|
699
698
|
function kv(o) {
|
|
700
|
-
const
|
|
699
|
+
const keys = Object.keys(o);
|
|
700
|
+
if (keys.length === 0) {
|
|
701
|
+
process.stdout.write("{}\n");
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const w = Math.max(...keys.map((k) => k.length));
|
|
701
705
|
for (const [k, v] of Object.entries(o)) process.stdout.write(k.padEnd(w) + " " + cell(v) + "\n");
|
|
702
706
|
}
|
|
707
|
+
function note(msg) {
|
|
708
|
+
process.stderr.write(msg + "\n");
|
|
709
|
+
}
|
|
703
710
|
function fail(msg, code = 1) {
|
|
704
711
|
process.stderr.write("error: " + msg + "\n");
|
|
705
712
|
process.exit(code);
|
|
706
713
|
}
|
|
714
|
+
function textOrFile(v) {
|
|
715
|
+
if (v === void 0) return void 0;
|
|
716
|
+
if (v.startsWith("@")) return readFileSync(v.slice(1), "utf8");
|
|
717
|
+
return v;
|
|
718
|
+
}
|
|
719
|
+
function parseValue(raw) {
|
|
720
|
+
if (raw === "null") return null;
|
|
721
|
+
if (raw === "true") return true;
|
|
722
|
+
if (raw === "false") return false;
|
|
723
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) return Number(raw);
|
|
724
|
+
if (raw.startsWith("@")) return readFileSync(raw.slice(1), "utf8");
|
|
725
|
+
if (raw.startsWith("{") && raw.endsWith("}") || raw.startsWith("[") && raw.endsWith("]")) {
|
|
726
|
+
try {
|
|
727
|
+
return JSON.parse(raw);
|
|
728
|
+
} catch {
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return raw;
|
|
732
|
+
}
|
|
733
|
+
function bodyFrom(values, extra = {}) {
|
|
734
|
+
const body = {};
|
|
735
|
+
const b = values.body;
|
|
736
|
+
if (b) {
|
|
737
|
+
const text = b === "-" ? readFileSync(0, "utf8") : textOrFile(b) || "";
|
|
738
|
+
try {
|
|
739
|
+
Object.assign(body, JSON.parse(text));
|
|
740
|
+
} catch {
|
|
741
|
+
fail("--body must be JSON (a file with @path, or - for stdin)");
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
for (const kv2 of values.set || []) {
|
|
745
|
+
const i = kv2.indexOf("=");
|
|
746
|
+
if (i < 1) fail("--set expects field=value, got " + kv2);
|
|
747
|
+
body[kv2.slice(0, i)] = parseValue(kv2.slice(i + 1));
|
|
748
|
+
}
|
|
749
|
+
for (const [k, v] of Object.entries(extra)) if (v !== void 0) body[k] = v;
|
|
750
|
+
return body;
|
|
751
|
+
}
|
|
752
|
+
function boolOrNull(v) {
|
|
753
|
+
if (v === void 0) return void 0;
|
|
754
|
+
if (v === "true") return true;
|
|
755
|
+
if (v === "false") return false;
|
|
756
|
+
if (v === "null") return null;
|
|
757
|
+
fail("expected true, false or null, got " + v);
|
|
758
|
+
}
|
|
759
|
+
function vars(list) {
|
|
760
|
+
if (!list || list.length === 0) return void 0;
|
|
761
|
+
const o = {};
|
|
762
|
+
for (const kv2 of list) {
|
|
763
|
+
const i = kv2.indexOf("=");
|
|
764
|
+
if (i < 1) fail("--var expects key=value, got " + kv2);
|
|
765
|
+
o[kv2.slice(0, i)] = kv2.slice(i + 1);
|
|
766
|
+
}
|
|
767
|
+
return o;
|
|
768
|
+
}
|
|
707
769
|
function parseCsv(text) {
|
|
708
770
|
const rows = [];
|
|
709
771
|
let row = [];
|
|
@@ -738,80 +800,143 @@ function parseCsv(text) {
|
|
|
738
800
|
}
|
|
739
801
|
const [head, ...body] = rows.filter((r) => r.some((c) => c.trim() !== ""));
|
|
740
802
|
if (!head) return [];
|
|
741
|
-
const keys = head.map((h) => h.trim());
|
|
803
|
+
const keys = head.map((h) => h.trim().replace(/^\uFEFF/, ""));
|
|
742
804
|
return body.map((r) => Object.fromEntries(keys.map((k, i) => [k, (r[i] ?? "").trim()])));
|
|
743
805
|
}
|
|
806
|
+
function recipientsFromCsv(file, allowOverride) {
|
|
807
|
+
const rows = parseCsv(readFileSync(file, "utf8"));
|
|
808
|
+
if (rows.length === 0) fail("no rows in " + file);
|
|
809
|
+
if (!("phone" in rows[0])) fail("the CSV needs a `phone` column (E.164, e.g. +447700900123)");
|
|
810
|
+
return rows.map((r) => {
|
|
811
|
+
const rec = { phone: r.phone };
|
|
812
|
+
const v = {};
|
|
813
|
+
for (const [k, val] of Object.entries(r)) {
|
|
814
|
+
if (k === "phone" || val === "") continue;
|
|
815
|
+
if (k === "prompt_override" && allowOverride) {
|
|
816
|
+
rec.prompt_override = val;
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
v[k] = val;
|
|
820
|
+
}
|
|
821
|
+
if (Object.keys(v).length) rec.variables = v;
|
|
822
|
+
return rec;
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
var GROUPS = ["login", "logout", "whoami", "usage", "doctor", "completion", "mcp", "agents", "calls", "campaigns", "numbers", "callers", "sms", "webhooks", "keys", "storage", "llm", "tts"];
|
|
744
826
|
var HELP = `nixflex ${VERSION} - the Nixflex voice AI platform from your terminal
|
|
745
827
|
|
|
746
|
-
USAGE nixflex <group> <command> [args] [--json] [--key KEY]
|
|
828
|
+
USAGE nixflex <group> <command> [args] [--json] [--key KEY] [--base-url URL]
|
|
829
|
+
|
|
830
|
+
EXAMPLES
|
|
831
|
+
nixflex login
|
|
832
|
+
nixflex agents update agent_x --set silence_hangup_seconds=12
|
|
833
|
+
nixflex calls create --agent agent_x --to +447700900123 --prompt @call.txt --wait
|
|
834
|
+
nixflex callers import +447450307843 ./customers.csv
|
|
747
835
|
|
|
748
836
|
ACCOUNT
|
|
749
|
-
login
|
|
750
|
-
logout
|
|
751
|
-
whoami
|
|
752
|
-
usage
|
|
753
|
-
doctor
|
|
837
|
+
login store your API key (prompt, or NIXFLEX_API_KEY)
|
|
838
|
+
logout remove the stored key
|
|
839
|
+
whoami key in use, usage and balance
|
|
840
|
+
usage usage and balance
|
|
841
|
+
doctor check key, connectivity and version
|
|
842
|
+
completion <bash|zsh|pwsh> print a shell completion script
|
|
843
|
+
keys rotate --confirm new secret; the old one stops working immediately
|
|
754
844
|
|
|
755
845
|
AGENTS
|
|
756
846
|
agents list [--limit N]
|
|
757
847
|
agents get <agent_id>
|
|
758
|
-
agents create --name NAME --prompt TEXT|@file [--voice ID] [--language xx]
|
|
759
|
-
agents update <
|
|
760
|
-
agents delete <
|
|
848
|
+
agents create --name NAME --prompt TEXT|@file [--voice ID] [--language xx] [--set k=v ...]
|
|
849
|
+
agents update <id> [--name] [--prompt] [--voice] [--language] [--incall-sms true|false] [--set k=v ...]
|
|
850
|
+
agents delete <id> --confirm
|
|
761
851
|
|
|
762
852
|
CALLS
|
|
763
|
-
calls create --agent ID --to +44... --prompt TEXT|@file [--from +44...] [--var
|
|
853
|
+
calls create --agent ID --to +44... --prompt TEXT|@file [--from +44...] [--var k=v ...] [--wait] [--timeout S]
|
|
764
854
|
calls list [--limit N] [--agent ID]
|
|
765
855
|
calls get <call_id>
|
|
856
|
+
calls delete <call_id> --confirm
|
|
857
|
+
calls delete-all --confirm every call and recording on the account
|
|
858
|
+
|
|
859
|
+
CAMPAIGNS (voice batch)
|
|
860
|
+
campaigns create --agent ID --from +44... --prompt TEXT|@file --csv people.csv [--name] [--set k=v ...]
|
|
861
|
+
CSV: phone (required), prompt_override (optional), any other column = variable
|
|
862
|
+
campaigns launch <campaign_id>
|
|
766
863
|
|
|
767
864
|
NUMBERS
|
|
768
865
|
numbers list [--agent ID]
|
|
769
|
-
numbers
|
|
866
|
+
numbers import --set phone_number=+44... --set agent_id=ID --set twilio_account_sid=... --set twilio_auth_token=...
|
|
867
|
+
(or --set telnyx_api_key=... --set telnyx_connection_id=...) or --body @number.json
|
|
868
|
+
numbers update <number> [--sms-reply] [--sms-prompt] [--dtmf] [--set k=v ...]
|
|
869
|
+
numbers delete <number> --confirm
|
|
870
|
+
numbers monitor <number> [get|on|off]
|
|
871
|
+
numbers web-calls <number> [get|on|off]
|
|
770
872
|
|
|
771
|
-
CALLERS
|
|
873
|
+
CALLERS (caller context)
|
|
772
874
|
callers get <your_number> <caller_number>
|
|
773
875
|
callers set <your_number> <caller_number> [--name] [--email] [--phone] [--location] [--reference] [--preference]
|
|
774
|
-
|
|
775
|
-
callers import <your_number> <file.csv> columns: caller_number,name,email,phone,location,reference_id,preference
|
|
876
|
+
callers import <your_number> <file.csv> columns: caller_number, name, email, phone, location, reference_id, preference
|
|
776
877
|
callers delete <your_number> <caller_number> --confirm
|
|
777
878
|
|
|
778
879
|
SMS
|
|
779
880
|
sms send --agent ID --from +44... --to +44... --message TEXT
|
|
881
|
+
sms campaigns create --agent ID --from +44... --message TEXT|@file --csv people.csv [--set k=v ...]
|
|
882
|
+
sms campaigns launch <id>
|
|
883
|
+
sms campaigns list [--status S] [--limit N]
|
|
884
|
+
sms campaigns get <id>
|
|
885
|
+
sms campaigns delete <id> --confirm
|
|
886
|
+
|
|
887
|
+
WEBHOOKS (per number)
|
|
888
|
+
webhooks set <number> <url> [--slot 1|2]
|
|
889
|
+
webhooks get <number> [--slot 1|2]
|
|
890
|
+
webhooks delete <number> [--slot 1|2] --confirm
|
|
891
|
+
|
|
892
|
+
BRING YOUR OWN
|
|
893
|
+
storage set --set k=v ... storage get storage delete --confirm
|
|
894
|
+
llm set --set k=v ... llm get llm delete --confirm
|
|
895
|
+
tts set --set k=v ... tts get tts delete --confirm
|
|
780
896
|
|
|
781
897
|
MCP
|
|
782
|
-
mcp setup <claude|cursor|vscode>
|
|
898
|
+
mcp setup <claude|cursor|vscode> connect the Nixflex MCP server to that app
|
|
783
899
|
|
|
784
|
-
|
|
900
|
+
FLAGS --json machine output --set field=value (repeat) --body @file.json | - --confirm / --yes
|
|
901
|
+
EXIT 0 ok 1 error 2 no API key
|
|
902
|
+
Docs: https://docs.nixflex.com/cli
|
|
785
903
|
`;
|
|
786
|
-
function
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
function vars(list) {
|
|
803
|
-
if (!list || list.length === 0) return void 0;
|
|
804
|
-
const o = {};
|
|
805
|
-
for (const kv2 of list) {
|
|
806
|
-
const i = kv2.indexOf("=");
|
|
807
|
-
if (i < 1) fail("--var expects key=value, got " + kv2);
|
|
808
|
-
o[kv2.slice(0, i)] = kv2.slice(i + 1);
|
|
904
|
+
function closest(word, options) {
|
|
905
|
+
const dist = (a, b) => {
|
|
906
|
+
const m = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
|
|
907
|
+
for (let j = 1; j <= b.length; j++) m[0][j] = j;
|
|
908
|
+
for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) m[i][j] = Math.min(m[i - 1][j] + 1, m[i][j - 1] + 1, m[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
909
|
+
return m[a.length][b.length];
|
|
910
|
+
};
|
|
911
|
+
let best = null;
|
|
912
|
+
let bd = 3;
|
|
913
|
+
for (const o of options) {
|
|
914
|
+
const d = dist(word, o);
|
|
915
|
+
if (d < bd) {
|
|
916
|
+
bd = d;
|
|
917
|
+
best = o;
|
|
918
|
+
}
|
|
809
919
|
}
|
|
810
|
-
return
|
|
920
|
+
return best;
|
|
921
|
+
}
|
|
922
|
+
function completion(shell) {
|
|
923
|
+
const words = GROUPS.join(" ");
|
|
924
|
+
if (shell === "bash") return `_nixflex() { COMPREPLY=($(compgen -W "${words}" -- "\${COMP_WORDS[COMP_CWORD]}")); }
|
|
925
|
+
complete -F _nixflex nixflex
|
|
926
|
+
`;
|
|
927
|
+
if (shell === "zsh") return `#compdef nixflex
|
|
928
|
+
_arguments "1: :(${words})"
|
|
929
|
+
`;
|
|
930
|
+
if (shell === "pwsh") return `Register-ArgumentCompleter -Native -CommandName nixflex -ScriptBlock { param($wordToComplete) '${GROUPS.join("','")}' | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } }
|
|
931
|
+
`;
|
|
932
|
+
fail("completion expects bash, zsh or pwsh");
|
|
811
933
|
}
|
|
812
934
|
function mcpSetup(app) {
|
|
813
935
|
const home = homedir();
|
|
814
|
-
const
|
|
936
|
+
const stored = readConfig().api_key;
|
|
937
|
+
const entry = { command: "npx", args: ["-y", "nixflex-mcp"] };
|
|
938
|
+
if (!stored && process.env.NIXFLEX_API_KEY) entry.env = { NIXFLEX_API_KEY: process.env.NIXFLEX_API_KEY };
|
|
939
|
+
if (!stored && !process.env.NIXFLEX_API_KEY) fail("Run 'nixflex login' first so the MCP server can find your key.");
|
|
815
940
|
let file;
|
|
816
941
|
let root;
|
|
817
942
|
if (app === "claude") {
|
|
@@ -835,7 +960,7 @@ function mcpSetup(app) {
|
|
|
835
960
|
const dir = join(file, "..");
|
|
836
961
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
837
962
|
writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n");
|
|
838
|
-
out({ written: file, server: "nixflex",
|
|
963
|
+
out({ written: file, server: "nixflex", key: stored ? "from ~/.nixflex/config.json" : "written into the config env", note: "Fully quit and reopen " + app + "." });
|
|
839
964
|
}
|
|
840
965
|
async function main() {
|
|
841
966
|
const { values, positionals } = parseArgs({
|
|
@@ -845,10 +970,15 @@ async function main() {
|
|
|
845
970
|
options: {
|
|
846
971
|
json: { type: "boolean" },
|
|
847
972
|
key: { type: "string" },
|
|
973
|
+
"base-url": { type: "string" },
|
|
848
974
|
help: { type: "boolean", short: "h" },
|
|
849
975
|
version: { type: "boolean", short: "v" },
|
|
850
976
|
confirm: { type: "boolean" },
|
|
977
|
+
yes: { type: "boolean", short: "y" },
|
|
851
978
|
limit: { type: "string" },
|
|
979
|
+
status: { type: "string" },
|
|
980
|
+
set: { type: "string", multiple: true },
|
|
981
|
+
body: { type: "string" },
|
|
852
982
|
name: { type: "string" },
|
|
853
983
|
prompt: { type: "string" },
|
|
854
984
|
voice: { type: "string" },
|
|
@@ -859,6 +989,10 @@ async function main() {
|
|
|
859
989
|
from: { type: "string" },
|
|
860
990
|
var: { type: "string", multiple: true },
|
|
861
991
|
message: { type: "string" },
|
|
992
|
+
wait: { type: "boolean" },
|
|
993
|
+
timeout: { type: "string" },
|
|
994
|
+
csv: { type: "string" },
|
|
995
|
+
slot: { type: "string" },
|
|
862
996
|
"sms-reply": { type: "string" },
|
|
863
997
|
"sms-prompt": { type: "string" },
|
|
864
998
|
dtmf: { type: "string" },
|
|
@@ -870,7 +1004,9 @@ async function main() {
|
|
|
870
1004
|
}
|
|
871
1005
|
});
|
|
872
1006
|
JSON_MODE = !!values.json;
|
|
1007
|
+
const confirmed = !!(values.confirm || values.yes);
|
|
873
1008
|
const [group, cmd, a1, a2] = positionals;
|
|
1009
|
+
const s = (k) => values[k];
|
|
874
1010
|
if (values.version) {
|
|
875
1011
|
process.stdout.write(VERSION + "\n");
|
|
876
1012
|
return;
|
|
@@ -879,12 +1015,17 @@ async function main() {
|
|
|
879
1015
|
process.stdout.write(HELP);
|
|
880
1016
|
return;
|
|
881
1017
|
}
|
|
882
|
-
|
|
1018
|
+
if (!GROUPS.includes(group)) {
|
|
1019
|
+
const c = closest(group, GROUPS);
|
|
1020
|
+
fail('unknown command "' + group + '".' + (c ? " Did you mean `nixflex " + c + "`?" : "") + " Run `nixflex --help`.");
|
|
1021
|
+
}
|
|
883
1022
|
if (group === "login") {
|
|
884
|
-
const key = process.env.NIXFLEX_API_KEY || await ask("API key (nxf_xxx:nxfs_xxx): "
|
|
885
|
-
if (
|
|
886
|
-
await new src_default({ apiKey: key }).usage.get().catch((e) => fail("Key rejected: " + e.message));
|
|
887
|
-
|
|
1023
|
+
const key = process.env.NIXFLEX_API_KEY || await ask("API key (nxf_xxx:nxfs_xxx): ");
|
|
1024
|
+
if (!KEY_RE.test(key)) fail("That is not a full key pair (nxf_xxx:nxfs_xxx).");
|
|
1025
|
+
await new src_default({ apiKey: key, baseUrl: s("base-url") }).usage.get().catch((e) => fail("Key rejected: " + e.message));
|
|
1026
|
+
const cfg = { ...readConfig(), api_key: key };
|
|
1027
|
+
if (s("base-url")) cfg.base_url = s("base-url");
|
|
1028
|
+
writeConfig(cfg);
|
|
888
1029
|
out({ logged_in: true, key_id: key.split(":")[0], config: CONFIG_FILE });
|
|
889
1030
|
return;
|
|
890
1031
|
}
|
|
@@ -895,14 +1036,28 @@ async function main() {
|
|
|
895
1036
|
out({ logged_out: true });
|
|
896
1037
|
return;
|
|
897
1038
|
}
|
|
1039
|
+
if (group === "completion") {
|
|
1040
|
+
process.stdout.write(completion(cmd || ""));
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
898
1043
|
if (group === "mcp") {
|
|
899
1044
|
if (cmd !== "setup") fail("usage: nixflex mcp setup <claude|cursor|vscode>");
|
|
900
1045
|
mcpSetup(a1);
|
|
901
1046
|
return;
|
|
902
1047
|
}
|
|
903
|
-
|
|
904
|
-
const client = new src_default({ apiKey: resolveKey(s("key")), baseUrl: readConfig().base_url });
|
|
1048
|
+
const client = new src_default({ apiKey: resolveKey(s("key")), baseUrl: s("base-url") || readConfig().base_url });
|
|
905
1049
|
const limit = s("limit") ? parseInt(s("limit"), 10) : void 0;
|
|
1050
|
+
const slot = s("slot") === "2" ? 2 : 1;
|
|
1051
|
+
const preview = async (what, fetch2) => {
|
|
1052
|
+
if (confirmed) return true;
|
|
1053
|
+
let current = null;
|
|
1054
|
+
try {
|
|
1055
|
+
current = await fetch2();
|
|
1056
|
+
} catch {
|
|
1057
|
+
}
|
|
1058
|
+
out({ would_delete: what, current, hint: "add --confirm (or --yes) to proceed" });
|
|
1059
|
+
return false;
|
|
1060
|
+
};
|
|
906
1061
|
if (group === "whoami") {
|
|
907
1062
|
const u = await client.usage.get();
|
|
908
1063
|
out({ key_id: resolveKey(s("key")).split(":")[0], ...u });
|
|
@@ -913,7 +1068,7 @@ async function main() {
|
|
|
913
1068
|
return;
|
|
914
1069
|
}
|
|
915
1070
|
if (group === "doctor") {
|
|
916
|
-
const checks = { version: VERSION, node: process.version, key_source: s("key") ? "--key" : process.env.NIXFLEX_API_KEY ? "env" : "config" };
|
|
1071
|
+
const checks = { version: VERSION, node: process.version, key_source: s("key") ? "--key" : process.env.NIXFLEX_API_KEY ? "env" : "config", base_url: s("base-url") || readConfig().base_url || "https://api.nixflex.com" };
|
|
917
1072
|
try {
|
|
918
1073
|
const t = Date.now();
|
|
919
1074
|
await client.usage.get();
|
|
@@ -924,6 +1079,17 @@ async function main() {
|
|
|
924
1079
|
out(checks);
|
|
925
1080
|
return;
|
|
926
1081
|
}
|
|
1082
|
+
if (group === "keys") {
|
|
1083
|
+
if (cmd !== "rotate") fail("keys: rotate --confirm");
|
|
1084
|
+
if (!confirmed) {
|
|
1085
|
+
out({ would_rotate: resolveKey(s("key")).split(":")[0], warning: "The current secret stops working the moment this runs. Update every place that uses it, then `nixflex login` again.", hint: "add --confirm to proceed" });
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const r = await client.keys.rotate();
|
|
1089
|
+
out(r);
|
|
1090
|
+
note("Run `nixflex login` with the new secret.");
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
927
1093
|
if (group === "agents") {
|
|
928
1094
|
if (cmd === "list") {
|
|
929
1095
|
out(await client.agents.list(limit ? { limit } : {}));
|
|
@@ -935,33 +1101,21 @@ async function main() {
|
|
|
935
1101
|
return;
|
|
936
1102
|
}
|
|
937
1103
|
if (cmd === "create") {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (s("voice")) body.voice_id = s("voice");
|
|
941
|
-
if (s("language")) body.language = s("language");
|
|
1104
|
+
const body = bodyFrom(values, { name: s("name"), system_prompt: textOrFile(s("prompt")), voice_id: s("voice"), language: s("language") });
|
|
1105
|
+
if (!body.name || !body.system_prompt) fail("agents create --name NAME --prompt TEXT|@file [--set k=v ...]");
|
|
942
1106
|
out(await client.agents.create(body));
|
|
943
1107
|
return;
|
|
944
1108
|
}
|
|
945
1109
|
if (cmd === "update") {
|
|
946
|
-
if (!a1) fail("agents update <agent_id> [
|
|
947
|
-
const body = {};
|
|
948
|
-
if (
|
|
949
|
-
if (s("prompt")) body.system_prompt = textOrFile(s("prompt"));
|
|
950
|
-
if (s("voice")) body.voice_id = s("voice");
|
|
951
|
-
if (s("language")) body.language = s("language");
|
|
952
|
-
const ic = boolOrNull(s("incall-sms"));
|
|
953
|
-
if (ic !== void 0) body.incall_sms_enabled = ic;
|
|
954
|
-
if (Object.keys(body).length === 0) fail("nothing to update - pass at least one flag");
|
|
1110
|
+
if (!a1) fail("agents update <agent_id> [flags] [--set k=v ...]");
|
|
1111
|
+
const body = bodyFrom(values, { name: s("name"), system_prompt: textOrFile(s("prompt")), voice_id: s("voice"), language: s("language"), incall_sms_enabled: boolOrNull(s("incall-sms")) });
|
|
1112
|
+
if (Object.keys(body).length === 0) fail("nothing to update - pass a flag or --set field=value");
|
|
955
1113
|
out(await client.agents.update(a1, body));
|
|
956
1114
|
return;
|
|
957
1115
|
}
|
|
958
1116
|
if (cmd === "delete") {
|
|
959
1117
|
if (!a1) fail("agents delete <agent_id> --confirm");
|
|
960
|
-
if (!
|
|
961
|
-
const ag = await client.agents.get(a1);
|
|
962
|
-
out({ would_delete: ag.name, agent_id: a1, hint: "add --confirm to delete" });
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
1118
|
+
if (!await preview("agent " + a1, () => client.agents.get(a1))) return;
|
|
965
1119
|
out(await client.agents.delete(a1));
|
|
966
1120
|
return;
|
|
967
1121
|
}
|
|
@@ -969,13 +1123,30 @@ async function main() {
|
|
|
969
1123
|
}
|
|
970
1124
|
if (group === "calls") {
|
|
971
1125
|
if (cmd === "create") {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1126
|
+
const body = bodyFrom(values, { agent_id: s("agent"), to_number: s("to"), prompt: textOrFile(s("prompt")), from_number: s("from"), variables: vars(values.var) });
|
|
1127
|
+
if (!body.agent_id || !body.to_number || !body.prompt) fail("calls create --agent ID --to +44... --prompt TEXT|@file [--from] [--var k=v] [--wait]");
|
|
1128
|
+
const created = await client.calls.create(body);
|
|
1129
|
+
if (!values.wait) {
|
|
1130
|
+
out(created);
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const id = created.call_id;
|
|
1134
|
+
if (!id) {
|
|
1135
|
+
out(created);
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const deadline = Date.now() + (s("timeout") ? parseInt(s("timeout"), 10) : 300) * 1e3;
|
|
1139
|
+
note("call " + id + " placed - waiting for it to end (Ctrl+C to stop waiting; the call continues)");
|
|
1140
|
+
while (Date.now() < deadline) {
|
|
1141
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
1142
|
+
const c = await client.calls.get(id).catch(() => null);
|
|
1143
|
+
if (c && (c.ended_reason || /^(completed|failed|no[-_]answer|busy|canceled|cancelled)$/i.test(c.call_status || ""))) {
|
|
1144
|
+
out(c);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
note(" " + (c && c.call_status ? c.call_status : "in progress") + "...");
|
|
1148
|
+
}
|
|
1149
|
+
fail("still in progress after the timeout - `nixflex calls get " + id + "` later");
|
|
979
1150
|
}
|
|
980
1151
|
if (cmd === "list") {
|
|
981
1152
|
const q = {};
|
|
@@ -989,7 +1160,37 @@ async function main() {
|
|
|
989
1160
|
out(await client.calls.get(a1));
|
|
990
1161
|
return;
|
|
991
1162
|
}
|
|
992
|
-
|
|
1163
|
+
if (cmd === "delete") {
|
|
1164
|
+
if (!a1) fail("calls delete <call_id> --confirm");
|
|
1165
|
+
if (!await preview("call " + a1 + " and its recording", () => client.calls.get(a1))) return;
|
|
1166
|
+
out(await client.calls.delete(a1));
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (cmd === "delete-all") {
|
|
1170
|
+
if (!confirmed) {
|
|
1171
|
+
out({ would_delete: "EVERY call, recording and SMS record on this account", hint: "add --confirm to proceed - this cannot be undone" });
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
out(await client.calls.deleteAll());
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
fail("calls: create | list | get | delete | delete-all");
|
|
1178
|
+
}
|
|
1179
|
+
if (group === "campaigns") {
|
|
1180
|
+
if (cmd === "create") {
|
|
1181
|
+
const body = bodyFrom(values, { agent_id: s("agent"), from_number: s("from"), prompt: textOrFile(s("prompt")), name: s("name") });
|
|
1182
|
+
if (s("csv")) body.recipients = recipientsFromCsv(s("csv"), true);
|
|
1183
|
+
if (!body.agent_id || !body.from_number || !body.prompt || !Array.isArray(body.recipients)) fail("campaigns create --agent ID --from +44... --prompt TEXT|@file --csv people.csv [--set k=v ...]");
|
|
1184
|
+
note("creating campaign with " + body.recipients.length + " recipient(s)");
|
|
1185
|
+
out(await client.campaigns.create(body));
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (cmd === "launch") {
|
|
1189
|
+
if (!a1) fail("campaigns launch <campaign_id>");
|
|
1190
|
+
out(await client.campaigns.launch(a1));
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
fail("campaigns: create | launch");
|
|
993
1194
|
}
|
|
994
1195
|
if (group === "numbers") {
|
|
995
1196
|
if (cmd === "list") {
|
|
@@ -997,19 +1198,44 @@ async function main() {
|
|
|
997
1198
|
out(JSON_MODE ? r : r.phone_numbers);
|
|
998
1199
|
return;
|
|
999
1200
|
}
|
|
1201
|
+
if (cmd === "import") {
|
|
1202
|
+
const body = bodyFrom(values);
|
|
1203
|
+
if (!body.phone_number || !body.agent_id) fail("numbers import --set phone_number=+44... --set agent_id=ID --set <carrier credentials> (or --body @number.json)");
|
|
1204
|
+
out(await client.phoneNumbers.import(body));
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1000
1207
|
if (cmd === "update") {
|
|
1001
|
-
if (!a1) fail("numbers update <number> [
|
|
1002
|
-
const body = {};
|
|
1003
|
-
|
|
1004
|
-
if (sr !== void 0) body.sms_reply_enabled = sr;
|
|
1005
|
-
if (s("sms-prompt") !== void 0) body.sms_prompt = nullable(textOrFile(s("sms-prompt")));
|
|
1006
|
-
const d = boolOrNull(s("dtmf"));
|
|
1007
|
-
if (d !== void 0) body.dtmf_enabled = d;
|
|
1008
|
-
if (Object.keys(body).length === 0) fail("nothing to update - pass at least one flag");
|
|
1208
|
+
if (!a1) fail("numbers update <number> [flags] [--set k=v ...]");
|
|
1209
|
+
const body = bodyFrom(values, { sms_reply_enabled: boolOrNull(s("sms-reply")), sms_prompt: s("sms-prompt") === void 0 ? void 0 : s("sms-prompt") === "null" ? null : textOrFile(s("sms-prompt")), dtmf_enabled: boolOrNull(s("dtmf")) });
|
|
1210
|
+
if (Object.keys(body).length === 0) fail("nothing to update - pass a flag or --set field=value");
|
|
1009
1211
|
out(await client.phoneNumbers.update(a1, body));
|
|
1010
1212
|
return;
|
|
1011
1213
|
}
|
|
1012
|
-
|
|
1214
|
+
if (cmd === "delete") {
|
|
1215
|
+
if (!a1) fail("numbers delete <number> --confirm");
|
|
1216
|
+
if (!confirmed) {
|
|
1217
|
+
out({ would_delete: "number " + a1 + " from Nixflex (your carrier keeps it and keeps billing it)", hint: "add --confirm to proceed" });
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
out(await client.phoneNumbers.delete(a1));
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
if (cmd === "monitor" || cmd === "web-calls") {
|
|
1224
|
+
if (!a1) fail("numbers " + cmd + " <number> [get|on|off]");
|
|
1225
|
+
const action = a2 || "get";
|
|
1226
|
+
const isMon = cmd === "monitor";
|
|
1227
|
+
if (action === "get") {
|
|
1228
|
+
out(isMon ? await client.phoneNumbers.getMonitor(a1) : await client.phoneNumbers.getWebCalls(a1));
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (action === "on" || action === "off") {
|
|
1232
|
+
if (isMon && action === "on") note("note: monitoring bills this number's inbound calls at the premium rate");
|
|
1233
|
+
out(isMon ? await client.phoneNumbers.setMonitor(a1, action === "on") : await client.phoneNumbers.setWebCalls(a1, action === "on"));
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
fail("numbers " + cmd + " <number> [get|on|off]");
|
|
1237
|
+
}
|
|
1238
|
+
fail("numbers: list | import | update | delete | monitor | web-calls");
|
|
1013
1239
|
}
|
|
1014
1240
|
if (group === "callers") {
|
|
1015
1241
|
if (cmd === "get") {
|
|
@@ -1019,12 +1245,9 @@ async function main() {
|
|
|
1019
1245
|
return;
|
|
1020
1246
|
}
|
|
1021
1247
|
if (cmd === "set") {
|
|
1022
|
-
if (!a1 || !a2) fail("callers set <your_number> <caller_number> --name ... --email ...");
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
const v = nullable(s(flag));
|
|
1026
|
-
if (v !== void 0) body[field] = v;
|
|
1027
|
-
}
|
|
1248
|
+
if (!a1 || !a2) fail("callers set <your_number> <caller_number> --name ... --email ... [--set k=v]");
|
|
1249
|
+
const nul = (v) => v === void 0 ? void 0 : v === "null" ? null : v;
|
|
1250
|
+
const body = bodyFrom(values, { name: nul(s("name")), email: nul(s("email")), phone: nul(s("phone")), location: nul(s("location")), reference_id: nul(s("reference")), preference: nul(s("preference")) });
|
|
1028
1251
|
if (Object.keys(body).length === 0) fail("nothing to set - pass at least one of --name --email --phone --location --reference --preference");
|
|
1029
1252
|
const r = await client.callers.set(a1, a2, body);
|
|
1030
1253
|
out(JSON_MODE ? r : r.caller.context);
|
|
@@ -1042,6 +1265,7 @@ async function main() {
|
|
|
1042
1265
|
for (const [k, v] of Object.entries(r2)) if (v !== "") o[k] = v;
|
|
1043
1266
|
return o;
|
|
1044
1267
|
});
|
|
1268
|
+
note("importing rows " + (i + 1) + "-" + Math.min(i + 1e3, rows.length) + " of " + rows.length);
|
|
1045
1269
|
const r = await client.callers.import(a1, chunk);
|
|
1046
1270
|
imported += r.imported;
|
|
1047
1271
|
}
|
|
@@ -1050,11 +1274,7 @@ async function main() {
|
|
|
1050
1274
|
}
|
|
1051
1275
|
if (cmd === "delete") {
|
|
1052
1276
|
if (!a1 || !a2) fail("callers delete <your_number> <caller_number> --confirm");
|
|
1053
|
-
if (!
|
|
1054
|
-
const r = await client.callers.get(a1, a2);
|
|
1055
|
-
out({ would_delete: r.caller.context, hint: "add --confirm to delete" });
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1277
|
+
if (!await preview("caller " + a2 + " on " + a1, async () => (await client.callers.get(a1, a2)).caller.context)) return;
|
|
1058
1278
|
out(await client.callers.delete(a1, a2));
|
|
1059
1279
|
return;
|
|
1060
1280
|
}
|
|
@@ -1062,11 +1282,86 @@ async function main() {
|
|
|
1062
1282
|
}
|
|
1063
1283
|
if (group === "sms") {
|
|
1064
1284
|
if (cmd === "send") {
|
|
1065
|
-
|
|
1066
|
-
|
|
1285
|
+
const body = bodyFrom(values, { agent_id: s("agent"), from_number: s("from"), to: s("to"), message: textOrFile(s("message")) });
|
|
1286
|
+
if (!body.agent_id || !body.from_number || !body.to || !body.message) fail("sms send --agent ID --from +44... --to +44... --message TEXT");
|
|
1287
|
+
out(await client.sms.send(body));
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (cmd === "campaigns") {
|
|
1291
|
+
const sub = a1;
|
|
1292
|
+
const id = a2;
|
|
1293
|
+
if (sub === "create") {
|
|
1294
|
+
const body = bodyFrom(values, { agent_id: s("agent"), from_number: s("from"), message: textOrFile(s("message")), name: s("name") });
|
|
1295
|
+
if (s("csv")) body.recipients = recipientsFromCsv(s("csv"), false);
|
|
1296
|
+
if (!body.agent_id || !body.from_number || !body.message || !Array.isArray(body.recipients)) fail("sms campaigns create --agent ID --from +44... --message TEXT|@file --csv people.csv");
|
|
1297
|
+
out(await client.sms.campaigns.create(body));
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
if (sub === "launch") {
|
|
1301
|
+
if (!id) fail("sms campaigns launch <id>");
|
|
1302
|
+
out(await client.sms.campaigns.launch(id));
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
if (sub === "list") {
|
|
1306
|
+
const q = {};
|
|
1307
|
+
if (limit) q.limit = limit;
|
|
1308
|
+
if (s("status")) q.status = s("status");
|
|
1309
|
+
const r = await client.sms.campaigns.list(q);
|
|
1310
|
+
out(JSON_MODE ? r : r.campaigns || r);
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
if (sub === "get") {
|
|
1314
|
+
if (!id) fail("sms campaigns get <id>");
|
|
1315
|
+
out(await client.sms.campaigns.get(id));
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
if (sub === "delete") {
|
|
1319
|
+
if (!id) fail("sms campaigns delete <id> --confirm");
|
|
1320
|
+
if (!await preview("sms campaign " + id + " (pending recipients will not be messaged)", () => client.sms.campaigns.get(id))) return;
|
|
1321
|
+
out(await client.sms.campaigns.delete(id));
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
fail("sms campaigns: create | launch | list | get | delete");
|
|
1325
|
+
}
|
|
1326
|
+
fail("sms: send | campaigns");
|
|
1327
|
+
}
|
|
1328
|
+
if (group === "webhooks") {
|
|
1329
|
+
if (cmd === "set") {
|
|
1330
|
+
if (!a1 || !a2) fail("webhooks set <number> <url> [--slot 1|2]");
|
|
1331
|
+
out(await client.webhooks.set(a1, a2, slot));
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
if (cmd === "get") {
|
|
1335
|
+
if (!a1) fail("webhooks get <number> [--slot 1|2]");
|
|
1336
|
+
out(await client.webhooks.get(a1, slot));
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
if (cmd === "delete") {
|
|
1340
|
+
if (!a1) fail("webhooks delete <number> [--slot 1|2] --confirm");
|
|
1341
|
+
if (!await preview("webhook slot " + slot + " on " + a1, () => client.webhooks.get(a1, slot))) return;
|
|
1342
|
+
out(await client.webhooks.delete(a1, slot));
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
fail("webhooks: set | get | delete");
|
|
1346
|
+
}
|
|
1347
|
+
if (group === "storage" || group === "llm" || group === "tts") {
|
|
1348
|
+
const res = client[group];
|
|
1349
|
+
if (cmd === "set") {
|
|
1350
|
+
const body = bodyFrom(values);
|
|
1351
|
+
if (Object.keys(body).length === 0) fail(group + " set --set field=value ... (or --body @file.json) - see https://docs.nixflex.com/advanced/your-own-" + group);
|
|
1352
|
+
out(await res.set(body));
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
if (cmd === "get") {
|
|
1356
|
+
out(await res.get());
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (cmd === "delete") {
|
|
1360
|
+
if (!await preview("your own " + group + " configuration (calls fall back to Nixflex)", () => res.get())) return;
|
|
1361
|
+
out(await res.delete());
|
|
1067
1362
|
return;
|
|
1068
1363
|
}
|
|
1069
|
-
fail("
|
|
1364
|
+
fail(group + ": set | get | delete");
|
|
1070
1365
|
}
|
|
1071
1366
|
fail('unknown command "' + group + '". Run `nixflex --help`.');
|
|
1072
1367
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -117,7 +117,7 @@ function errorFromResponse(status, body, requestId, retryAfterSeconds) {
|
|
|
117
117
|
// src/client.ts
|
|
118
118
|
var DEFAULT_BASE_URL = "https://api.nixflex.com";
|
|
119
119
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
120
|
-
var SDK_VERSION = "0.
|
|
120
|
+
var SDK_VERSION = "0.8.0";
|
|
121
121
|
var HttpClient = class {
|
|
122
122
|
apiKey;
|
|
123
123
|
baseUrl;
|
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,8 @@ interface AgentCreateParams {
|
|
|
62
62
|
silence_hangup_seconds?: number;
|
|
63
63
|
/** Save call audio. Recordings delete after 90 days. Default true. */
|
|
64
64
|
record_call?: boolean;
|
|
65
|
+
/** Who records when record_call is on. 'provider' = your carrier records (whole call, including after a transfer to a person; carrier recording charges apply). 'nixflex' = the voice engine records the conversation itself at no extra cost; a transfer to a person is not included. Default 'provider'. */
|
|
66
|
+
recording_source?: 'provider' | 'nixflex';
|
|
65
67
|
/** Carrier answering-machine detection: fast hangup ~4s in, NO voicemail message, extra carrier cost. OFF lets the agent detect voicemail itself and leave a message. Default false. */
|
|
66
68
|
amd_enabled?: boolean;
|
|
67
69
|
/** Keypad digits instead of speech. Three-state: true/false explicit, null = not set (a number's own setting decides). */
|
|
@@ -115,6 +117,7 @@ interface Agent {
|
|
|
115
117
|
max_call_duration_seconds: number;
|
|
116
118
|
silence_hangup_seconds: number;
|
|
117
119
|
record_call: boolean;
|
|
120
|
+
recording_source: 'provider' | 'nixflex';
|
|
118
121
|
func_end_call?: boolean;
|
|
119
122
|
transfer_whisper?: string | null;
|
|
120
123
|
func_send_sms?: boolean;
|
|
@@ -407,6 +410,7 @@ interface PhoneNumber {
|
|
|
407
410
|
speaking_rate?: number | null;
|
|
408
411
|
dtmf_enabled?: boolean | null;
|
|
409
412
|
record_call?: boolean | null;
|
|
413
|
+
recording_source?: 'provider' | 'nixflex' | null;
|
|
410
414
|
created_at?: string;
|
|
411
415
|
}
|
|
412
416
|
/** Every field optional - send only what changes; omitted fields are untouched.
|
|
@@ -434,6 +438,8 @@ interface PhoneNumberUpdateParams {
|
|
|
434
438
|
dtmf_enabled?: boolean | null;
|
|
435
439
|
/** Recording: null = inherit; false stops recording this number while the agent keeps recording. */
|
|
436
440
|
record_call?: boolean | null;
|
|
441
|
+
/** Who records on this number: 'provider' (carrier) or 'nixflex' (voice engine). null = inherit the agent. Ignored while record_call is off. */
|
|
442
|
+
recording_source?: 'provider' | 'nixflex' | null;
|
|
437
443
|
}
|
|
438
444
|
interface PhoneNumberListResponse {
|
|
439
445
|
phone_numbers: PhoneNumber[];
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ interface AgentCreateParams {
|
|
|
62
62
|
silence_hangup_seconds?: number;
|
|
63
63
|
/** Save call audio. Recordings delete after 90 days. Default true. */
|
|
64
64
|
record_call?: boolean;
|
|
65
|
+
/** Who records when record_call is on. 'provider' = your carrier records (whole call, including after a transfer to a person; carrier recording charges apply). 'nixflex' = the voice engine records the conversation itself at no extra cost; a transfer to a person is not included. Default 'provider'. */
|
|
66
|
+
recording_source?: 'provider' | 'nixflex';
|
|
65
67
|
/** Carrier answering-machine detection: fast hangup ~4s in, NO voicemail message, extra carrier cost. OFF lets the agent detect voicemail itself and leave a message. Default false. */
|
|
66
68
|
amd_enabled?: boolean;
|
|
67
69
|
/** Keypad digits instead of speech. Three-state: true/false explicit, null = not set (a number's own setting decides). */
|
|
@@ -115,6 +117,7 @@ interface Agent {
|
|
|
115
117
|
max_call_duration_seconds: number;
|
|
116
118
|
silence_hangup_seconds: number;
|
|
117
119
|
record_call: boolean;
|
|
120
|
+
recording_source: 'provider' | 'nixflex';
|
|
118
121
|
func_end_call?: boolean;
|
|
119
122
|
transfer_whisper?: string | null;
|
|
120
123
|
func_send_sms?: boolean;
|
|
@@ -407,6 +410,7 @@ interface PhoneNumber {
|
|
|
407
410
|
speaking_rate?: number | null;
|
|
408
411
|
dtmf_enabled?: boolean | null;
|
|
409
412
|
record_call?: boolean | null;
|
|
413
|
+
recording_source?: 'provider' | 'nixflex' | null;
|
|
410
414
|
created_at?: string;
|
|
411
415
|
}
|
|
412
416
|
/** Every field optional - send only what changes; omitted fields are untouched.
|
|
@@ -434,6 +438,8 @@ interface PhoneNumberUpdateParams {
|
|
|
434
438
|
dtmf_enabled?: boolean | null;
|
|
435
439
|
/** Recording: null = inherit; false stops recording this number while the agent keeps recording. */
|
|
436
440
|
record_call?: boolean | null;
|
|
441
|
+
/** Who records on this number: 'provider' (carrier) or 'nixflex' (voice engine). null = inherit the agent. Ignored while record_call is off. */
|
|
442
|
+
recording_source?: 'provider' | 'nixflex' | null;
|
|
437
443
|
}
|
|
438
444
|
interface PhoneNumberListResponse {
|
|
439
445
|
phone_numbers: PhoneNumber[];
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,7 @@ function errorFromResponse(status, body, requestId, retryAfterSeconds) {
|
|
|
81
81
|
// src/client.ts
|
|
82
82
|
var DEFAULT_BASE_URL = "https://api.nixflex.com";
|
|
83
83
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
84
|
-
var SDK_VERSION = "0.
|
|
84
|
+
var SDK_VERSION = "0.8.0";
|
|
85
85
|
var HttpClient = class {
|
|
86
86
|
apiKey;
|
|
87
87
|
baseUrl;
|