@arbidocs/cli 0.3.9 → 0.3.11
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 +19 -5
- package/dist/index.js +262 -162
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ var commander = require('commander');
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var os = require('os');
|
|
7
7
|
var path = require('path');
|
|
8
|
-
var
|
|
8
|
+
var sdk = require('@arbidocs/sdk');
|
|
9
9
|
var chalk = require('chalk');
|
|
10
10
|
var prompts = require('@inquirer/prompts');
|
|
11
11
|
var child_process = require('child_process');
|
|
12
|
-
var
|
|
12
|
+
var client = require('@arbidocs/client');
|
|
13
13
|
var module$1 = require('module');
|
|
14
14
|
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -20,7 +20,7 @@ var os__default = /*#__PURE__*/_interopDefault(os);
|
|
|
20
20
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
21
21
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
22
22
|
|
|
23
|
-
var store = new
|
|
23
|
+
var store = new sdk.FileConfigStore();
|
|
24
24
|
function getConfig() {
|
|
25
25
|
return store.getConfig();
|
|
26
26
|
}
|
|
@@ -31,7 +31,7 @@ function requireConfig() {
|
|
|
31
31
|
try {
|
|
32
32
|
return store.requireConfig();
|
|
33
33
|
} catch (err) {
|
|
34
|
-
if (err instanceof
|
|
34
|
+
if (err instanceof sdk.ArbiError) {
|
|
35
35
|
console.error(err.message);
|
|
36
36
|
process.exit(1);
|
|
37
37
|
}
|
|
@@ -3502,7 +3502,7 @@ function getLatestVersion(skipCache = false) {
|
|
|
3502
3502
|
}
|
|
3503
3503
|
}
|
|
3504
3504
|
function getCurrentVersion() {
|
|
3505
|
-
return "0.3.
|
|
3505
|
+
return "0.3.11";
|
|
3506
3506
|
}
|
|
3507
3507
|
function readChangelog(fromVersion, toVersion) {
|
|
3508
3508
|
try {
|
|
@@ -3518,9 +3518,11 @@ function extractSections(changelog, fromVersion, toVersion) {
|
|
|
3518
3518
|
const lines = changelog.split("\n");
|
|
3519
3519
|
const sections = [];
|
|
3520
3520
|
let capturing = false;
|
|
3521
|
+
let skipSection = false;
|
|
3521
3522
|
for (const line of lines) {
|
|
3522
3523
|
const match = line.match(/^## v(.+)/);
|
|
3523
3524
|
if (match) {
|
|
3525
|
+
skipSection = false;
|
|
3524
3526
|
const version = match[1].trim();
|
|
3525
3527
|
if (version === fromVersion) {
|
|
3526
3528
|
break;
|
|
@@ -3529,11 +3531,19 @@ function extractSections(changelog, fromVersion, toVersion) {
|
|
|
3529
3531
|
capturing = true;
|
|
3530
3532
|
}
|
|
3531
3533
|
}
|
|
3532
|
-
if (capturing)
|
|
3533
|
-
|
|
3534
|
+
if (!capturing) continue;
|
|
3535
|
+
if (line.match(/^\[compare changes\]/)) continue;
|
|
3536
|
+
if (line.match(/^### .*(Chore|Contributors)/)) {
|
|
3537
|
+
skipSection = true;
|
|
3538
|
+
continue;
|
|
3539
|
+
}
|
|
3540
|
+
if (skipSection && line.match(/^### /)) {
|
|
3541
|
+
skipSection = false;
|
|
3534
3542
|
}
|
|
3543
|
+
if (skipSection) continue;
|
|
3544
|
+
sections.push(line);
|
|
3535
3545
|
}
|
|
3536
|
-
const result = sections.join("\n").trim();
|
|
3546
|
+
const result = sections.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
3537
3547
|
return result || null;
|
|
3538
3548
|
}
|
|
3539
3549
|
function showChangelog(fromVersion, toVersion) {
|
|
@@ -3545,17 +3555,17 @@ function showChangelog(fromVersion, toVersion) {
|
|
|
3545
3555
|
async function checkForUpdates(autoUpdate) {
|
|
3546
3556
|
try {
|
|
3547
3557
|
const latest = getLatestVersion();
|
|
3548
|
-
if (!latest || latest === "0.3.
|
|
3558
|
+
if (!latest || latest === "0.3.11") return;
|
|
3549
3559
|
if (autoUpdate) {
|
|
3550
3560
|
warn(`
|
|
3551
|
-
Your arbi version is out of date (${"0.3.
|
|
3561
|
+
Your arbi version is out of date (${"0.3.11"} \u2192 ${latest}). Updating...`);
|
|
3552
3562
|
child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
|
|
3553
|
-
showChangelog("0.3.
|
|
3563
|
+
showChangelog("0.3.11", latest);
|
|
3554
3564
|
console.log(`Updated to ${latest}.`);
|
|
3555
3565
|
} else {
|
|
3556
3566
|
warn(
|
|
3557
3567
|
`
|
|
3558
|
-
Your arbi version is out of date (${"0.3.
|
|
3568
|
+
Your arbi version is out of date (${"0.3.11"} \u2192 ${latest}).
|
|
3559
3569
|
Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
|
|
3560
3570
|
);
|
|
3561
3571
|
}
|
|
@@ -3565,9 +3575,9 @@ Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
|
|
|
3565
3575
|
function hintUpdateOnError() {
|
|
3566
3576
|
try {
|
|
3567
3577
|
const cached = readCache();
|
|
3568
|
-
if (cached && cached.latest !== "0.3.
|
|
3578
|
+
if (cached && cached.latest !== "0.3.11") {
|
|
3569
3579
|
warn(
|
|
3570
|
-
`Your arbi version is out of date (${"0.3.
|
|
3580
|
+
`Your arbi version is out of date (${"0.3.11"} \u2192 ${cached.latest}). Run "arbi update".`
|
|
3571
3581
|
);
|
|
3572
3582
|
}
|
|
3573
3583
|
} catch {
|
|
@@ -3581,37 +3591,40 @@ function registerLoginCommand(program2) {
|
|
|
3581
3591
|
const email = opts.email || process.env.ARBI_EMAIL || await promptInput("Email");
|
|
3582
3592
|
const pw = opts.password || process.env.ARBI_PASSWORD || await promptPassword("Password");
|
|
3583
3593
|
try {
|
|
3584
|
-
const { arbi } = await
|
|
3594
|
+
const { arbi } = await sdk.performPasswordLogin(config, email, pw, store);
|
|
3595
|
+
clearChatSession();
|
|
3585
3596
|
const { data: workspaces2 } = await arbi.fetch.GET("/v1/user/workspaces");
|
|
3586
3597
|
const wsList = workspaces2 || [];
|
|
3587
|
-
|
|
3588
|
-
if (
|
|
3589
|
-
console.log("No workspaces found.");
|
|
3598
|
+
const memberWorkspaces = wsList.filter((ws2) => ws2.users?.some((u) => u.email === email));
|
|
3599
|
+
if (memberWorkspaces.length === 0) {
|
|
3600
|
+
console.log("No workspaces found. Create one with: arbi workspace create <name>");
|
|
3590
3601
|
return;
|
|
3591
3602
|
}
|
|
3592
3603
|
if (opts.workspace) {
|
|
3593
|
-
const ws2 =
|
|
3604
|
+
const ws2 = memberWorkspaces.find((w) => w.external_id === opts.workspace);
|
|
3594
3605
|
if (!ws2) {
|
|
3595
|
-
error(`Workspace ${opts.workspace} not found.`);
|
|
3606
|
+
error(`Workspace ${opts.workspace} not found or you don't have access.`);
|
|
3596
3607
|
process.exit(1);
|
|
3597
3608
|
}
|
|
3598
3609
|
updateConfig({ selectedWorkspaceId: ws2.external_id });
|
|
3599
3610
|
success(`Workspace: ${ws2.name} (${ref(ws2.external_id)})`);
|
|
3600
3611
|
return;
|
|
3601
3612
|
}
|
|
3602
|
-
if (
|
|
3603
|
-
updateConfig({ selectedWorkspaceId:
|
|
3604
|
-
success(
|
|
3613
|
+
if (memberWorkspaces.length === 1) {
|
|
3614
|
+
updateConfig({ selectedWorkspaceId: memberWorkspaces[0].external_id });
|
|
3615
|
+
success(
|
|
3616
|
+
`Workspace: ${memberWorkspaces[0].name} (${ref(memberWorkspaces[0].external_id)})`
|
|
3617
|
+
);
|
|
3605
3618
|
return;
|
|
3606
3619
|
}
|
|
3607
|
-
const choices =
|
|
3620
|
+
const choices = sdk.formatWorkspaceChoices(memberWorkspaces);
|
|
3608
3621
|
const selected = await promptSelect("Select workspace", choices);
|
|
3609
3622
|
updateConfig({ selectedWorkspaceId: selected });
|
|
3610
|
-
const ws =
|
|
3623
|
+
const ws = memberWorkspaces.find((w) => w.external_id === selected);
|
|
3611
3624
|
success(`Workspace: ${ws.name} (${ref(selected)})`);
|
|
3612
3625
|
dim('\nTip: Run "arbi config alias" to use A as a shortcut for "arbi ask"');
|
|
3613
3626
|
} catch (err) {
|
|
3614
|
-
error(`Login failed: ${
|
|
3627
|
+
error(`Login failed: ${sdk.getErrorMessage(err)}`);
|
|
3615
3628
|
process.exit(1);
|
|
3616
3629
|
} finally {
|
|
3617
3630
|
await checkForUpdates(getConfig()?.autoUpdate);
|
|
@@ -3646,7 +3659,7 @@ function registerRegisterCommand(program2) {
|
|
|
3646
3659
|
}
|
|
3647
3660
|
async function smartRegister(config, opts) {
|
|
3648
3661
|
const email = opts.email || process.env.ARBI_EMAIL || await promptInput("Email");
|
|
3649
|
-
const arbi =
|
|
3662
|
+
const arbi = client.createArbiClient({
|
|
3650
3663
|
baseUrl: config.baseUrl,
|
|
3651
3664
|
deploymentDomain: config.deploymentDomain,
|
|
3652
3665
|
credentials: "omit"
|
|
@@ -3701,7 +3714,7 @@ async function smartRegister(config, opts) {
|
|
|
3701
3714
|
success(`
|
|
3702
3715
|
Registered successfully as ${email}`);
|
|
3703
3716
|
} catch (err) {
|
|
3704
|
-
error(`Registration failed: ${
|
|
3717
|
+
error(`Registration failed: ${sdk.getErrorMessage(err)}`);
|
|
3705
3718
|
process.exit(1);
|
|
3706
3719
|
}
|
|
3707
3720
|
const allFlagsProvided = !!(opts.email || process.env.ARBI_EMAIL) && !!(opts.password || process.env.ARBI_PASSWORD) && !!opts.verificationCode;
|
|
@@ -3722,7 +3735,7 @@ async function nonInteractiveRegister(config, opts) {
|
|
|
3722
3735
|
error("Password required. Use --password <password> or set ARBI_PASSWORD");
|
|
3723
3736
|
process.exit(1);
|
|
3724
3737
|
}
|
|
3725
|
-
const arbi =
|
|
3738
|
+
const arbi = client.createArbiClient({
|
|
3726
3739
|
baseUrl: config.baseUrl,
|
|
3727
3740
|
deploymentDomain: config.deploymentDomain,
|
|
3728
3741
|
credentials: "omit"
|
|
@@ -3757,35 +3770,37 @@ async function nonInteractiveRegister(config, opts) {
|
|
|
3757
3770
|
});
|
|
3758
3771
|
success(`Registered: ${email}`);
|
|
3759
3772
|
} catch (err) {
|
|
3760
|
-
error(`Registration failed: ${
|
|
3773
|
+
error(`Registration failed: ${sdk.getErrorMessage(err)}`);
|
|
3761
3774
|
process.exit(1);
|
|
3762
3775
|
}
|
|
3776
|
+
await loginAfterRegister(config, email, password2);
|
|
3763
3777
|
}
|
|
3764
3778
|
async function loginAfterRegister(config, email, password2) {
|
|
3765
3779
|
try {
|
|
3766
|
-
const { arbi } = await
|
|
3780
|
+
const { arbi } = await sdk.performPasswordLogin(config, email, password2, store);
|
|
3767
3781
|
success(`Logged in as ${email}`);
|
|
3768
3782
|
const { data: workspaces2 } = await arbi.fetch.GET("/v1/user/workspaces");
|
|
3769
3783
|
const wsList = workspaces2 || [];
|
|
3770
|
-
|
|
3784
|
+
const memberWorkspaces = wsList.filter((ws2) => ws2.users?.some((u) => u.email === email));
|
|
3785
|
+
if (memberWorkspaces.length === 0) {
|
|
3771
3786
|
console.log("Creating your first workspace...");
|
|
3772
|
-
const ws2 = await
|
|
3787
|
+
const ws2 = await sdk.workspaces.createWorkspace(arbi, "My First Workspace");
|
|
3773
3788
|
updateConfig({ selectedWorkspaceId: ws2.external_id });
|
|
3774
3789
|
success(`Workspace: ${ws2.name} (${ref(ws2.external_id)})`);
|
|
3775
3790
|
return;
|
|
3776
3791
|
}
|
|
3777
|
-
if (
|
|
3778
|
-
updateConfig({ selectedWorkspaceId:
|
|
3779
|
-
success(`Workspace: ${
|
|
3792
|
+
if (memberWorkspaces.length === 1) {
|
|
3793
|
+
updateConfig({ selectedWorkspaceId: memberWorkspaces[0].external_id });
|
|
3794
|
+
success(`Workspace: ${memberWorkspaces[0].name} (${ref(memberWorkspaces[0].external_id)})`);
|
|
3780
3795
|
return;
|
|
3781
3796
|
}
|
|
3782
|
-
const choices =
|
|
3797
|
+
const choices = sdk.formatWorkspaceChoices(memberWorkspaces);
|
|
3783
3798
|
const selected = await promptSelect("Select workspace", choices);
|
|
3784
3799
|
updateConfig({ selectedWorkspaceId: selected });
|
|
3785
|
-
const ws =
|
|
3800
|
+
const ws = memberWorkspaces.find((w) => w.external_id === selected);
|
|
3786
3801
|
success(`Workspace: ${ws.name} (${ref(selected)})`);
|
|
3787
3802
|
} catch (err) {
|
|
3788
|
-
error(`Login failed: ${
|
|
3803
|
+
error(`Login failed: ${sdk.getErrorMessage(err)}`);
|
|
3789
3804
|
error("You can log in later with: arbi login");
|
|
3790
3805
|
}
|
|
3791
3806
|
}
|
|
@@ -3794,6 +3809,7 @@ async function loginAfterRegister(config, email, password2) {
|
|
|
3794
3809
|
function registerLogoutCommand(program2) {
|
|
3795
3810
|
program2.command("logout").description("Log out of ARBI").action(() => {
|
|
3796
3811
|
deleteCredentials();
|
|
3812
|
+
clearChatSession();
|
|
3797
3813
|
updateConfig({ selectedWorkspaceId: void 0 });
|
|
3798
3814
|
success("Logged out.");
|
|
3799
3815
|
});
|
|
@@ -3834,11 +3850,11 @@ function colorize(level, text) {
|
|
|
3834
3850
|
async function startBackgroundNotifications(baseUrl, accessToken) {
|
|
3835
3851
|
if (activeConnection) return;
|
|
3836
3852
|
try {
|
|
3837
|
-
activeConnection = await
|
|
3853
|
+
activeConnection = await sdk.connectWithReconnect({
|
|
3838
3854
|
baseUrl,
|
|
3839
3855
|
accessToken,
|
|
3840
3856
|
onMessage: (msg) => {
|
|
3841
|
-
const { text, level } =
|
|
3857
|
+
const { text, level } = sdk.formatWsMessage(msg);
|
|
3842
3858
|
process.stderr.write(`
|
|
3843
3859
|
${colorize(level, `[${timestamp()}] ${text}`)}
|
|
3844
3860
|
`);
|
|
@@ -3878,13 +3894,25 @@ process.on("SIGINT", () => {
|
|
|
3878
3894
|
});
|
|
3879
3895
|
|
|
3880
3896
|
// src/helpers.ts
|
|
3897
|
+
function formatCliError(err) {
|
|
3898
|
+
if (err instanceof sdk.ArbiApiError && err.apiError && typeof err.apiError === "object") {
|
|
3899
|
+
const base = err.message;
|
|
3900
|
+
const apiErr = err.apiError;
|
|
3901
|
+
const detail = apiErr.detail ?? apiErr.message ?? apiErr.error;
|
|
3902
|
+
if (typeof detail === "string" && detail && !base.includes(detail)) {
|
|
3903
|
+
return `${base} \u2014 ${detail}`;
|
|
3904
|
+
}
|
|
3905
|
+
return base;
|
|
3906
|
+
}
|
|
3907
|
+
return sdk.getErrorMessage(err);
|
|
3908
|
+
}
|
|
3881
3909
|
function runAction(fn) {
|
|
3882
3910
|
return async () => {
|
|
3883
3911
|
try {
|
|
3884
3912
|
await fn();
|
|
3885
3913
|
process.exit(0);
|
|
3886
3914
|
} catch (err) {
|
|
3887
|
-
error(`Error: ${
|
|
3915
|
+
error(`Error: ${formatCliError(err)}`);
|
|
3888
3916
|
hintUpdateOnError();
|
|
3889
3917
|
process.exit(1);
|
|
3890
3918
|
}
|
|
@@ -3892,9 +3920,9 @@ function runAction(fn) {
|
|
|
3892
3920
|
}
|
|
3893
3921
|
async function resolveAuth() {
|
|
3894
3922
|
try {
|
|
3895
|
-
return await
|
|
3923
|
+
return await sdk.resolveAuth(store);
|
|
3896
3924
|
} catch (err) {
|
|
3897
|
-
if (err instanceof
|
|
3925
|
+
if (err instanceof sdk.ArbiError) {
|
|
3898
3926
|
error(err.message);
|
|
3899
3927
|
process.exit(1);
|
|
3900
3928
|
}
|
|
@@ -3903,14 +3931,14 @@ async function resolveAuth() {
|
|
|
3903
3931
|
}
|
|
3904
3932
|
async function resolveWorkspace(workspaceOpt) {
|
|
3905
3933
|
try {
|
|
3906
|
-
const ctx = await
|
|
3934
|
+
const ctx = await sdk.resolveWorkspace(store, workspaceOpt);
|
|
3907
3935
|
if (getConfig()?.notifications) {
|
|
3908
3936
|
startBackgroundNotifications(ctx.config.baseUrl, ctx.accessToken).catch(() => {
|
|
3909
3937
|
});
|
|
3910
3938
|
}
|
|
3911
3939
|
return ctx;
|
|
3912
3940
|
} catch (err) {
|
|
3913
|
-
if (err instanceof
|
|
3941
|
+
if (err instanceof sdk.ArbiError) {
|
|
3914
3942
|
error(err.message);
|
|
3915
3943
|
process.exit(1);
|
|
3916
3944
|
}
|
|
@@ -3942,7 +3970,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3942
3970
|
program2.command("workspaces").description("List workspaces").action(
|
|
3943
3971
|
runAction(async () => {
|
|
3944
3972
|
const { arbi } = await resolveAuth();
|
|
3945
|
-
const data = await
|
|
3973
|
+
const data = await sdk.workspaces.listWorkspaces(arbi);
|
|
3946
3974
|
if (data.length === 0) {
|
|
3947
3975
|
console.log("No workspaces found.");
|
|
3948
3976
|
return;
|
|
@@ -3970,7 +3998,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3970
3998
|
workspace.command("select [id]").description("Select active workspace (interactive picker if no ID given)").action(
|
|
3971
3999
|
(id) => runAction(async () => {
|
|
3972
4000
|
const { arbi } = await resolveAuth();
|
|
3973
|
-
const data = await
|
|
4001
|
+
const data = await sdk.workspaces.listWorkspaces(arbi);
|
|
3974
4002
|
if (data.length === 0) {
|
|
3975
4003
|
console.log("No workspaces found.");
|
|
3976
4004
|
return;
|
|
@@ -3986,10 +4014,11 @@ function registerWorkspacesCommand(program2) {
|
|
|
3986
4014
|
}
|
|
3987
4015
|
selectedId = id;
|
|
3988
4016
|
} else {
|
|
3989
|
-
const choices =
|
|
4017
|
+
const choices = sdk.formatWorkspaceChoices(data);
|
|
3990
4018
|
selectedId = await promptSelect("Select workspace", choices);
|
|
3991
4019
|
}
|
|
3992
4020
|
updateConfig({ selectedWorkspaceId: selectedId });
|
|
4021
|
+
clearChatSession();
|
|
3993
4022
|
const ws = data.find((w) => w.external_id === selectedId);
|
|
3994
4023
|
success(`Selected: ${ws.name} (${ref(selectedId)})`);
|
|
3995
4024
|
})()
|
|
@@ -3997,7 +4026,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3997
4026
|
workspace.command("create <name>").description("Create a new workspace").option("-d, --description <text>", "Workspace description").option("--public", "Make workspace public", false).action(
|
|
3998
4027
|
(name, opts) => runAction(async () => {
|
|
3999
4028
|
const { arbi } = await resolveAuth();
|
|
4000
|
-
const data = await
|
|
4029
|
+
const data = await sdk.workspaces.createWorkspace(
|
|
4001
4030
|
arbi,
|
|
4002
4031
|
name,
|
|
4003
4032
|
opts.description,
|
|
@@ -4014,7 +4043,11 @@ function registerWorkspacesCommand(program2) {
|
|
|
4014
4043
|
error("No workspace ID given and no workspace selected. Run: arbi workspace select");
|
|
4015
4044
|
process.exit(1);
|
|
4016
4045
|
}
|
|
4017
|
-
await
|
|
4046
|
+
await sdk.workspaces.deleteWorkspaces(arbi, [targetId]);
|
|
4047
|
+
const session = getChatSession();
|
|
4048
|
+
if (session.workspaceId === targetId) {
|
|
4049
|
+
clearChatSession();
|
|
4050
|
+
}
|
|
4018
4051
|
success(`Deleted workspace ${targetId}`);
|
|
4019
4052
|
})()
|
|
4020
4053
|
);
|
|
@@ -4022,14 +4055,14 @@ function registerWorkspacesCommand(program2) {
|
|
|
4022
4055
|
(id, json) => runAction(async () => {
|
|
4023
4056
|
const body = parseJsonArg(json, `arbi workspace update wrk-123 '{"name": "New Name"}'`);
|
|
4024
4057
|
const { arbi } = await resolveWorkspace(id);
|
|
4025
|
-
const data = await
|
|
4058
|
+
const data = await sdk.workspaces.updateWorkspace(arbi, body);
|
|
4026
4059
|
success(`Updated: ${data.name} (${ref(data.external_id)})`);
|
|
4027
4060
|
})()
|
|
4028
4061
|
);
|
|
4029
4062
|
workspace.command("users").description("List users in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4030
4063
|
(opts) => runAction(async () => {
|
|
4031
4064
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4032
|
-
const data = await
|
|
4065
|
+
const data = await sdk.workspaces.listWorkspaceUsers(arbi);
|
|
4033
4066
|
if (data.length === 0) {
|
|
4034
4067
|
console.log("No users found.");
|
|
4035
4068
|
return;
|
|
@@ -4066,21 +4099,21 @@ function registerWorkspacesCommand(program2) {
|
|
|
4066
4099
|
(emails, opts) => runAction(async () => {
|
|
4067
4100
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4068
4101
|
const role = opts.role ?? "collaborator";
|
|
4069
|
-
const data = await
|
|
4102
|
+
const data = await sdk.workspaces.addWorkspaceUsers(arbi, emails, role);
|
|
4070
4103
|
for (const u of data) success(`Added: ${u.user.email} as ${u.role}`);
|
|
4071
4104
|
})()
|
|
4072
4105
|
);
|
|
4073
4106
|
workspace.command("remove-user <user-ids...>").description("Remove users from the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4074
4107
|
(userIds, opts) => runAction(async () => {
|
|
4075
4108
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4076
|
-
await
|
|
4109
|
+
await sdk.workspaces.removeWorkspaceUsers(arbi, userIds);
|
|
4077
4110
|
success(`Removed ${userIds.length} user(s).`);
|
|
4078
4111
|
})()
|
|
4079
4112
|
);
|
|
4080
4113
|
workspace.command("set-role <role> <user-ids...>").description("Update user roles (owner, collaborator, guest)").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4081
4114
|
(role, userIds, opts) => runAction(async () => {
|
|
4082
4115
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4083
|
-
const data = await
|
|
4116
|
+
const data = await sdk.workspaces.setUserRole(
|
|
4084
4117
|
arbi,
|
|
4085
4118
|
userIds,
|
|
4086
4119
|
role
|
|
@@ -4092,19 +4125,19 @@ function registerWorkspacesCommand(program2) {
|
|
|
4092
4125
|
(targetId, docIds, opts) => runAction(async () => {
|
|
4093
4126
|
const { arbi, loginResult } = await resolveWorkspace(opts.workspace);
|
|
4094
4127
|
const signingPrivateKeyBase64 = arbi.crypto.bytesToBase64(loginResult.signingPrivateKey);
|
|
4095
|
-
const wsList = await
|
|
4128
|
+
const wsList = await sdk.workspaces.listWorkspaces(arbi);
|
|
4096
4129
|
const targetWs = wsList.find((w) => w.external_id === targetId);
|
|
4097
4130
|
if (!targetWs || !targetWs.wrapped_key) {
|
|
4098
4131
|
error(`Target workspace ${targetId} not found or has no encryption key`);
|
|
4099
4132
|
process.exit(1);
|
|
4100
4133
|
}
|
|
4101
|
-
const targetKey = await
|
|
4134
|
+
const targetKey = await sdk.generateEncryptedWorkspaceKey(
|
|
4102
4135
|
arbi,
|
|
4103
4136
|
targetWs.wrapped_key,
|
|
4104
4137
|
loginResult.serverSessionKey,
|
|
4105
4138
|
signingPrivateKeyBase64
|
|
4106
4139
|
);
|
|
4107
|
-
const data = await
|
|
4140
|
+
const data = await sdk.workspaces.copyDocuments(arbi, targetId, docIds, targetKey);
|
|
4108
4141
|
success(`${data.detail} (${data.documents_copied} document(s) copied)`);
|
|
4109
4142
|
})()
|
|
4110
4143
|
);
|
|
@@ -4128,7 +4161,7 @@ function statusSymbol(status2) {
|
|
|
4128
4161
|
}
|
|
4129
4162
|
}
|
|
4130
4163
|
async function fetchDocChoices(arbi, workspaceId) {
|
|
4131
|
-
const data = await
|
|
4164
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4132
4165
|
if (data.length === 0) {
|
|
4133
4166
|
console.log("No documents found.");
|
|
4134
4167
|
process.exit(0);
|
|
@@ -4143,7 +4176,7 @@ function registerDocsCommand(program2) {
|
|
|
4143
4176
|
program2.command("docs").description("List documents in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4144
4177
|
(opts) => runAction(async () => {
|
|
4145
4178
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4146
|
-
const data = await
|
|
4179
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4147
4180
|
if (data.length === 0) {
|
|
4148
4181
|
console.log("No documents found.");
|
|
4149
4182
|
return;
|
|
@@ -4192,8 +4225,25 @@ function registerDocsCommand(program2) {
|
|
|
4192
4225
|
if (selected.length === 0) return;
|
|
4193
4226
|
docIds = selected;
|
|
4194
4227
|
}
|
|
4195
|
-
const data = await
|
|
4228
|
+
const data = await sdk.documents.getDocuments(arbi, docIds);
|
|
4196
4229
|
console.log(JSON.stringify(data, null, 2));
|
|
4230
|
+
const docs = Array.isArray(data) ? data : [data];
|
|
4231
|
+
for (const d of docs) {
|
|
4232
|
+
const raw = d;
|
|
4233
|
+
if (raw.status === "failed") {
|
|
4234
|
+
const reason = raw.error_reason || raw.status_details || raw.error || null;
|
|
4235
|
+
const docId = raw.external_id;
|
|
4236
|
+
if (reason) {
|
|
4237
|
+
console.error(chalk__default.default.red(`
|
|
4238
|
+
\u26A0 ${docId} processing failed: ${reason}`));
|
|
4239
|
+
} else {
|
|
4240
|
+
console.error(
|
|
4241
|
+
chalk__default.default.red(`
|
|
4242
|
+
\u26A0 ${docId} processing failed (no error details available)`)
|
|
4243
|
+
);
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
}
|
|
4197
4247
|
})()
|
|
4198
4248
|
);
|
|
4199
4249
|
doc.command("delete [ids...]").description("Delete documents (interactive picker if no IDs given)").action(
|
|
@@ -4206,7 +4256,7 @@ function registerDocsCommand(program2) {
|
|
|
4206
4256
|
if (selected.length === 0) return;
|
|
4207
4257
|
docIds = selected;
|
|
4208
4258
|
}
|
|
4209
|
-
await
|
|
4259
|
+
await sdk.documents.deleteDocuments(arbi, docIds);
|
|
4210
4260
|
success(`Deleted ${docIds.length} document(s).`);
|
|
4211
4261
|
})()
|
|
4212
4262
|
);
|
|
@@ -4216,7 +4266,7 @@ function registerDocsCommand(program2) {
|
|
|
4216
4266
|
const parsed = parseJsonArg(json, `arbi doc update '[{"external_id": "doc-123", "shared": true}]'`);
|
|
4217
4267
|
const docs = Array.isArray(parsed) ? parsed : parsed.documents;
|
|
4218
4268
|
const { arbi } = await resolveWorkspace();
|
|
4219
|
-
const data = await
|
|
4269
|
+
const data = await sdk.documents.updateDocuments(arbi, docs);
|
|
4220
4270
|
success(`Updated ${data.length} document(s).`);
|
|
4221
4271
|
} else {
|
|
4222
4272
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
@@ -4240,7 +4290,7 @@ function registerDocsCommand(program2) {
|
|
|
4240
4290
|
} else {
|
|
4241
4291
|
value = await promptInput(`${field.charAt(0).toUpperCase() + field.slice(1)}`);
|
|
4242
4292
|
}
|
|
4243
|
-
const data = await
|
|
4293
|
+
const data = await sdk.documents.updateDocuments(arbi, [
|
|
4244
4294
|
{ external_id: docId, [field]: value }
|
|
4245
4295
|
]);
|
|
4246
4296
|
success(`Updated ${data.length} document(s).`);
|
|
@@ -4250,35 +4300,26 @@ function registerDocsCommand(program2) {
|
|
|
4250
4300
|
doc.command("upload-url <urls...>").description("Upload documents from URLs").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").option("--shared", "Make documents shared", false).action(
|
|
4251
4301
|
(urls, opts) => runAction(async () => {
|
|
4252
4302
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4253
|
-
const data = await
|
|
4303
|
+
const data = await sdk.documents.uploadUrl(arbi, urls, workspaceId, opts.shared ?? false);
|
|
4254
4304
|
success(`Uploaded: ${data.doc_ext_ids.join(", ")}`);
|
|
4255
4305
|
if (data.duplicates && data.duplicates.length > 0) {
|
|
4256
4306
|
warn(`Duplicates: ${data.duplicates.join(", ")}`);
|
|
4257
4307
|
}
|
|
4258
4308
|
})()
|
|
4259
4309
|
);
|
|
4260
|
-
doc.command("parsed
|
|
4310
|
+
doc.command("parsed <doc-id> [stage]").description("Get parsed document content (stage: marker, subchunk, final; default: final)").action(
|
|
4261
4311
|
(docId, stage) => runAction(async () => {
|
|
4262
|
-
const {
|
|
4263
|
-
if (!docId) {
|
|
4264
|
-
const choices = await fetchDocChoices(arbi, workspaceId);
|
|
4265
|
-
docId = await promptSearch("Select document", choices);
|
|
4266
|
-
}
|
|
4312
|
+
const { accessToken, workspaceKeyHeader, config } = await resolveWorkspace();
|
|
4267
4313
|
const validStages = ["marker", "subchunk", "final"];
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
{ name: "Subchunk", value: "subchunk" },
|
|
4272
|
-
{ name: "Marker (raw)", value: "marker" }
|
|
4273
|
-
]);
|
|
4274
|
-
} else if (!validStages.includes(stage)) {
|
|
4275
|
-
error(`Invalid stage: ${stage}. Must be one of: ${validStages.join(", ")}`);
|
|
4314
|
+
const selectedStage = stage ?? "final";
|
|
4315
|
+
if (!validStages.includes(selectedStage)) {
|
|
4316
|
+
error(`Invalid stage: ${selectedStage}. Must be one of: ${validStages.join(", ")}`);
|
|
4276
4317
|
process.exit(1);
|
|
4277
4318
|
}
|
|
4278
|
-
const data = await
|
|
4319
|
+
const data = await sdk.documents.getParsedContent(
|
|
4279
4320
|
{ baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
|
|
4280
4321
|
docId,
|
|
4281
|
-
|
|
4322
|
+
selectedStage
|
|
4282
4323
|
);
|
|
4283
4324
|
console.log(JSON.stringify(data, null, 2));
|
|
4284
4325
|
})()
|
|
@@ -4299,41 +4340,71 @@ function registerUploadCommand(program2) {
|
|
|
4299
4340
|
const uploadedDocs = /* @__PURE__ */ new Map();
|
|
4300
4341
|
const auth = { baseUrl: config.baseUrl, accessToken, workspaceKeyHeader };
|
|
4301
4342
|
for (const filePath of files) {
|
|
4302
|
-
const result = await
|
|
4343
|
+
const result = await sdk.documents.uploadLocalFile(auth, workspaceId, filePath);
|
|
4303
4344
|
success(`Uploaded: ${result.fileName} (${result.doc_ext_ids.join(", ")})`);
|
|
4304
4345
|
if (result.duplicates && result.duplicates.length > 0) {
|
|
4305
4346
|
warn(` Duplicates: ${result.duplicates.join(", ")}`);
|
|
4306
4347
|
}
|
|
4307
4348
|
for (const id of result.doc_ext_ids) uploadedDocs.set(id, result.fileName);
|
|
4308
4349
|
}
|
|
4309
|
-
|
|
4350
|
+
const isInteractive = process.stdout.isTTY === true;
|
|
4351
|
+
const shouldWatch = opts.watch === true || files.length === 1 && isInteractive;
|
|
4352
|
+
if (shouldWatch && uploadedDocs.size > 0) {
|
|
4310
4353
|
const pending = new Set(uploadedDocs.keys());
|
|
4354
|
+
const failed = /* @__PURE__ */ new Map();
|
|
4311
4355
|
console.log(`
|
|
4312
4356
|
Watching ${pending.size} document(s)...`);
|
|
4313
|
-
|
|
4357
|
+
let onDone;
|
|
4358
|
+
const done = new Promise((r) => {
|
|
4359
|
+
onDone = r;
|
|
4360
|
+
});
|
|
4361
|
+
const conn = await sdk.connectWebSocket({
|
|
4314
4362
|
baseUrl: config.baseUrl,
|
|
4315
4363
|
accessToken,
|
|
4316
4364
|
onMessage: (msg) => {
|
|
4317
|
-
if (
|
|
4365
|
+
if (client.isMessageType(msg, "task_update")) {
|
|
4318
4366
|
if (!pending.has(msg.doc_ext_id)) return;
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
)
|
|
4322
|
-
|
|
4367
|
+
const docName = uploadedDocs.get(msg.doc_ext_id) || msg.file_name;
|
|
4368
|
+
const extra = msg;
|
|
4369
|
+
if (msg.status === "failed") {
|
|
4370
|
+
const reason = extra.error_reason || extra.status_details || extra.detail || "Unknown error";
|
|
4371
|
+
failed.set(msg.doc_ext_id, reason);
|
|
4372
|
+
console.log(` ${docName}: ${status(msg.status)} \u2014 ${reason}`);
|
|
4323
4373
|
pending.delete(msg.doc_ext_id);
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4374
|
+
} else {
|
|
4375
|
+
console.log(` ${docName}: ${status(msg.status)} (${msg.progress}%)`);
|
|
4376
|
+
if (msg.status === "completed") {
|
|
4377
|
+
pending.delete(msg.doc_ext_id);
|
|
4327
4378
|
}
|
|
4328
4379
|
}
|
|
4380
|
+
if (pending.size === 0) {
|
|
4381
|
+
conn.close();
|
|
4382
|
+
}
|
|
4329
4383
|
}
|
|
4330
4384
|
},
|
|
4331
4385
|
onClose: () => {
|
|
4332
|
-
if (
|
|
4386
|
+
if (failed.size > 0) {
|
|
4387
|
+
error(`
|
|
4388
|
+
${failed.size} document(s) failed to process:`);
|
|
4389
|
+
for (const [docId, reason] of failed) {
|
|
4390
|
+
error(` ${uploadedDocs.get(docId) || docId}: ${reason}`);
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
if (pending.size > 0) {
|
|
4333
4394
|
warn(`
|
|
4334
4395
|
Connection closed. ${pending.size} document(s) still processing.`);
|
|
4396
|
+
dim('Run "arbi watch" to continue monitoring, or "arbi docs" to check status.');
|
|
4397
|
+
} else if (failed.size === 0 && uploadedDocs.size > 0) {
|
|
4398
|
+
success("\nAll documents processed successfully.");
|
|
4399
|
+
}
|
|
4400
|
+
onDone();
|
|
4335
4401
|
}
|
|
4336
4402
|
});
|
|
4403
|
+
await done;
|
|
4404
|
+
} else if (uploadedDocs.size > 0 && !shouldWatch) {
|
|
4405
|
+
dim(
|
|
4406
|
+
'Tip: Use -W/--watch to monitor processing progress, or run "arbi docs" to check status.'
|
|
4407
|
+
);
|
|
4337
4408
|
}
|
|
4338
4409
|
})()
|
|
4339
4410
|
);
|
|
@@ -4343,7 +4414,7 @@ function registerDownloadCommand(program2) {
|
|
|
4343
4414
|
(docId, opts) => runAction(async () => {
|
|
4344
4415
|
const { arbi, config, accessToken, workspaceKeyHeader, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4345
4416
|
if (!docId) {
|
|
4346
|
-
const data = await
|
|
4417
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4347
4418
|
if (data.length === 0) {
|
|
4348
4419
|
console.log("No documents found.");
|
|
4349
4420
|
return;
|
|
@@ -4355,7 +4426,7 @@ function registerDownloadCommand(program2) {
|
|
|
4355
4426
|
}));
|
|
4356
4427
|
docId = await promptSearch("Select document to download", choices);
|
|
4357
4428
|
}
|
|
4358
|
-
const res = await
|
|
4429
|
+
const res = await sdk.documents.downloadDocument(
|
|
4359
4430
|
{ baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
|
|
4360
4431
|
docId
|
|
4361
4432
|
);
|
|
@@ -4380,27 +4451,49 @@ function registerAskCommand(program2) {
|
|
|
4380
4451
|
const question = words.join(" ");
|
|
4381
4452
|
const { arbi, accessToken, workspaceKeyHeader, workspaceId, config } = await resolveWorkspace(opts.workspace);
|
|
4382
4453
|
const session = getChatSession();
|
|
4454
|
+
const workspaceChanged = session.lastMessageExtId && session.workspaceId && session.workspaceId !== workspaceId;
|
|
4455
|
+
let previousResponseId = null;
|
|
4383
4456
|
if (opts.new) {
|
|
4384
4457
|
clearChatSession();
|
|
4385
|
-
|
|
4458
|
+
} else if (workspaceChanged) {
|
|
4459
|
+
clearChatSession();
|
|
4460
|
+
} else if (session.lastMessageExtId) {
|
|
4461
|
+
previousResponseId = session.lastMessageExtId;
|
|
4386
4462
|
}
|
|
4387
|
-
const docs = await
|
|
4463
|
+
const docs = await sdk.documents.listDocuments(arbi);
|
|
4388
4464
|
const docIds = docs.map((d) => d.external_id);
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4465
|
+
let res;
|
|
4466
|
+
try {
|
|
4467
|
+
res = await sdk.assistant.queryAssistant({
|
|
4468
|
+
baseUrl: config.baseUrl,
|
|
4469
|
+
accessToken,
|
|
4470
|
+
workspaceKeyHeader,
|
|
4471
|
+
workspaceId,
|
|
4472
|
+
question,
|
|
4473
|
+
docIds,
|
|
4474
|
+
previousResponseId,
|
|
4475
|
+
model: opts.config
|
|
4476
|
+
});
|
|
4477
|
+
} catch (err) {
|
|
4478
|
+
const isStaleParent = previousResponseId && err instanceof Error && (err.message.includes("404") || err.message.includes("Parent message not found"));
|
|
4479
|
+
if (!isStaleParent) throw err;
|
|
4480
|
+
clearChatSession();
|
|
4481
|
+
res = await sdk.assistant.queryAssistant({
|
|
4482
|
+
baseUrl: config.baseUrl,
|
|
4483
|
+
accessToken,
|
|
4484
|
+
workspaceKeyHeader,
|
|
4485
|
+
workspaceId,
|
|
4486
|
+
question,
|
|
4487
|
+
docIds,
|
|
4488
|
+
previousResponseId: null,
|
|
4489
|
+
model: opts.config
|
|
4490
|
+
});
|
|
4491
|
+
}
|
|
4492
|
+
const result = await sdk.streamSSE(res, {
|
|
4400
4493
|
onToken: (content) => process.stdout.write(content),
|
|
4401
4494
|
onAgentStep: (data) => {
|
|
4402
4495
|
if (opts.verbose) {
|
|
4403
|
-
const focus = data.focus || data.
|
|
4496
|
+
const focus = data.focus || data.step || "";
|
|
4404
4497
|
console.error(chalk__default.default.dim(`
|
|
4405
4498
|
[agent] ${focus}`));
|
|
4406
4499
|
}
|
|
@@ -4411,7 +4504,8 @@ Error: ${message}`))
|
|
|
4411
4504
|
process.stdout.write("\n");
|
|
4412
4505
|
if (result.assistantMessageExtId) {
|
|
4413
4506
|
const updates = {
|
|
4414
|
-
lastMessageExtId: result.assistantMessageExtId
|
|
4507
|
+
lastMessageExtId: result.assistantMessageExtId,
|
|
4508
|
+
workspaceId
|
|
4415
4509
|
};
|
|
4416
4510
|
const conversationExtId = result.userMessage?.conversation_ext_id ?? result.metadata?.conversation_ext_id;
|
|
4417
4511
|
if (conversationExtId) {
|
|
@@ -4433,11 +4527,15 @@ function registerWatchCommand(program2) {
|
|
|
4433
4527
|
(opts) => runAction(async () => {
|
|
4434
4528
|
const { config, accessToken, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4435
4529
|
console.log(`Watching workspace ${workspaceId}... (Ctrl+C to stop)`);
|
|
4436
|
-
|
|
4530
|
+
let onDone;
|
|
4531
|
+
const done = new Promise((r) => {
|
|
4532
|
+
onDone = r;
|
|
4533
|
+
});
|
|
4534
|
+
await sdk.connectWebSocket({
|
|
4437
4535
|
baseUrl: config.baseUrl,
|
|
4438
4536
|
accessToken,
|
|
4439
4537
|
onMessage: (msg) => {
|
|
4440
|
-
const { text, level } =
|
|
4538
|
+
const { text, level } = sdk.formatWsMessage(msg);
|
|
4441
4539
|
console.log(colorize2(level, text));
|
|
4442
4540
|
},
|
|
4443
4541
|
onClose: (code, reason) => {
|
|
@@ -4445,8 +4543,10 @@ function registerWatchCommand(program2) {
|
|
|
4445
4543
|
chalk__default.default.yellow(`
|
|
4446
4544
|
Connection closed (code ${code}${reason ? ": " + reason : ""})`)
|
|
4447
4545
|
);
|
|
4546
|
+
onDone();
|
|
4448
4547
|
}
|
|
4449
4548
|
});
|
|
4549
|
+
await done;
|
|
4450
4550
|
})()
|
|
4451
4551
|
);
|
|
4452
4552
|
}
|
|
@@ -4455,7 +4555,7 @@ function registerContactsCommand(program2) {
|
|
|
4455
4555
|
contacts.command("list").description("List all contacts").action(
|
|
4456
4556
|
runAction(async () => {
|
|
4457
4557
|
const { arbi } = await resolveAuth();
|
|
4458
|
-
const data = await
|
|
4558
|
+
const data = await sdk.contacts.listContacts(arbi);
|
|
4459
4559
|
if (data.length === 0) {
|
|
4460
4560
|
console.log("No contacts found.");
|
|
4461
4561
|
return;
|
|
@@ -4466,7 +4566,7 @@ function registerContactsCommand(program2) {
|
|
|
4466
4566
|
{
|
|
4467
4567
|
header: "NAME",
|
|
4468
4568
|
width: 20,
|
|
4469
|
-
value: (r) =>
|
|
4569
|
+
value: (r) => sdk.formatUserName(r.user)
|
|
4470
4570
|
},
|
|
4471
4571
|
{ header: "EMAIL", width: 30, value: (r) => r.email },
|
|
4472
4572
|
{ header: "STATUS", width: 18, value: (r) => r.status }
|
|
@@ -4483,7 +4583,7 @@ function registerContactsCommand(program2) {
|
|
|
4483
4583
|
emails = input2.split(",").map((e) => e.trim()).filter(Boolean);
|
|
4484
4584
|
if (emails.length === 0) return;
|
|
4485
4585
|
}
|
|
4486
|
-
const data = await
|
|
4586
|
+
const data = await sdk.contacts.addContacts(arbi, emails);
|
|
4487
4587
|
for (const c of data) {
|
|
4488
4588
|
success(`Added: ${c.email} (${c.external_id}) \u2014 ${c.status}`);
|
|
4489
4589
|
}
|
|
@@ -4494,7 +4594,7 @@ function registerContactsCommand(program2) {
|
|
|
4494
4594
|
const { arbi } = await resolveAuth();
|
|
4495
4595
|
let contactIds = ids && ids.length > 0 ? ids : void 0;
|
|
4496
4596
|
if (!contactIds) {
|
|
4497
|
-
const data = await
|
|
4597
|
+
const data = await sdk.contacts.listContacts(arbi);
|
|
4498
4598
|
if (data.length === 0) {
|
|
4499
4599
|
console.log("No contacts found.");
|
|
4500
4600
|
return;
|
|
@@ -4502,7 +4602,7 @@ function registerContactsCommand(program2) {
|
|
|
4502
4602
|
contactIds = await promptCheckbox(
|
|
4503
4603
|
"Select contacts to remove",
|
|
4504
4604
|
data.map((c) => {
|
|
4505
|
-
const name =
|
|
4605
|
+
const name = sdk.formatUserName(c.user);
|
|
4506
4606
|
return {
|
|
4507
4607
|
name: name ? `${name} (${c.email})` : c.email,
|
|
4508
4608
|
value: c.external_id
|
|
@@ -4511,7 +4611,7 @@ function registerContactsCommand(program2) {
|
|
|
4511
4611
|
);
|
|
4512
4612
|
if (contactIds.length === 0) return;
|
|
4513
4613
|
}
|
|
4514
|
-
await
|
|
4614
|
+
await sdk.contacts.removeContacts(arbi, contactIds);
|
|
4515
4615
|
success(`Removed ${contactIds.length} contact(s).`);
|
|
4516
4616
|
})()
|
|
4517
4617
|
);
|
|
@@ -4524,7 +4624,7 @@ function registerDmCommand(program2) {
|
|
|
4524
4624
|
dm.command("list").description("List all DMs and notifications").action(
|
|
4525
4625
|
runAction(async () => {
|
|
4526
4626
|
const { arbi } = await resolveAuth();
|
|
4527
|
-
const data = await
|
|
4627
|
+
const data = await sdk.dm.listDMs(arbi);
|
|
4528
4628
|
if (data.length === 0) {
|
|
4529
4629
|
console.log("No messages found.");
|
|
4530
4630
|
return;
|
|
@@ -4538,7 +4638,7 @@ function registerDmCommand(program2) {
|
|
|
4538
4638
|
width: 22,
|
|
4539
4639
|
value: (r) => {
|
|
4540
4640
|
const s = r.sender;
|
|
4541
|
-
return
|
|
4641
|
+
return sdk.formatUserName(s) || s?.email || "";
|
|
4542
4642
|
}
|
|
4543
4643
|
},
|
|
4544
4644
|
{ header: "READ", width: 6, value: (r) => r.read ? "yes" : "no" },
|
|
@@ -4552,7 +4652,7 @@ function registerDmCommand(program2) {
|
|
|
4552
4652
|
(recipient, content) => runAction(async () => {
|
|
4553
4653
|
const { arbi } = await resolveAuth();
|
|
4554
4654
|
if (!recipient) {
|
|
4555
|
-
const contacts = await
|
|
4655
|
+
const contacts = await sdk.contacts.listContacts(arbi);
|
|
4556
4656
|
if (contacts.length === 0) {
|
|
4557
4657
|
error("No contacts found. Add contacts first: arbi contacts add <email>");
|
|
4558
4658
|
process.exit(1);
|
|
@@ -4561,7 +4661,7 @@ function registerDmCommand(program2) {
|
|
|
4561
4661
|
"Send to",
|
|
4562
4662
|
contacts.map((c) => {
|
|
4563
4663
|
const u = c.user;
|
|
4564
|
-
const name =
|
|
4664
|
+
const name = sdk.formatUserName(u);
|
|
4565
4665
|
return {
|
|
4566
4666
|
name: name ? `${name} (${c.email})` : c.email,
|
|
4567
4667
|
value: u?.external_id ?? c.external_id,
|
|
@@ -4575,7 +4675,7 @@ function registerDmCommand(program2) {
|
|
|
4575
4675
|
}
|
|
4576
4676
|
let recipientExtId = recipient;
|
|
4577
4677
|
if (recipient.includes("@")) {
|
|
4578
|
-
const contacts = await
|
|
4678
|
+
const contacts = await sdk.contacts.listContacts(arbi);
|
|
4579
4679
|
const match = contacts.find((c) => c.email === recipient);
|
|
4580
4680
|
if (!match) {
|
|
4581
4681
|
error(`No contact found with email: ${recipient}`);
|
|
@@ -4584,7 +4684,7 @@ function registerDmCommand(program2) {
|
|
|
4584
4684
|
}
|
|
4585
4685
|
recipientExtId = match.user?.external_id ?? match.external_id;
|
|
4586
4686
|
}
|
|
4587
|
-
const data = await
|
|
4687
|
+
const data = await sdk.dm.sendDM(arbi, [{ recipient_ext_id: recipientExtId, content }]);
|
|
4588
4688
|
for (const n of data) {
|
|
4589
4689
|
success(`Sent: ${n.external_id} \u2192 ${n.recipient.email}`);
|
|
4590
4690
|
}
|
|
@@ -4595,7 +4695,7 @@ function registerDmCommand(program2) {
|
|
|
4595
4695
|
const { arbi } = await resolveAuth();
|
|
4596
4696
|
let msgIds = ids && ids.length > 0 ? ids : void 0;
|
|
4597
4697
|
if (!msgIds) {
|
|
4598
|
-
const data2 = await
|
|
4698
|
+
const data2 = await sdk.dm.listDMs(arbi);
|
|
4599
4699
|
const unread = data2.filter((m) => !m.read);
|
|
4600
4700
|
if (unread.length === 0) {
|
|
4601
4701
|
console.log("No unread messages.");
|
|
@@ -4605,7 +4705,7 @@ function registerDmCommand(program2) {
|
|
|
4605
4705
|
"Select messages to mark as read",
|
|
4606
4706
|
unread.map((m) => {
|
|
4607
4707
|
const s = m.sender;
|
|
4608
|
-
const from =
|
|
4708
|
+
const from = sdk.formatUserName(s) || s?.email || "";
|
|
4609
4709
|
return {
|
|
4610
4710
|
name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
|
|
4611
4711
|
value: m.external_id
|
|
@@ -4614,7 +4714,7 @@ function registerDmCommand(program2) {
|
|
|
4614
4714
|
);
|
|
4615
4715
|
if (msgIds.length === 0) return;
|
|
4616
4716
|
}
|
|
4617
|
-
const data = await
|
|
4717
|
+
const data = await sdk.dm.markRead(arbi, msgIds);
|
|
4618
4718
|
success(`Marked ${data.length} message(s) as read.`);
|
|
4619
4719
|
})()
|
|
4620
4720
|
);
|
|
@@ -4623,7 +4723,7 @@ function registerDmCommand(program2) {
|
|
|
4623
4723
|
const { arbi } = await resolveAuth();
|
|
4624
4724
|
let msgIds = ids && ids.length > 0 ? ids : void 0;
|
|
4625
4725
|
if (!msgIds) {
|
|
4626
|
-
const data = await
|
|
4726
|
+
const data = await sdk.dm.listDMs(arbi);
|
|
4627
4727
|
if (data.length === 0) {
|
|
4628
4728
|
console.log("No messages found.");
|
|
4629
4729
|
return;
|
|
@@ -4632,7 +4732,7 @@ function registerDmCommand(program2) {
|
|
|
4632
4732
|
"Select messages to delete",
|
|
4633
4733
|
data.map((m) => {
|
|
4634
4734
|
const s = m.sender;
|
|
4635
|
-
const from =
|
|
4735
|
+
const from = sdk.formatUserName(s) || s?.email || "";
|
|
4636
4736
|
return {
|
|
4637
4737
|
name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
|
|
4638
4738
|
value: m.external_id
|
|
@@ -4641,7 +4741,7 @@ function registerDmCommand(program2) {
|
|
|
4641
4741
|
);
|
|
4642
4742
|
if (msgIds.length === 0) return;
|
|
4643
4743
|
}
|
|
4644
|
-
await
|
|
4744
|
+
await sdk.dm.deleteDMs(arbi, msgIds);
|
|
4645
4745
|
success(`Deleted ${msgIds.length} message(s).`);
|
|
4646
4746
|
})()
|
|
4647
4747
|
);
|
|
@@ -4650,7 +4750,7 @@ function registerDmCommand(program2) {
|
|
|
4650
4750
|
});
|
|
4651
4751
|
}
|
|
4652
4752
|
async function fetchTagChoices(arbi, workspaceId) {
|
|
4653
|
-
const data = await
|
|
4753
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4654
4754
|
if (data.length === 0) {
|
|
4655
4755
|
console.log("No tags found.");
|
|
4656
4756
|
process.exit(0);
|
|
@@ -4669,7 +4769,7 @@ function registerTagsCommand(program2) {
|
|
|
4669
4769
|
tags.command("list").description("List tags in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4670
4770
|
(opts) => runAction(async () => {
|
|
4671
4771
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4672
|
-
const data = await
|
|
4772
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4673
4773
|
if (data.length === 0) {
|
|
4674
4774
|
console.log("No tags found.");
|
|
4675
4775
|
return;
|
|
@@ -4713,7 +4813,7 @@ function registerTagsCommand(program2) {
|
|
|
4713
4813
|
]);
|
|
4714
4814
|
const instruction = interactive ? opts.instruction ?? (await promptInput("Instruction (optional)", false) || null) : opts.instruction ?? null;
|
|
4715
4815
|
const shared = interactive ? opts.shared || await promptConfirm("Shared?", false) : opts.shared ?? false;
|
|
4716
|
-
const data = await
|
|
4816
|
+
const data = await sdk.tags.createTag(arbi, {
|
|
4717
4817
|
name,
|
|
4718
4818
|
tagType: { type: tagType, options: [] },
|
|
4719
4819
|
instruction,
|
|
@@ -4729,7 +4829,7 @@ function registerTagsCommand(program2) {
|
|
|
4729
4829
|
const { choices } = await fetchTagChoices(arbi, workspaceId);
|
|
4730
4830
|
id = await promptSelect("Select tag to delete", choices);
|
|
4731
4831
|
}
|
|
4732
|
-
const data = await
|
|
4832
|
+
const data = await sdk.tags.deleteTag(arbi, id);
|
|
4733
4833
|
success(data?.detail ?? `Deleted tag ${id}`);
|
|
4734
4834
|
})()
|
|
4735
4835
|
);
|
|
@@ -4755,7 +4855,7 @@ function registerTagsCommand(program2) {
|
|
|
4755
4855
|
body = { [field]: await promptInput(field.charAt(0).toUpperCase() + field.slice(1)) };
|
|
4756
4856
|
}
|
|
4757
4857
|
}
|
|
4758
|
-
const data = await
|
|
4858
|
+
const data = await sdk.tags.updateTag(arbi, id, body);
|
|
4759
4859
|
success(`Updated: ${data.name} (${ref(data.external_id)})`);
|
|
4760
4860
|
})()
|
|
4761
4861
|
);
|
|
@@ -4764,7 +4864,7 @@ function registerTagsCommand(program2) {
|
|
|
4764
4864
|
});
|
|
4765
4865
|
}
|
|
4766
4866
|
async function pickTag(arbi, workspaceId, message = "Select tag") {
|
|
4767
|
-
const data = await
|
|
4867
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4768
4868
|
if (data.length === 0) {
|
|
4769
4869
|
console.log("No tags found.");
|
|
4770
4870
|
process.exit(0);
|
|
@@ -4779,7 +4879,7 @@ async function pickTag(arbi, workspaceId, message = "Select tag") {
|
|
|
4779
4879
|
);
|
|
4780
4880
|
}
|
|
4781
4881
|
async function pickDocs(arbi, workspaceId, message = "Select documents") {
|
|
4782
|
-
const data = await
|
|
4882
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4783
4883
|
if (data.length === 0) {
|
|
4784
4884
|
console.log("No documents found.");
|
|
4785
4885
|
process.exit(0);
|
|
@@ -4801,7 +4901,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4801
4901
|
if (!docIds || docIds.length === 0)
|
|
4802
4902
|
docIds = await pickDocs(arbi, workspaceId, "Select documents to tag");
|
|
4803
4903
|
if (docIds.length === 0) return;
|
|
4804
|
-
const data = await
|
|
4904
|
+
const data = await sdk.doctags.assignDocTags(arbi, tagId, docIds, opts?.note);
|
|
4805
4905
|
success(`Created ${data.length} doctag(s) for tag ${tagId}.`);
|
|
4806
4906
|
})()
|
|
4807
4907
|
);
|
|
@@ -4812,7 +4912,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4812
4912
|
if (!docIds || docIds.length === 0)
|
|
4813
4913
|
docIds = await pickDocs(arbi, workspaceId, "Select documents to untag");
|
|
4814
4914
|
if (docIds.length === 0) return;
|
|
4815
|
-
await
|
|
4915
|
+
await sdk.doctags.removeDocTags(arbi, tagId, docIds);
|
|
4816
4916
|
success(`Removed tag ${tagId} from ${docIds.length} document(s).`);
|
|
4817
4917
|
})()
|
|
4818
4918
|
);
|
|
@@ -4823,7 +4923,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4823
4923
|
if (opts.tags) {
|
|
4824
4924
|
tagIds = opts.tags.split(",").map((s) => s.trim());
|
|
4825
4925
|
} else {
|
|
4826
|
-
const data2 = await
|
|
4926
|
+
const data2 = await sdk.tags.listTags(arbi);
|
|
4827
4927
|
if (data2.length === 0) {
|
|
4828
4928
|
console.log("No tags found.");
|
|
4829
4929
|
return;
|
|
@@ -4844,7 +4944,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4844
4944
|
docIds = await pickDocs(arbi, workspaceId, "Select documents for AI tagging");
|
|
4845
4945
|
if (docIds.length === 0) return;
|
|
4846
4946
|
}
|
|
4847
|
-
const data = await
|
|
4947
|
+
const data = await sdk.doctags.generateDocTags(arbi, tagIds, docIds);
|
|
4848
4948
|
console.log(
|
|
4849
4949
|
`Generating doctags for ${data.doc_ext_ids.length} doc(s) with ${data.tag_ext_ids.length} tag(s).`
|
|
4850
4950
|
);
|
|
@@ -4852,7 +4952,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4852
4952
|
);
|
|
4853
4953
|
}
|
|
4854
4954
|
async function pickConversation(arbi, workspaceId, message = "Select conversation") {
|
|
4855
|
-
const data = await
|
|
4955
|
+
const data = await sdk.conversations.listConversations(arbi);
|
|
4856
4956
|
if (data.length === 0) {
|
|
4857
4957
|
console.log("No conversations found.");
|
|
4858
4958
|
process.exit(0);
|
|
@@ -4871,7 +4971,7 @@ function registerConversationsCommand(program2) {
|
|
|
4871
4971
|
conv.command("list").description("List conversations in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4872
4972
|
(opts) => runAction(async () => {
|
|
4873
4973
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4874
|
-
const data = await
|
|
4974
|
+
const data = await sdk.conversations.listConversations(arbi);
|
|
4875
4975
|
if (data.length === 0) {
|
|
4876
4976
|
console.log("No conversations found.");
|
|
4877
4977
|
return;
|
|
@@ -4891,7 +4991,7 @@ function registerConversationsCommand(program2) {
|
|
|
4891
4991
|
(conversationId) => runAction(async () => {
|
|
4892
4992
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4893
4993
|
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4894
|
-
const data = await
|
|
4994
|
+
const data = await sdk.conversations.getConversationThreads(arbi, conversationId);
|
|
4895
4995
|
console.log(JSON.stringify(data, null, 2));
|
|
4896
4996
|
})()
|
|
4897
4997
|
);
|
|
@@ -4904,7 +5004,7 @@ function registerConversationsCommand(program2) {
|
|
|
4904
5004
|
workspaceId,
|
|
4905
5005
|
"Select conversation to delete"
|
|
4906
5006
|
);
|
|
4907
|
-
const data = await
|
|
5007
|
+
const data = await sdk.conversations.deleteConversation(arbi, conversationId);
|
|
4908
5008
|
success(data?.detail ?? `Deleted conversation ${conversationId}`);
|
|
4909
5009
|
})()
|
|
4910
5010
|
);
|
|
@@ -4913,7 +5013,7 @@ function registerConversationsCommand(program2) {
|
|
|
4913
5013
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4914
5014
|
if (!conversationId)
|
|
4915
5015
|
conversationId = await pickConversation(arbi, workspaceId, "Select conversation to share");
|
|
4916
|
-
const data = await
|
|
5016
|
+
const data = await sdk.conversations.shareConversation(arbi, conversationId);
|
|
4917
5017
|
success(data?.detail ?? `Shared conversation ${conversationId}`);
|
|
4918
5018
|
})()
|
|
4919
5019
|
);
|
|
@@ -4922,21 +5022,21 @@ function registerConversationsCommand(program2) {
|
|
|
4922
5022
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4923
5023
|
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4924
5024
|
if (!title) title = await promptInput("New title");
|
|
4925
|
-
const data = await
|
|
5025
|
+
const data = await sdk.conversations.updateConversationTitle(arbi, conversationId, title);
|
|
4926
5026
|
success(data?.detail ?? `Updated title to: ${title}`);
|
|
4927
5027
|
})()
|
|
4928
5028
|
);
|
|
4929
5029
|
conv.command("message <message-id>").description("Get message details").action(
|
|
4930
5030
|
(messageId) => runAction(async () => {
|
|
4931
5031
|
const { arbi } = await resolveWorkspace();
|
|
4932
|
-
const data = await
|
|
5032
|
+
const data = await sdk.conversations.getMessage(arbi, messageId);
|
|
4933
5033
|
console.log(JSON.stringify(data, null, 2));
|
|
4934
5034
|
})()
|
|
4935
5035
|
);
|
|
4936
5036
|
conv.command("delete-message <message-id>").description("Delete a message and its descendants").action(
|
|
4937
5037
|
(messageId) => runAction(async () => {
|
|
4938
5038
|
const { arbi } = await resolveAuth();
|
|
4939
|
-
const data = await
|
|
5039
|
+
const data = await sdk.conversations.deleteMessage(arbi, messageId);
|
|
4940
5040
|
success(data?.detail ?? `Deleted message ${messageId}`);
|
|
4941
5041
|
})()
|
|
4942
5042
|
);
|
|
@@ -4949,7 +5049,7 @@ function registerSettingsCommand(program2) {
|
|
|
4949
5049
|
settings.command("get").description("Show current user settings").action(
|
|
4950
5050
|
runAction(async () => {
|
|
4951
5051
|
const { arbi } = await resolveAuth();
|
|
4952
|
-
const data = await
|
|
5052
|
+
const data = await sdk.settings.getSettings(arbi);
|
|
4953
5053
|
console.log(JSON.stringify(data, null, 2));
|
|
4954
5054
|
})
|
|
4955
5055
|
);
|
|
@@ -4957,7 +5057,7 @@ function registerSettingsCommand(program2) {
|
|
|
4957
5057
|
(json) => runAction(async () => {
|
|
4958
5058
|
const body = parseJsonArg(json, `arbi settings set '{"hide_online_status": true}'`);
|
|
4959
5059
|
const { arbi } = await resolveAuth();
|
|
4960
|
-
await
|
|
5060
|
+
await sdk.settings.updateSettings(arbi, body);
|
|
4961
5061
|
success("Settings updated.");
|
|
4962
5062
|
})()
|
|
4963
5063
|
);
|
|
@@ -4975,7 +5075,7 @@ var MODEL_SECTIONS = [
|
|
|
4975
5075
|
"ArtifactLLM"
|
|
4976
5076
|
];
|
|
4977
5077
|
async function pickConfig(arbi, message = "Select configuration") {
|
|
4978
|
-
const data = await
|
|
5078
|
+
const data = await sdk.agentconfig.listConfigs(arbi);
|
|
4979
5079
|
if (data.versions.length === 0) {
|
|
4980
5080
|
console.log("No saved configurations found.");
|
|
4981
5081
|
process.exit(0);
|
|
@@ -4990,7 +5090,7 @@ async function pickConfig(arbi, message = "Select configuration") {
|
|
|
4990
5090
|
);
|
|
4991
5091
|
}
|
|
4992
5092
|
async function fetchModels(arbi) {
|
|
4993
|
-
const data = await
|
|
5093
|
+
const data = await sdk.agentconfig.getModels(arbi);
|
|
4994
5094
|
return data.models.map((m) => ({
|
|
4995
5095
|
name: `${m.model_name} (${m.provider ?? m.api_type})`,
|
|
4996
5096
|
value: m.model_name,
|
|
@@ -5112,7 +5212,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5112
5212
|
ac.command("list").description("List saved configuration versions").action(
|
|
5113
5213
|
runAction(async () => {
|
|
5114
5214
|
const { arbi } = await resolveAuth();
|
|
5115
|
-
const data = await
|
|
5215
|
+
const data = await sdk.agentconfig.listConfigs(arbi);
|
|
5116
5216
|
if (data.versions.length === 0) {
|
|
5117
5217
|
console.log("No saved configurations.");
|
|
5118
5218
|
return;
|
|
@@ -5143,7 +5243,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5143
5243
|
configId = await pickConfig(arbi);
|
|
5144
5244
|
}
|
|
5145
5245
|
}
|
|
5146
|
-
const data = await
|
|
5246
|
+
const data = await sdk.agentconfig.getConfig(arbi, configId);
|
|
5147
5247
|
console.log(JSON.stringify(data, null, 2));
|
|
5148
5248
|
})()
|
|
5149
5249
|
);
|
|
@@ -5162,7 +5262,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5162
5262
|
}
|
|
5163
5263
|
if (opts?.tag) body.tag_ext_id = opts.tag;
|
|
5164
5264
|
if (opts?.message) body.parent_message_ext_id = opts.message;
|
|
5165
|
-
const data = await
|
|
5265
|
+
const data = await sdk.agentconfig.saveConfig(arbi, body);
|
|
5166
5266
|
success(`Saved: ${data.title || "(untitled)"} (${ref(data.external_id)})`);
|
|
5167
5267
|
})()
|
|
5168
5268
|
);
|
|
@@ -5170,14 +5270,14 @@ function registerAgentconfigCommand(program2) {
|
|
|
5170
5270
|
(configId) => runAction(async () => {
|
|
5171
5271
|
const { arbi } = await resolveAuth();
|
|
5172
5272
|
if (!configId) configId = await pickConfig(arbi, "Select configuration to delete");
|
|
5173
|
-
const data = await
|
|
5273
|
+
const data = await sdk.agentconfig.deleteConfig(arbi, configId);
|
|
5174
5274
|
success(data.detail);
|
|
5175
5275
|
})()
|
|
5176
5276
|
);
|
|
5177
5277
|
ac.command("schema").description("Show JSON schema for all configuration models").action(
|
|
5178
5278
|
runAction(async () => {
|
|
5179
5279
|
const { arbi } = await resolveAuth();
|
|
5180
|
-
const data = await
|
|
5280
|
+
const data = await sdk.agentconfig.getSchema(arbi);
|
|
5181
5281
|
console.log(JSON.stringify(data, null, 2));
|
|
5182
5282
|
})
|
|
5183
5283
|
);
|
|
@@ -5189,7 +5289,7 @@ function registerHealthCommand(program2) {
|
|
|
5189
5289
|
program2.command("health").description("Show server health status").action(
|
|
5190
5290
|
runAction(async () => {
|
|
5191
5291
|
const { arbi } = await resolveAuth();
|
|
5192
|
-
const data = await
|
|
5292
|
+
const data = await sdk.health.getHealth(arbi);
|
|
5193
5293
|
label("Status:", status(data.status));
|
|
5194
5294
|
if (data.backend_git_hash) label("Backend:", data.backend_git_hash);
|
|
5195
5295
|
if (data.frontend_docker_version) label("Frontend:", data.frontend_docker_version);
|
|
@@ -5211,7 +5311,7 @@ Models (${data.models_health.application}):`);
|
|
|
5211
5311
|
program2.command("models").description("List available AI models").action(
|
|
5212
5312
|
runAction(async () => {
|
|
5213
5313
|
const { arbi } = await resolveAuth();
|
|
5214
|
-
const data = await
|
|
5314
|
+
const data = await sdk.health.getHealthModels(arbi);
|
|
5215
5315
|
if (data.models.length === 0) {
|
|
5216
5316
|
console.log("No models available.");
|
|
5217
5317
|
return;
|
|
@@ -5283,7 +5383,7 @@ console.info = (...args) => {
|
|
|
5283
5383
|
_origInfo(...args);
|
|
5284
5384
|
};
|
|
5285
5385
|
var program = new commander.Command();
|
|
5286
|
-
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.
|
|
5386
|
+
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.11");
|
|
5287
5387
|
registerConfigCommand(program);
|
|
5288
5388
|
registerLoginCommand(program);
|
|
5289
5389
|
registerRegisterCommand(program);
|