@arbidocs/cli 0.3.8 → 0.3.10
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 +74 -43
- package/dist/index.js +176 -147
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
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.10";
|
|
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;
|
|
3534
3539
|
}
|
|
3540
|
+
if (skipSection && line.match(/^### /)) {
|
|
3541
|
+
skipSection = false;
|
|
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.10") 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.10"} \u2192 ${latest}). Updating...`);
|
|
3552
3562
|
child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
|
|
3553
|
-
showChangelog("0.3.
|
|
3563
|
+
showChangelog("0.3.10", 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.10"} \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.10") {
|
|
3569
3579
|
warn(
|
|
3570
|
-
`Your arbi version is out of date (${"0.3.
|
|
3580
|
+
`Your arbi version is out of date (${"0.3.10"} \u2192 ${cached.latest}). Run "arbi update".`
|
|
3571
3581
|
);
|
|
3572
3582
|
}
|
|
3573
3583
|
} catch {
|
|
@@ -3581,8 +3591,9 @@ 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
|
|
3585
|
-
|
|
3594
|
+
const { arbi } = await sdk.performPasswordLogin(config, email, pw, store);
|
|
3595
|
+
clearChatSession();
|
|
3596
|
+
const { data: workspaces2 } = await arbi.fetch.GET("/v1/user/workspaces");
|
|
3586
3597
|
const wsList = workspaces2 || [];
|
|
3587
3598
|
success(`Logged in as ${email}`);
|
|
3588
3599
|
if (wsList.length === 0) {
|
|
@@ -3604,14 +3615,14 @@ function registerLoginCommand(program2) {
|
|
|
3604
3615
|
success(`Workspace: ${wsList[0].name} (${ref(wsList[0].external_id)})`);
|
|
3605
3616
|
return;
|
|
3606
3617
|
}
|
|
3607
|
-
const choices =
|
|
3618
|
+
const choices = sdk.formatWorkspaceChoices(wsList);
|
|
3608
3619
|
const selected = await promptSelect("Select workspace", choices);
|
|
3609
3620
|
updateConfig({ selectedWorkspaceId: selected });
|
|
3610
3621
|
const ws = wsList.find((w) => w.external_id === selected);
|
|
3611
3622
|
success(`Workspace: ${ws.name} (${ref(selected)})`);
|
|
3612
3623
|
dim('\nTip: Run "arbi config alias" to use A as a shortcut for "arbi ask"');
|
|
3613
3624
|
} catch (err) {
|
|
3614
|
-
error(`Login failed: ${
|
|
3625
|
+
error(`Login failed: ${sdk.getErrorMessage(err)}`);
|
|
3615
3626
|
process.exit(1);
|
|
3616
3627
|
} finally {
|
|
3617
3628
|
await checkForUpdates(getConfig()?.autoUpdate);
|
|
@@ -3646,7 +3657,7 @@ function registerRegisterCommand(program2) {
|
|
|
3646
3657
|
}
|
|
3647
3658
|
async function smartRegister(config, opts) {
|
|
3648
3659
|
const email = opts.email || process.env.ARBI_EMAIL || await promptInput("Email");
|
|
3649
|
-
const arbi =
|
|
3660
|
+
const arbi = client.createArbiClient({
|
|
3650
3661
|
baseUrl: config.baseUrl,
|
|
3651
3662
|
deploymentDomain: config.deploymentDomain,
|
|
3652
3663
|
credentials: "omit"
|
|
@@ -3664,7 +3675,7 @@ async function smartRegister(config, opts) {
|
|
|
3664
3675
|
verificationCode = await promptInput("Invitation code");
|
|
3665
3676
|
} else {
|
|
3666
3677
|
console.log("Sending verification email...");
|
|
3667
|
-
const verifyResponse = await arbi.fetch.POST("/
|
|
3678
|
+
const verifyResponse = await arbi.fetch.POST("/v1/user/verify-email", {
|
|
3668
3679
|
body: { email }
|
|
3669
3680
|
});
|
|
3670
3681
|
if (verifyResponse.error) {
|
|
@@ -3701,7 +3712,7 @@ async function smartRegister(config, opts) {
|
|
|
3701
3712
|
success(`
|
|
3702
3713
|
Registered successfully as ${email}`);
|
|
3703
3714
|
} catch (err) {
|
|
3704
|
-
error(`Registration failed: ${
|
|
3715
|
+
error(`Registration failed: ${sdk.getErrorMessage(err)}`);
|
|
3705
3716
|
process.exit(1);
|
|
3706
3717
|
}
|
|
3707
3718
|
const allFlagsProvided = !!(opts.email || process.env.ARBI_EMAIL) && !!(opts.password || process.env.ARBI_PASSWORD) && !!opts.verificationCode;
|
|
@@ -3722,7 +3733,7 @@ async function nonInteractiveRegister(config, opts) {
|
|
|
3722
3733
|
error("Password required. Use --password <password> or set ARBI_PASSWORD");
|
|
3723
3734
|
process.exit(1);
|
|
3724
3735
|
}
|
|
3725
|
-
const arbi =
|
|
3736
|
+
const arbi = client.createArbiClient({
|
|
3726
3737
|
baseUrl: config.baseUrl,
|
|
3727
3738
|
deploymentDomain: config.deploymentDomain,
|
|
3728
3739
|
credentials: "omit"
|
|
@@ -3738,7 +3749,7 @@ async function nonInteractiveRegister(config, opts) {
|
|
|
3738
3749
|
);
|
|
3739
3750
|
process.exit(1);
|
|
3740
3751
|
}
|
|
3741
|
-
const verifyResponse = await arbi.fetch.POST("/
|
|
3752
|
+
const verifyResponse = await arbi.fetch.POST("/v1/user/verify-email", {
|
|
3742
3753
|
body: { email }
|
|
3743
3754
|
});
|
|
3744
3755
|
if (verifyResponse.error) {
|
|
@@ -3757,19 +3768,19 @@ async function nonInteractiveRegister(config, opts) {
|
|
|
3757
3768
|
});
|
|
3758
3769
|
success(`Registered: ${email}`);
|
|
3759
3770
|
} catch (err) {
|
|
3760
|
-
error(`Registration failed: ${
|
|
3771
|
+
error(`Registration failed: ${sdk.getErrorMessage(err)}`);
|
|
3761
3772
|
process.exit(1);
|
|
3762
3773
|
}
|
|
3763
3774
|
}
|
|
3764
3775
|
async function loginAfterRegister(config, email, password2) {
|
|
3765
3776
|
try {
|
|
3766
|
-
const { arbi } = await
|
|
3777
|
+
const { arbi } = await sdk.performPasswordLogin(config, email, password2, store);
|
|
3767
3778
|
success(`Logged in as ${email}`);
|
|
3768
|
-
const { data: workspaces2 } = await arbi.fetch.GET("/
|
|
3779
|
+
const { data: workspaces2 } = await arbi.fetch.GET("/v1/user/workspaces");
|
|
3769
3780
|
const wsList = workspaces2 || [];
|
|
3770
3781
|
if (wsList.length === 0) {
|
|
3771
3782
|
console.log("Creating your first workspace...");
|
|
3772
|
-
const ws2 = await
|
|
3783
|
+
const ws2 = await sdk.workspaces.createWorkspace(arbi, "My First Workspace");
|
|
3773
3784
|
updateConfig({ selectedWorkspaceId: ws2.external_id });
|
|
3774
3785
|
success(`Workspace: ${ws2.name} (${ref(ws2.external_id)})`);
|
|
3775
3786
|
return;
|
|
@@ -3779,13 +3790,13 @@ async function loginAfterRegister(config, email, password2) {
|
|
|
3779
3790
|
success(`Workspace: ${wsList[0].name} (${ref(wsList[0].external_id)})`);
|
|
3780
3791
|
return;
|
|
3781
3792
|
}
|
|
3782
|
-
const choices =
|
|
3793
|
+
const choices = sdk.formatWorkspaceChoices(wsList);
|
|
3783
3794
|
const selected = await promptSelect("Select workspace", choices);
|
|
3784
3795
|
updateConfig({ selectedWorkspaceId: selected });
|
|
3785
3796
|
const ws = wsList.find((w) => w.external_id === selected);
|
|
3786
3797
|
success(`Workspace: ${ws.name} (${ref(selected)})`);
|
|
3787
3798
|
} catch (err) {
|
|
3788
|
-
error(`Login failed: ${
|
|
3799
|
+
error(`Login failed: ${sdk.getErrorMessage(err)}`);
|
|
3789
3800
|
error("You can log in later with: arbi login");
|
|
3790
3801
|
}
|
|
3791
3802
|
}
|
|
@@ -3794,6 +3805,7 @@ async function loginAfterRegister(config, email, password2) {
|
|
|
3794
3805
|
function registerLogoutCommand(program2) {
|
|
3795
3806
|
program2.command("logout").description("Log out of ARBI").action(() => {
|
|
3796
3807
|
deleteCredentials();
|
|
3808
|
+
clearChatSession();
|
|
3797
3809
|
updateConfig({ selectedWorkspaceId: void 0 });
|
|
3798
3810
|
success("Logged out.");
|
|
3799
3811
|
});
|
|
@@ -3834,11 +3846,11 @@ function colorize(level, text) {
|
|
|
3834
3846
|
async function startBackgroundNotifications(baseUrl, accessToken) {
|
|
3835
3847
|
if (activeConnection) return;
|
|
3836
3848
|
try {
|
|
3837
|
-
activeConnection = await
|
|
3849
|
+
activeConnection = await sdk.connectWithReconnect({
|
|
3838
3850
|
baseUrl,
|
|
3839
3851
|
accessToken,
|
|
3840
3852
|
onMessage: (msg) => {
|
|
3841
|
-
const { text, level } =
|
|
3853
|
+
const { text, level } = sdk.formatWsMessage(msg);
|
|
3842
3854
|
process.stderr.write(`
|
|
3843
3855
|
${colorize(level, `[${timestamp()}] ${text}`)}
|
|
3844
3856
|
`);
|
|
@@ -3882,8 +3894,9 @@ function runAction(fn) {
|
|
|
3882
3894
|
return async () => {
|
|
3883
3895
|
try {
|
|
3884
3896
|
await fn();
|
|
3897
|
+
process.exit(0);
|
|
3885
3898
|
} catch (err) {
|
|
3886
|
-
error(`Error: ${
|
|
3899
|
+
error(`Error: ${sdk.getErrorMessage(err)}`);
|
|
3887
3900
|
hintUpdateOnError();
|
|
3888
3901
|
process.exit(1);
|
|
3889
3902
|
}
|
|
@@ -3891,9 +3904,9 @@ function runAction(fn) {
|
|
|
3891
3904
|
}
|
|
3892
3905
|
async function resolveAuth() {
|
|
3893
3906
|
try {
|
|
3894
|
-
return await
|
|
3907
|
+
return await sdk.resolveAuth(store);
|
|
3895
3908
|
} catch (err) {
|
|
3896
|
-
if (err instanceof
|
|
3909
|
+
if (err instanceof sdk.ArbiError) {
|
|
3897
3910
|
error(err.message);
|
|
3898
3911
|
process.exit(1);
|
|
3899
3912
|
}
|
|
@@ -3902,14 +3915,14 @@ async function resolveAuth() {
|
|
|
3902
3915
|
}
|
|
3903
3916
|
async function resolveWorkspace(workspaceOpt) {
|
|
3904
3917
|
try {
|
|
3905
|
-
const ctx = await
|
|
3918
|
+
const ctx = await sdk.resolveWorkspace(store, workspaceOpt);
|
|
3906
3919
|
if (getConfig()?.notifications) {
|
|
3907
3920
|
startBackgroundNotifications(ctx.config.baseUrl, ctx.accessToken).catch(() => {
|
|
3908
3921
|
});
|
|
3909
3922
|
}
|
|
3910
3923
|
return ctx;
|
|
3911
3924
|
} catch (err) {
|
|
3912
|
-
if (err instanceof
|
|
3925
|
+
if (err instanceof sdk.ArbiError) {
|
|
3913
3926
|
error(err.message);
|
|
3914
3927
|
process.exit(1);
|
|
3915
3928
|
}
|
|
@@ -3941,7 +3954,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3941
3954
|
program2.command("workspaces").description("List workspaces").action(
|
|
3942
3955
|
runAction(async () => {
|
|
3943
3956
|
const { arbi } = await resolveAuth();
|
|
3944
|
-
const data = await
|
|
3957
|
+
const data = await sdk.workspaces.listWorkspaces(arbi);
|
|
3945
3958
|
if (data.length === 0) {
|
|
3946
3959
|
console.log("No workspaces found.");
|
|
3947
3960
|
return;
|
|
@@ -3969,7 +3982,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3969
3982
|
workspace.command("select [id]").description("Select active workspace (interactive picker if no ID given)").action(
|
|
3970
3983
|
(id) => runAction(async () => {
|
|
3971
3984
|
const { arbi } = await resolveAuth();
|
|
3972
|
-
const data = await
|
|
3985
|
+
const data = await sdk.workspaces.listWorkspaces(arbi);
|
|
3973
3986
|
if (data.length === 0) {
|
|
3974
3987
|
console.log("No workspaces found.");
|
|
3975
3988
|
return;
|
|
@@ -3985,10 +3998,11 @@ function registerWorkspacesCommand(program2) {
|
|
|
3985
3998
|
}
|
|
3986
3999
|
selectedId = id;
|
|
3987
4000
|
} else {
|
|
3988
|
-
const choices =
|
|
4001
|
+
const choices = sdk.formatWorkspaceChoices(data);
|
|
3989
4002
|
selectedId = await promptSelect("Select workspace", choices);
|
|
3990
4003
|
}
|
|
3991
4004
|
updateConfig({ selectedWorkspaceId: selectedId });
|
|
4005
|
+
clearChatSession();
|
|
3992
4006
|
const ws = data.find((w) => w.external_id === selectedId);
|
|
3993
4007
|
success(`Selected: ${ws.name} (${ref(selectedId)})`);
|
|
3994
4008
|
})()
|
|
@@ -3996,7 +4010,7 @@ function registerWorkspacesCommand(program2) {
|
|
|
3996
4010
|
workspace.command("create <name>").description("Create a new workspace").option("-d, --description <text>", "Workspace description").option("--public", "Make workspace public", false).action(
|
|
3997
4011
|
(name, opts) => runAction(async () => {
|
|
3998
4012
|
const { arbi } = await resolveAuth();
|
|
3999
|
-
const data = await
|
|
4013
|
+
const data = await sdk.workspaces.createWorkspace(
|
|
4000
4014
|
arbi,
|
|
4001
4015
|
name,
|
|
4002
4016
|
opts.description,
|
|
@@ -4005,25 +4019,30 @@ function registerWorkspacesCommand(program2) {
|
|
|
4005
4019
|
success(`Created: ${data.name} (${ref(data.external_id)})`);
|
|
4006
4020
|
})()
|
|
4007
4021
|
);
|
|
4008
|
-
workspace.command("delete
|
|
4022
|
+
workspace.command("delete [id]").description("Delete a workspace (defaults to selected workspace)").action(
|
|
4009
4023
|
(id) => runAction(async () => {
|
|
4010
4024
|
const { arbi } = await resolveAuth();
|
|
4011
|
-
const
|
|
4012
|
-
|
|
4025
|
+
const targetId = id ?? getConfig()?.selectedWorkspaceId;
|
|
4026
|
+
if (!targetId) {
|
|
4027
|
+
error("No workspace ID given and no workspace selected. Run: arbi workspace select");
|
|
4028
|
+
process.exit(1);
|
|
4029
|
+
}
|
|
4030
|
+
await sdk.workspaces.deleteWorkspaces(arbi, [targetId]);
|
|
4031
|
+
success(`Deleted workspace ${targetId}`);
|
|
4013
4032
|
})()
|
|
4014
4033
|
);
|
|
4015
4034
|
workspace.command("update <id> <json>").description("Update workspace properties (pass JSON)").action(
|
|
4016
4035
|
(id, json) => runAction(async () => {
|
|
4017
4036
|
const body = parseJsonArg(json, `arbi workspace update wrk-123 '{"name": "New Name"}'`);
|
|
4018
4037
|
const { arbi } = await resolveWorkspace(id);
|
|
4019
|
-
const data = await
|
|
4038
|
+
const data = await sdk.workspaces.updateWorkspace(arbi, body);
|
|
4020
4039
|
success(`Updated: ${data.name} (${ref(data.external_id)})`);
|
|
4021
4040
|
})()
|
|
4022
4041
|
);
|
|
4023
4042
|
workspace.command("users").description("List users in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4024
4043
|
(opts) => runAction(async () => {
|
|
4025
4044
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4026
|
-
const data = await
|
|
4045
|
+
const data = await sdk.workspaces.listWorkspaceUsers(arbi);
|
|
4027
4046
|
if (data.length === 0) {
|
|
4028
4047
|
console.log("No users found.");
|
|
4029
4048
|
return;
|
|
@@ -4060,23 +4079,22 @@ function registerWorkspacesCommand(program2) {
|
|
|
4060
4079
|
(emails, opts) => runAction(async () => {
|
|
4061
4080
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4062
4081
|
const role = opts.role ?? "collaborator";
|
|
4063
|
-
const data = await
|
|
4082
|
+
const data = await sdk.workspaces.addWorkspaceUsers(arbi, emails, role);
|
|
4064
4083
|
for (const u of data) success(`Added: ${u.user.email} as ${u.role}`);
|
|
4065
4084
|
})()
|
|
4066
4085
|
);
|
|
4067
4086
|
workspace.command("remove-user <user-ids...>").description("Remove users from the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4068
4087
|
(userIds, opts) => runAction(async () => {
|
|
4069
4088
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4070
|
-
await
|
|
4089
|
+
await sdk.workspaces.removeWorkspaceUsers(arbi, userIds);
|
|
4071
4090
|
success(`Removed ${userIds.length} user(s).`);
|
|
4072
4091
|
})()
|
|
4073
4092
|
);
|
|
4074
4093
|
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(
|
|
4075
4094
|
(role, userIds, opts) => runAction(async () => {
|
|
4076
4095
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4077
|
-
const data = await
|
|
4096
|
+
const data = await sdk.workspaces.setUserRole(
|
|
4078
4097
|
arbi,
|
|
4079
|
-
workspaceId,
|
|
4080
4098
|
userIds,
|
|
4081
4099
|
role
|
|
4082
4100
|
);
|
|
@@ -4085,8 +4103,21 @@ function registerWorkspacesCommand(program2) {
|
|
|
4085
4103
|
);
|
|
4086
4104
|
workspace.command("copy <target-workspace-id> <doc-ids...>").description("Copy documents to another workspace").option("-w, --workspace <id>", "Source workspace ID (defaults to selected workspace)").action(
|
|
4087
4105
|
(targetId, docIds, opts) => runAction(async () => {
|
|
4088
|
-
const { arbi,
|
|
4089
|
-
const
|
|
4106
|
+
const { arbi, loginResult } = await resolveWorkspace(opts.workspace);
|
|
4107
|
+
const signingPrivateKeyBase64 = arbi.crypto.bytesToBase64(loginResult.signingPrivateKey);
|
|
4108
|
+
const wsList = await sdk.workspaces.listWorkspaces(arbi);
|
|
4109
|
+
const targetWs = wsList.find((w) => w.external_id === targetId);
|
|
4110
|
+
if (!targetWs || !targetWs.wrapped_key) {
|
|
4111
|
+
error(`Target workspace ${targetId} not found or has no encryption key`);
|
|
4112
|
+
process.exit(1);
|
|
4113
|
+
}
|
|
4114
|
+
const targetKey = await sdk.generateEncryptedWorkspaceKey(
|
|
4115
|
+
arbi,
|
|
4116
|
+
targetWs.wrapped_key,
|
|
4117
|
+
loginResult.serverSessionKey,
|
|
4118
|
+
signingPrivateKeyBase64
|
|
4119
|
+
);
|
|
4120
|
+
const data = await sdk.workspaces.copyDocuments(arbi, targetId, docIds, targetKey);
|
|
4090
4121
|
success(`${data.detail} (${data.documents_copied} document(s) copied)`);
|
|
4091
4122
|
})()
|
|
4092
4123
|
);
|
|
@@ -4110,7 +4141,7 @@ function statusSymbol(status2) {
|
|
|
4110
4141
|
}
|
|
4111
4142
|
}
|
|
4112
4143
|
async function fetchDocChoices(arbi, workspaceId) {
|
|
4113
|
-
const data = await
|
|
4144
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4114
4145
|
if (data.length === 0) {
|
|
4115
4146
|
console.log("No documents found.");
|
|
4116
4147
|
process.exit(0);
|
|
@@ -4125,7 +4156,7 @@ function registerDocsCommand(program2) {
|
|
|
4125
4156
|
program2.command("docs").description("List documents in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4126
4157
|
(opts) => runAction(async () => {
|
|
4127
4158
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4128
|
-
const data = await
|
|
4159
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4129
4160
|
if (data.length === 0) {
|
|
4130
4161
|
console.log("No documents found.");
|
|
4131
4162
|
return;
|
|
@@ -4174,7 +4205,7 @@ function registerDocsCommand(program2) {
|
|
|
4174
4205
|
if (selected.length === 0) return;
|
|
4175
4206
|
docIds = selected;
|
|
4176
4207
|
}
|
|
4177
|
-
const data = await
|
|
4208
|
+
const data = await sdk.documents.getDocuments(arbi, docIds);
|
|
4178
4209
|
console.log(JSON.stringify(data, null, 2));
|
|
4179
4210
|
})()
|
|
4180
4211
|
);
|
|
@@ -4188,7 +4219,7 @@ function registerDocsCommand(program2) {
|
|
|
4188
4219
|
if (selected.length === 0) return;
|
|
4189
4220
|
docIds = selected;
|
|
4190
4221
|
}
|
|
4191
|
-
await
|
|
4222
|
+
await sdk.documents.deleteDocuments(arbi, docIds);
|
|
4192
4223
|
success(`Deleted ${docIds.length} document(s).`);
|
|
4193
4224
|
})()
|
|
4194
4225
|
);
|
|
@@ -4198,7 +4229,7 @@ function registerDocsCommand(program2) {
|
|
|
4198
4229
|
const parsed = parseJsonArg(json, `arbi doc update '[{"external_id": "doc-123", "shared": true}]'`);
|
|
4199
4230
|
const docs = Array.isArray(parsed) ? parsed : parsed.documents;
|
|
4200
4231
|
const { arbi } = await resolveWorkspace();
|
|
4201
|
-
const data = await
|
|
4232
|
+
const data = await sdk.documents.updateDocuments(arbi, docs);
|
|
4202
4233
|
success(`Updated ${data.length} document(s).`);
|
|
4203
4234
|
} else {
|
|
4204
4235
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
@@ -4222,7 +4253,7 @@ function registerDocsCommand(program2) {
|
|
|
4222
4253
|
} else {
|
|
4223
4254
|
value = await promptInput(`${field.charAt(0).toUpperCase() + field.slice(1)}`);
|
|
4224
4255
|
}
|
|
4225
|
-
const data = await
|
|
4256
|
+
const data = await sdk.documents.updateDocuments(arbi, [
|
|
4226
4257
|
{ external_id: docId, [field]: value }
|
|
4227
4258
|
]);
|
|
4228
4259
|
success(`Updated ${data.length} document(s).`);
|
|
@@ -4232,7 +4263,7 @@ function registerDocsCommand(program2) {
|
|
|
4232
4263
|
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(
|
|
4233
4264
|
(urls, opts) => runAction(async () => {
|
|
4234
4265
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4235
|
-
const data = await
|
|
4266
|
+
const data = await sdk.documents.uploadUrl(arbi, urls, workspaceId, opts.shared ?? false);
|
|
4236
4267
|
success(`Uploaded: ${data.doc_ext_ids.join(", ")}`);
|
|
4237
4268
|
if (data.duplicates && data.duplicates.length > 0) {
|
|
4238
4269
|
warn(`Duplicates: ${data.duplicates.join(", ")}`);
|
|
@@ -4257,7 +4288,7 @@ function registerDocsCommand(program2) {
|
|
|
4257
4288
|
error(`Invalid stage: ${stage}. Must be one of: ${validStages.join(", ")}`);
|
|
4258
4289
|
process.exit(1);
|
|
4259
4290
|
}
|
|
4260
|
-
const data = await
|
|
4291
|
+
const data = await sdk.documents.getParsedContent(
|
|
4261
4292
|
{ baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
|
|
4262
4293
|
docId,
|
|
4263
4294
|
stage
|
|
@@ -4281,7 +4312,7 @@ function registerUploadCommand(program2) {
|
|
|
4281
4312
|
const uploadedDocs = /* @__PURE__ */ new Map();
|
|
4282
4313
|
const auth = { baseUrl: config.baseUrl, accessToken, workspaceKeyHeader };
|
|
4283
4314
|
for (const filePath of files) {
|
|
4284
|
-
const result = await
|
|
4315
|
+
const result = await sdk.documents.uploadLocalFile(auth, workspaceId, filePath);
|
|
4285
4316
|
success(`Uploaded: ${result.fileName} (${result.doc_ext_ids.join(", ")})`);
|
|
4286
4317
|
if (result.duplicates && result.duplicates.length > 0) {
|
|
4287
4318
|
warn(` Duplicates: ${result.duplicates.join(", ")}`);
|
|
@@ -4292,11 +4323,11 @@ function registerUploadCommand(program2) {
|
|
|
4292
4323
|
const pending = new Set(uploadedDocs.keys());
|
|
4293
4324
|
console.log(`
|
|
4294
4325
|
Watching ${pending.size} document(s)...`);
|
|
4295
|
-
const conn = await
|
|
4326
|
+
const conn = await sdk.connectWebSocket({
|
|
4296
4327
|
baseUrl: config.baseUrl,
|
|
4297
4328
|
accessToken,
|
|
4298
4329
|
onMessage: (msg) => {
|
|
4299
|
-
if (
|
|
4330
|
+
if (client.isMessageType(msg, "task_update")) {
|
|
4300
4331
|
if (!pending.has(msg.doc_ext_id)) return;
|
|
4301
4332
|
console.log(
|
|
4302
4333
|
` ${uploadedDocs.get(msg.doc_ext_id) || msg.file_name}: ${status(msg.status)} (${msg.progress}%)`
|
|
@@ -4325,7 +4356,7 @@ function registerDownloadCommand(program2) {
|
|
|
4325
4356
|
(docId, opts) => runAction(async () => {
|
|
4326
4357
|
const { arbi, config, accessToken, workspaceKeyHeader, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4327
4358
|
if (!docId) {
|
|
4328
|
-
const data = await
|
|
4359
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4329
4360
|
if (data.length === 0) {
|
|
4330
4361
|
console.log("No documents found.");
|
|
4331
4362
|
return;
|
|
@@ -4337,7 +4368,7 @@ function registerDownloadCommand(program2) {
|
|
|
4337
4368
|
}));
|
|
4338
4369
|
docId = await promptSearch("Select document to download", choices);
|
|
4339
4370
|
}
|
|
4340
|
-
const res = await
|
|
4371
|
+
const res = await sdk.documents.downloadDocument(
|
|
4341
4372
|
{ baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
|
|
4342
4373
|
docId
|
|
4343
4374
|
);
|
|
@@ -4366,23 +4397,40 @@ function registerAskCommand(program2) {
|
|
|
4366
4397
|
clearChatSession();
|
|
4367
4398
|
session.lastMessageExtId = null;
|
|
4368
4399
|
}
|
|
4369
|
-
const docs = await
|
|
4400
|
+
const docs = await sdk.documents.listDocuments(arbi);
|
|
4370
4401
|
const docIds = docs.map((d) => d.external_id);
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4402
|
+
let res;
|
|
4403
|
+
try {
|
|
4404
|
+
res = await sdk.assistant.queryAssistant({
|
|
4405
|
+
baseUrl: config.baseUrl,
|
|
4406
|
+
accessToken,
|
|
4407
|
+
workspaceKeyHeader,
|
|
4408
|
+
workspaceId,
|
|
4409
|
+
question,
|
|
4410
|
+
docIds,
|
|
4411
|
+
previousResponseId: session.lastMessageExtId,
|
|
4412
|
+
model: opts.config
|
|
4413
|
+
});
|
|
4414
|
+
} catch (err) {
|
|
4415
|
+
const isStaleParent = session.lastMessageExtId && err instanceof Error && err.message.includes("Parent message not found");
|
|
4416
|
+
if (!isStaleParent) throw err;
|
|
4417
|
+
clearChatSession();
|
|
4418
|
+
res = await sdk.assistant.queryAssistant({
|
|
4419
|
+
baseUrl: config.baseUrl,
|
|
4420
|
+
accessToken,
|
|
4421
|
+
workspaceKeyHeader,
|
|
4422
|
+
workspaceId,
|
|
4423
|
+
question,
|
|
4424
|
+
docIds,
|
|
4425
|
+
previousResponseId: null,
|
|
4426
|
+
model: opts.config
|
|
4427
|
+
});
|
|
4428
|
+
}
|
|
4429
|
+
const result = await sdk.streamSSE(res, {
|
|
4382
4430
|
onToken: (content) => process.stdout.write(content),
|
|
4383
4431
|
onAgentStep: (data) => {
|
|
4384
4432
|
if (opts.verbose) {
|
|
4385
|
-
const focus = data.focus || data.
|
|
4433
|
+
const focus = data.focus || data.step || "";
|
|
4386
4434
|
console.error(chalk__default.default.dim(`
|
|
4387
4435
|
[agent] ${focus}`));
|
|
4388
4436
|
}
|
|
@@ -4415,11 +4463,11 @@ function registerWatchCommand(program2) {
|
|
|
4415
4463
|
(opts) => runAction(async () => {
|
|
4416
4464
|
const { config, accessToken, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4417
4465
|
console.log(`Watching workspace ${workspaceId}... (Ctrl+C to stop)`);
|
|
4418
|
-
await
|
|
4466
|
+
await sdk.connectWebSocket({
|
|
4419
4467
|
baseUrl: config.baseUrl,
|
|
4420
4468
|
accessToken,
|
|
4421
4469
|
onMessage: (msg) => {
|
|
4422
|
-
const { text, level } =
|
|
4470
|
+
const { text, level } = sdk.formatWsMessage(msg);
|
|
4423
4471
|
console.log(colorize2(level, text));
|
|
4424
4472
|
},
|
|
4425
4473
|
onClose: (code, reason) => {
|
|
@@ -4437,7 +4485,7 @@ function registerContactsCommand(program2) {
|
|
|
4437
4485
|
contacts.command("list").description("List all contacts").action(
|
|
4438
4486
|
runAction(async () => {
|
|
4439
4487
|
const { arbi } = await resolveAuth();
|
|
4440
|
-
const data = await
|
|
4488
|
+
const data = await sdk.contacts.listContacts(arbi);
|
|
4441
4489
|
if (data.length === 0) {
|
|
4442
4490
|
console.log("No contacts found.");
|
|
4443
4491
|
return;
|
|
@@ -4448,7 +4496,7 @@ function registerContactsCommand(program2) {
|
|
|
4448
4496
|
{
|
|
4449
4497
|
header: "NAME",
|
|
4450
4498
|
width: 20,
|
|
4451
|
-
value: (r) =>
|
|
4499
|
+
value: (r) => sdk.formatUserName(r.user)
|
|
4452
4500
|
},
|
|
4453
4501
|
{ header: "EMAIL", width: 30, value: (r) => r.email },
|
|
4454
4502
|
{ header: "STATUS", width: 18, value: (r) => r.status }
|
|
@@ -4465,7 +4513,7 @@ function registerContactsCommand(program2) {
|
|
|
4465
4513
|
emails = input2.split(",").map((e) => e.trim()).filter(Boolean);
|
|
4466
4514
|
if (emails.length === 0) return;
|
|
4467
4515
|
}
|
|
4468
|
-
const data = await
|
|
4516
|
+
const data = await sdk.contacts.addContacts(arbi, emails);
|
|
4469
4517
|
for (const c of data) {
|
|
4470
4518
|
success(`Added: ${c.email} (${c.external_id}) \u2014 ${c.status}`);
|
|
4471
4519
|
}
|
|
@@ -4476,7 +4524,7 @@ function registerContactsCommand(program2) {
|
|
|
4476
4524
|
const { arbi } = await resolveAuth();
|
|
4477
4525
|
let contactIds = ids && ids.length > 0 ? ids : void 0;
|
|
4478
4526
|
if (!contactIds) {
|
|
4479
|
-
const data = await
|
|
4527
|
+
const data = await sdk.contacts.listContacts(arbi);
|
|
4480
4528
|
if (data.length === 0) {
|
|
4481
4529
|
console.log("No contacts found.");
|
|
4482
4530
|
return;
|
|
@@ -4484,7 +4532,7 @@ function registerContactsCommand(program2) {
|
|
|
4484
4532
|
contactIds = await promptCheckbox(
|
|
4485
4533
|
"Select contacts to remove",
|
|
4486
4534
|
data.map((c) => {
|
|
4487
|
-
const name =
|
|
4535
|
+
const name = sdk.formatUserName(c.user);
|
|
4488
4536
|
return {
|
|
4489
4537
|
name: name ? `${name} (${c.email})` : c.email,
|
|
4490
4538
|
value: c.external_id
|
|
@@ -4493,7 +4541,7 @@ function registerContactsCommand(program2) {
|
|
|
4493
4541
|
);
|
|
4494
4542
|
if (contactIds.length === 0) return;
|
|
4495
4543
|
}
|
|
4496
|
-
await
|
|
4544
|
+
await sdk.contacts.removeContacts(arbi, contactIds);
|
|
4497
4545
|
success(`Removed ${contactIds.length} contact(s).`);
|
|
4498
4546
|
})()
|
|
4499
4547
|
);
|
|
@@ -4506,7 +4554,7 @@ function registerDmCommand(program2) {
|
|
|
4506
4554
|
dm.command("list").description("List all DMs and notifications").action(
|
|
4507
4555
|
runAction(async () => {
|
|
4508
4556
|
const { arbi } = await resolveAuth();
|
|
4509
|
-
const data = await
|
|
4557
|
+
const data = await sdk.dm.listDMs(arbi);
|
|
4510
4558
|
if (data.length === 0) {
|
|
4511
4559
|
console.log("No messages found.");
|
|
4512
4560
|
return;
|
|
@@ -4520,7 +4568,7 @@ function registerDmCommand(program2) {
|
|
|
4520
4568
|
width: 22,
|
|
4521
4569
|
value: (r) => {
|
|
4522
4570
|
const s = r.sender;
|
|
4523
|
-
return
|
|
4571
|
+
return sdk.formatUserName(s) || s?.email || "";
|
|
4524
4572
|
}
|
|
4525
4573
|
},
|
|
4526
4574
|
{ header: "READ", width: 6, value: (r) => r.read ? "yes" : "no" },
|
|
@@ -4534,7 +4582,7 @@ function registerDmCommand(program2) {
|
|
|
4534
4582
|
(recipient, content) => runAction(async () => {
|
|
4535
4583
|
const { arbi } = await resolveAuth();
|
|
4536
4584
|
if (!recipient) {
|
|
4537
|
-
const contacts = await
|
|
4585
|
+
const contacts = await sdk.contacts.listContacts(arbi);
|
|
4538
4586
|
if (contacts.length === 0) {
|
|
4539
4587
|
error("No contacts found. Add contacts first: arbi contacts add <email>");
|
|
4540
4588
|
process.exit(1);
|
|
@@ -4543,7 +4591,7 @@ function registerDmCommand(program2) {
|
|
|
4543
4591
|
"Send to",
|
|
4544
4592
|
contacts.map((c) => {
|
|
4545
4593
|
const u = c.user;
|
|
4546
|
-
const name =
|
|
4594
|
+
const name = sdk.formatUserName(u);
|
|
4547
4595
|
return {
|
|
4548
4596
|
name: name ? `${name} (${c.email})` : c.email,
|
|
4549
4597
|
value: u?.external_id ?? c.external_id,
|
|
@@ -4557,7 +4605,7 @@ function registerDmCommand(program2) {
|
|
|
4557
4605
|
}
|
|
4558
4606
|
let recipientExtId = recipient;
|
|
4559
4607
|
if (recipient.includes("@")) {
|
|
4560
|
-
const contacts = await
|
|
4608
|
+
const contacts = await sdk.contacts.listContacts(arbi);
|
|
4561
4609
|
const match = contacts.find((c) => c.email === recipient);
|
|
4562
4610
|
if (!match) {
|
|
4563
4611
|
error(`No contact found with email: ${recipient}`);
|
|
@@ -4566,7 +4614,7 @@ function registerDmCommand(program2) {
|
|
|
4566
4614
|
}
|
|
4567
4615
|
recipientExtId = match.user?.external_id ?? match.external_id;
|
|
4568
4616
|
}
|
|
4569
|
-
const data = await
|
|
4617
|
+
const data = await sdk.dm.sendDM(arbi, [{ recipient_ext_id: recipientExtId, content }]);
|
|
4570
4618
|
for (const n of data) {
|
|
4571
4619
|
success(`Sent: ${n.external_id} \u2192 ${n.recipient.email}`);
|
|
4572
4620
|
}
|
|
@@ -4577,7 +4625,7 @@ function registerDmCommand(program2) {
|
|
|
4577
4625
|
const { arbi } = await resolveAuth();
|
|
4578
4626
|
let msgIds = ids && ids.length > 0 ? ids : void 0;
|
|
4579
4627
|
if (!msgIds) {
|
|
4580
|
-
const data2 = await
|
|
4628
|
+
const data2 = await sdk.dm.listDMs(arbi);
|
|
4581
4629
|
const unread = data2.filter((m) => !m.read);
|
|
4582
4630
|
if (unread.length === 0) {
|
|
4583
4631
|
console.log("No unread messages.");
|
|
@@ -4587,7 +4635,7 @@ function registerDmCommand(program2) {
|
|
|
4587
4635
|
"Select messages to mark as read",
|
|
4588
4636
|
unread.map((m) => {
|
|
4589
4637
|
const s = m.sender;
|
|
4590
|
-
const from =
|
|
4638
|
+
const from = sdk.formatUserName(s) || s?.email || "";
|
|
4591
4639
|
return {
|
|
4592
4640
|
name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
|
|
4593
4641
|
value: m.external_id
|
|
@@ -4596,7 +4644,7 @@ function registerDmCommand(program2) {
|
|
|
4596
4644
|
);
|
|
4597
4645
|
if (msgIds.length === 0) return;
|
|
4598
4646
|
}
|
|
4599
|
-
const data = await
|
|
4647
|
+
const data = await sdk.dm.markRead(arbi, msgIds);
|
|
4600
4648
|
success(`Marked ${data.length} message(s) as read.`);
|
|
4601
4649
|
})()
|
|
4602
4650
|
);
|
|
@@ -4605,7 +4653,7 @@ function registerDmCommand(program2) {
|
|
|
4605
4653
|
const { arbi } = await resolveAuth();
|
|
4606
4654
|
let msgIds = ids && ids.length > 0 ? ids : void 0;
|
|
4607
4655
|
if (!msgIds) {
|
|
4608
|
-
const data = await
|
|
4656
|
+
const data = await sdk.dm.listDMs(arbi);
|
|
4609
4657
|
if (data.length === 0) {
|
|
4610
4658
|
console.log("No messages found.");
|
|
4611
4659
|
return;
|
|
@@ -4614,7 +4662,7 @@ function registerDmCommand(program2) {
|
|
|
4614
4662
|
"Select messages to delete",
|
|
4615
4663
|
data.map((m) => {
|
|
4616
4664
|
const s = m.sender;
|
|
4617
|
-
const from =
|
|
4665
|
+
const from = sdk.formatUserName(s) || s?.email || "";
|
|
4618
4666
|
return {
|
|
4619
4667
|
name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
|
|
4620
4668
|
value: m.external_id
|
|
@@ -4623,7 +4671,7 @@ function registerDmCommand(program2) {
|
|
|
4623
4671
|
);
|
|
4624
4672
|
if (msgIds.length === 0) return;
|
|
4625
4673
|
}
|
|
4626
|
-
await
|
|
4674
|
+
await sdk.dm.deleteDMs(arbi, msgIds);
|
|
4627
4675
|
success(`Deleted ${msgIds.length} message(s).`);
|
|
4628
4676
|
})()
|
|
4629
4677
|
);
|
|
@@ -4632,7 +4680,7 @@ function registerDmCommand(program2) {
|
|
|
4632
4680
|
});
|
|
4633
4681
|
}
|
|
4634
4682
|
async function fetchTagChoices(arbi, workspaceId) {
|
|
4635
|
-
const data = await
|
|
4683
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4636
4684
|
if (data.length === 0) {
|
|
4637
4685
|
console.log("No tags found.");
|
|
4638
4686
|
process.exit(0);
|
|
@@ -4651,7 +4699,7 @@ function registerTagsCommand(program2) {
|
|
|
4651
4699
|
tags.command("list").description("List tags in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4652
4700
|
(opts) => runAction(async () => {
|
|
4653
4701
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4654
|
-
const data = await
|
|
4702
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4655
4703
|
if (data.length === 0) {
|
|
4656
4704
|
console.log("No tags found.");
|
|
4657
4705
|
return;
|
|
@@ -4695,9 +4743,8 @@ function registerTagsCommand(program2) {
|
|
|
4695
4743
|
]);
|
|
4696
4744
|
const instruction = interactive ? opts.instruction ?? (await promptInput("Instruction (optional)", false) || null) : opts.instruction ?? null;
|
|
4697
4745
|
const shared = interactive ? opts.shared || await promptConfirm("Shared?", false) : opts.shared ?? false;
|
|
4698
|
-
const data = await
|
|
4746
|
+
const data = await sdk.tags.createTag(arbi, {
|
|
4699
4747
|
name,
|
|
4700
|
-
workspaceId,
|
|
4701
4748
|
tagType: { type: tagType, options: [] },
|
|
4702
4749
|
instruction,
|
|
4703
4750
|
shared
|
|
@@ -4712,7 +4759,7 @@ function registerTagsCommand(program2) {
|
|
|
4712
4759
|
const { choices } = await fetchTagChoices(arbi, workspaceId);
|
|
4713
4760
|
id = await promptSelect("Select tag to delete", choices);
|
|
4714
4761
|
}
|
|
4715
|
-
const data = await
|
|
4762
|
+
const data = await sdk.tags.deleteTag(arbi, id);
|
|
4716
4763
|
success(data?.detail ?? `Deleted tag ${id}`);
|
|
4717
4764
|
})()
|
|
4718
4765
|
);
|
|
@@ -4738,7 +4785,7 @@ function registerTagsCommand(program2) {
|
|
|
4738
4785
|
body = { [field]: await promptInput(field.charAt(0).toUpperCase() + field.slice(1)) };
|
|
4739
4786
|
}
|
|
4740
4787
|
}
|
|
4741
|
-
const data = await
|
|
4788
|
+
const data = await sdk.tags.updateTag(arbi, id, body);
|
|
4742
4789
|
success(`Updated: ${data.name} (${ref(data.external_id)})`);
|
|
4743
4790
|
})()
|
|
4744
4791
|
);
|
|
@@ -4747,7 +4794,7 @@ function registerTagsCommand(program2) {
|
|
|
4747
4794
|
});
|
|
4748
4795
|
}
|
|
4749
4796
|
async function pickTag(arbi, workspaceId, message = "Select tag") {
|
|
4750
|
-
const data = await
|
|
4797
|
+
const data = await sdk.tags.listTags(arbi);
|
|
4751
4798
|
if (data.length === 0) {
|
|
4752
4799
|
console.log("No tags found.");
|
|
4753
4800
|
process.exit(0);
|
|
@@ -4762,7 +4809,7 @@ async function pickTag(arbi, workspaceId, message = "Select tag") {
|
|
|
4762
4809
|
);
|
|
4763
4810
|
}
|
|
4764
4811
|
async function pickDocs(arbi, workspaceId, message = "Select documents") {
|
|
4765
|
-
const data = await
|
|
4812
|
+
const data = await sdk.documents.listDocuments(arbi);
|
|
4766
4813
|
if (data.length === 0) {
|
|
4767
4814
|
console.log("No documents found.");
|
|
4768
4815
|
process.exit(0);
|
|
@@ -4784,7 +4831,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4784
4831
|
if (!docIds || docIds.length === 0)
|
|
4785
4832
|
docIds = await pickDocs(arbi, workspaceId, "Select documents to tag");
|
|
4786
4833
|
if (docIds.length === 0) return;
|
|
4787
|
-
const data = await
|
|
4834
|
+
const data = await sdk.doctags.assignDocTags(arbi, tagId, docIds, opts?.note);
|
|
4788
4835
|
success(`Created ${data.length} doctag(s) for tag ${tagId}.`);
|
|
4789
4836
|
})()
|
|
4790
4837
|
);
|
|
@@ -4795,7 +4842,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4795
4842
|
if (!docIds || docIds.length === 0)
|
|
4796
4843
|
docIds = await pickDocs(arbi, workspaceId, "Select documents to untag");
|
|
4797
4844
|
if (docIds.length === 0) return;
|
|
4798
|
-
await
|
|
4845
|
+
await sdk.doctags.removeDocTags(arbi, tagId, docIds);
|
|
4799
4846
|
success(`Removed tag ${tagId} from ${docIds.length} document(s).`);
|
|
4800
4847
|
})()
|
|
4801
4848
|
);
|
|
@@ -4806,7 +4853,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4806
4853
|
if (opts.tags) {
|
|
4807
4854
|
tagIds = opts.tags.split(",").map((s) => s.trim());
|
|
4808
4855
|
} else {
|
|
4809
|
-
const data2 = await
|
|
4856
|
+
const data2 = await sdk.tags.listTags(arbi);
|
|
4810
4857
|
if (data2.length === 0) {
|
|
4811
4858
|
console.log("No tags found.");
|
|
4812
4859
|
return;
|
|
@@ -4827,7 +4874,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4827
4874
|
docIds = await pickDocs(arbi, workspaceId, "Select documents for AI tagging");
|
|
4828
4875
|
if (docIds.length === 0) return;
|
|
4829
4876
|
}
|
|
4830
|
-
const data = await
|
|
4877
|
+
const data = await sdk.doctags.generateDocTags(arbi, tagIds, docIds);
|
|
4831
4878
|
console.log(
|
|
4832
4879
|
`Generating doctags for ${data.doc_ext_ids.length} doc(s) with ${data.tag_ext_ids.length} tag(s).`
|
|
4833
4880
|
);
|
|
@@ -4835,7 +4882,7 @@ function registerDoctagsCommand(program2) {
|
|
|
4835
4882
|
);
|
|
4836
4883
|
}
|
|
4837
4884
|
async function pickConversation(arbi, workspaceId, message = "Select conversation") {
|
|
4838
|
-
const data = await
|
|
4885
|
+
const data = await sdk.conversations.listConversations(arbi);
|
|
4839
4886
|
if (data.length === 0) {
|
|
4840
4887
|
console.log("No conversations found.");
|
|
4841
4888
|
process.exit(0);
|
|
@@ -4854,7 +4901,7 @@ function registerConversationsCommand(program2) {
|
|
|
4854
4901
|
conv.command("list").description("List conversations in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
|
|
4855
4902
|
(opts) => runAction(async () => {
|
|
4856
4903
|
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4857
|
-
const data = await
|
|
4904
|
+
const data = await sdk.conversations.listConversations(arbi);
|
|
4858
4905
|
if (data.length === 0) {
|
|
4859
4906
|
console.log("No conversations found.");
|
|
4860
4907
|
return;
|
|
@@ -4874,7 +4921,7 @@ function registerConversationsCommand(program2) {
|
|
|
4874
4921
|
(conversationId) => runAction(async () => {
|
|
4875
4922
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4876
4923
|
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4877
|
-
const data = await
|
|
4924
|
+
const data = await sdk.conversations.getConversationThreads(arbi, conversationId);
|
|
4878
4925
|
console.log(JSON.stringify(data, null, 2));
|
|
4879
4926
|
})()
|
|
4880
4927
|
);
|
|
@@ -4887,7 +4934,7 @@ function registerConversationsCommand(program2) {
|
|
|
4887
4934
|
workspaceId,
|
|
4888
4935
|
"Select conversation to delete"
|
|
4889
4936
|
);
|
|
4890
|
-
const data = await
|
|
4937
|
+
const data = await sdk.conversations.deleteConversation(arbi, conversationId);
|
|
4891
4938
|
success(data?.detail ?? `Deleted conversation ${conversationId}`);
|
|
4892
4939
|
})()
|
|
4893
4940
|
);
|
|
@@ -4896,7 +4943,7 @@ function registerConversationsCommand(program2) {
|
|
|
4896
4943
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4897
4944
|
if (!conversationId)
|
|
4898
4945
|
conversationId = await pickConversation(arbi, workspaceId, "Select conversation to share");
|
|
4899
|
-
const data = await
|
|
4946
|
+
const data = await sdk.conversations.shareConversation(arbi, conversationId);
|
|
4900
4947
|
success(data?.detail ?? `Shared conversation ${conversationId}`);
|
|
4901
4948
|
})()
|
|
4902
4949
|
);
|
|
@@ -4905,39 +4952,21 @@ function registerConversationsCommand(program2) {
|
|
|
4905
4952
|
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4906
4953
|
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4907
4954
|
if (!title) title = await promptInput("New title");
|
|
4908
|
-
const data = await
|
|
4955
|
+
const data = await sdk.conversations.updateConversationTitle(arbi, conversationId, title);
|
|
4909
4956
|
success(data?.detail ?? `Updated title to: ${title}`);
|
|
4910
4957
|
})()
|
|
4911
4958
|
);
|
|
4912
|
-
conv.command("add-user [conversation-id] [user-id]").description("Add a user to a conversation (interactive if no args)").action(
|
|
4913
|
-
(conversationId, userId) => runAction(async () => {
|
|
4914
|
-
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4915
|
-
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4916
|
-
if (!userId) userId = await promptInput("User ext_id or email");
|
|
4917
|
-
const data = await core.conversations.addConversationUser(arbi, conversationId, userId);
|
|
4918
|
-
success(data?.detail ?? `Added user ${userId} to conversation`);
|
|
4919
|
-
})()
|
|
4920
|
-
);
|
|
4921
|
-
conv.command("remove-user [conversation-id] [user-id]").description("Remove a user from a conversation (interactive if no args)").action(
|
|
4922
|
-
(conversationId, userId) => runAction(async () => {
|
|
4923
|
-
const { arbi, workspaceId } = await resolveWorkspace();
|
|
4924
|
-
if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
|
|
4925
|
-
if (!userId) userId = await promptInput("User ext_id");
|
|
4926
|
-
const data = await core.conversations.removeConversationUser(arbi, conversationId, userId);
|
|
4927
|
-
success(data?.detail ?? `Removed user ${userId} from conversation`);
|
|
4928
|
-
})()
|
|
4929
|
-
);
|
|
4930
4959
|
conv.command("message <message-id>").description("Get message details").action(
|
|
4931
4960
|
(messageId) => runAction(async () => {
|
|
4932
4961
|
const { arbi } = await resolveWorkspace();
|
|
4933
|
-
const data = await
|
|
4962
|
+
const data = await sdk.conversations.getMessage(arbi, messageId);
|
|
4934
4963
|
console.log(JSON.stringify(data, null, 2));
|
|
4935
4964
|
})()
|
|
4936
4965
|
);
|
|
4937
4966
|
conv.command("delete-message <message-id>").description("Delete a message and its descendants").action(
|
|
4938
4967
|
(messageId) => runAction(async () => {
|
|
4939
4968
|
const { arbi } = await resolveAuth();
|
|
4940
|
-
const data = await
|
|
4969
|
+
const data = await sdk.conversations.deleteMessage(arbi, messageId);
|
|
4941
4970
|
success(data?.detail ?? `Deleted message ${messageId}`);
|
|
4942
4971
|
})()
|
|
4943
4972
|
);
|
|
@@ -4950,7 +4979,7 @@ function registerSettingsCommand(program2) {
|
|
|
4950
4979
|
settings.command("get").description("Show current user settings").action(
|
|
4951
4980
|
runAction(async () => {
|
|
4952
4981
|
const { arbi } = await resolveAuth();
|
|
4953
|
-
const data = await
|
|
4982
|
+
const data = await sdk.settings.getSettings(arbi);
|
|
4954
4983
|
console.log(JSON.stringify(data, null, 2));
|
|
4955
4984
|
})
|
|
4956
4985
|
);
|
|
@@ -4958,7 +4987,7 @@ function registerSettingsCommand(program2) {
|
|
|
4958
4987
|
(json) => runAction(async () => {
|
|
4959
4988
|
const body = parseJsonArg(json, `arbi settings set '{"hide_online_status": true}'`);
|
|
4960
4989
|
const { arbi } = await resolveAuth();
|
|
4961
|
-
await
|
|
4990
|
+
await sdk.settings.updateSettings(arbi, body);
|
|
4962
4991
|
success("Settings updated.");
|
|
4963
4992
|
})()
|
|
4964
4993
|
);
|
|
@@ -4976,7 +5005,7 @@ var MODEL_SECTIONS = [
|
|
|
4976
5005
|
"ArtifactLLM"
|
|
4977
5006
|
];
|
|
4978
5007
|
async function pickConfig(arbi, message = "Select configuration") {
|
|
4979
|
-
const data = await
|
|
5008
|
+
const data = await sdk.agentconfig.listConfigs(arbi);
|
|
4980
5009
|
if (data.versions.length === 0) {
|
|
4981
5010
|
console.log("No saved configurations found.");
|
|
4982
5011
|
process.exit(0);
|
|
@@ -4991,7 +5020,7 @@ async function pickConfig(arbi, message = "Select configuration") {
|
|
|
4991
5020
|
);
|
|
4992
5021
|
}
|
|
4993
5022
|
async function fetchModels(arbi) {
|
|
4994
|
-
const data = await
|
|
5023
|
+
const data = await sdk.agentconfig.getModels(arbi);
|
|
4995
5024
|
return data.models.map((m) => ({
|
|
4996
5025
|
name: `${m.model_name} (${m.provider ?? m.api_type})`,
|
|
4997
5026
|
value: m.model_name,
|
|
@@ -5113,7 +5142,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5113
5142
|
ac.command("list").description("List saved configuration versions").action(
|
|
5114
5143
|
runAction(async () => {
|
|
5115
5144
|
const { arbi } = await resolveAuth();
|
|
5116
|
-
const data = await
|
|
5145
|
+
const data = await sdk.agentconfig.listConfigs(arbi);
|
|
5117
5146
|
if (data.versions.length === 0) {
|
|
5118
5147
|
console.log("No saved configurations.");
|
|
5119
5148
|
return;
|
|
@@ -5144,7 +5173,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5144
5173
|
configId = await pickConfig(arbi);
|
|
5145
5174
|
}
|
|
5146
5175
|
}
|
|
5147
|
-
const data = await
|
|
5176
|
+
const data = await sdk.agentconfig.getConfig(arbi, configId);
|
|
5148
5177
|
console.log(JSON.stringify(data, null, 2));
|
|
5149
5178
|
})()
|
|
5150
5179
|
);
|
|
@@ -5163,7 +5192,7 @@ function registerAgentconfigCommand(program2) {
|
|
|
5163
5192
|
}
|
|
5164
5193
|
if (opts?.tag) body.tag_ext_id = opts.tag;
|
|
5165
5194
|
if (opts?.message) body.parent_message_ext_id = opts.message;
|
|
5166
|
-
const data = await
|
|
5195
|
+
const data = await sdk.agentconfig.saveConfig(arbi, body);
|
|
5167
5196
|
success(`Saved: ${data.title || "(untitled)"} (${ref(data.external_id)})`);
|
|
5168
5197
|
})()
|
|
5169
5198
|
);
|
|
@@ -5171,14 +5200,14 @@ function registerAgentconfigCommand(program2) {
|
|
|
5171
5200
|
(configId) => runAction(async () => {
|
|
5172
5201
|
const { arbi } = await resolveAuth();
|
|
5173
5202
|
if (!configId) configId = await pickConfig(arbi, "Select configuration to delete");
|
|
5174
|
-
const data = await
|
|
5203
|
+
const data = await sdk.agentconfig.deleteConfig(arbi, configId);
|
|
5175
5204
|
success(data.detail);
|
|
5176
5205
|
})()
|
|
5177
5206
|
);
|
|
5178
5207
|
ac.command("schema").description("Show JSON schema for all configuration models").action(
|
|
5179
5208
|
runAction(async () => {
|
|
5180
5209
|
const { arbi } = await resolveAuth();
|
|
5181
|
-
const data = await
|
|
5210
|
+
const data = await sdk.agentconfig.getSchema(arbi);
|
|
5182
5211
|
console.log(JSON.stringify(data, null, 2));
|
|
5183
5212
|
})
|
|
5184
5213
|
);
|
|
@@ -5190,7 +5219,7 @@ function registerHealthCommand(program2) {
|
|
|
5190
5219
|
program2.command("health").description("Show server health status").action(
|
|
5191
5220
|
runAction(async () => {
|
|
5192
5221
|
const { arbi } = await resolveAuth();
|
|
5193
|
-
const data = await
|
|
5222
|
+
const data = await sdk.health.getHealth(arbi);
|
|
5194
5223
|
label("Status:", status(data.status));
|
|
5195
5224
|
if (data.backend_git_hash) label("Backend:", data.backend_git_hash);
|
|
5196
5225
|
if (data.frontend_docker_version) label("Frontend:", data.frontend_docker_version);
|
|
@@ -5212,7 +5241,7 @@ Models (${data.models_health.application}):`);
|
|
|
5212
5241
|
program2.command("models").description("List available AI models").action(
|
|
5213
5242
|
runAction(async () => {
|
|
5214
5243
|
const { arbi } = await resolveAuth();
|
|
5215
|
-
const data = await
|
|
5244
|
+
const data = await sdk.health.getHealthModels(arbi);
|
|
5216
5245
|
if (data.models.length === 0) {
|
|
5217
5246
|
console.log("No models available.");
|
|
5218
5247
|
return;
|
|
@@ -5284,7 +5313,7 @@ console.info = (...args) => {
|
|
|
5284
5313
|
_origInfo(...args);
|
|
5285
5314
|
};
|
|
5286
5315
|
var program = new commander.Command();
|
|
5287
|
-
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.
|
|
5316
|
+
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.10");
|
|
5288
5317
|
registerConfigCommand(program);
|
|
5289
5318
|
registerLoginCommand(program);
|
|
5290
5319
|
registerRegisterCommand(program);
|