@arbidocs/cli 0.3.9 → 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/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 core = require('@arbidocs/core');
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 sdk = require('@arbidocs/sdk');
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 core.FileConfigStore();
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 core.ArbiError) {
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.9";
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
- sections.push(line);
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.9") return;
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.9"} \u2192 ${latest}). Updating...`);
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.9", latest);
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.9"} \u2192 ${latest}).
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.9") {
3578
+ if (cached && cached.latest !== "0.3.10") {
3569
3579
  warn(
3570
- `Your arbi version is out of date (${"0.3.9"} \u2192 ${cached.latest}). Run "arbi update".`
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,7 +3591,8 @@ 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 core.performPasswordLogin(config, email, pw, store);
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
3598
  success(`Logged in as ${email}`);
@@ -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 = core.formatWorkspaceChoices(wsList);
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: ${core.getErrorMessage(err)}`);
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 = sdk.createArbiClient({
3660
+ const arbi = client.createArbiClient({
3650
3661
  baseUrl: config.baseUrl,
3651
3662
  deploymentDomain: config.deploymentDomain,
3652
3663
  credentials: "omit"
@@ -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: ${core.getErrorMessage(err)}`);
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 = sdk.createArbiClient({
3736
+ const arbi = client.createArbiClient({
3726
3737
  baseUrl: config.baseUrl,
3727
3738
  deploymentDomain: config.deploymentDomain,
3728
3739
  credentials: "omit"
@@ -3757,19 +3768,19 @@ async function nonInteractiveRegister(config, opts) {
3757
3768
  });
3758
3769
  success(`Registered: ${email}`);
3759
3770
  } catch (err) {
3760
- error(`Registration failed: ${core.getErrorMessage(err)}`);
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 core.performPasswordLogin(config, email, password2, store);
3777
+ const { arbi } = await sdk.performPasswordLogin(config, email, password2, store);
3767
3778
  success(`Logged in as ${email}`);
3768
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 core.workspaces.createWorkspace(arbi, "My First Workspace");
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 = core.formatWorkspaceChoices(wsList);
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: ${core.getErrorMessage(err)}`);
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 core.connectWithReconnect({
3849
+ activeConnection = await sdk.connectWithReconnect({
3838
3850
  baseUrl,
3839
3851
  accessToken,
3840
3852
  onMessage: (msg) => {
3841
- const { text, level } = core.formatWsMessage(msg);
3853
+ const { text, level } = sdk.formatWsMessage(msg);
3842
3854
  process.stderr.write(`
3843
3855
  ${colorize(level, `[${timestamp()}] ${text}`)}
3844
3856
  `);
@@ -3884,7 +3896,7 @@ function runAction(fn) {
3884
3896
  await fn();
3885
3897
  process.exit(0);
3886
3898
  } catch (err) {
3887
- error(`Error: ${core.getErrorMessage(err)}`);
3899
+ error(`Error: ${sdk.getErrorMessage(err)}`);
3888
3900
  hintUpdateOnError();
3889
3901
  process.exit(1);
3890
3902
  }
@@ -3892,9 +3904,9 @@ function runAction(fn) {
3892
3904
  }
3893
3905
  async function resolveAuth() {
3894
3906
  try {
3895
- return await core.resolveAuth(store);
3907
+ return await sdk.resolveAuth(store);
3896
3908
  } catch (err) {
3897
- if (err instanceof core.ArbiError) {
3909
+ if (err instanceof sdk.ArbiError) {
3898
3910
  error(err.message);
3899
3911
  process.exit(1);
3900
3912
  }
@@ -3903,14 +3915,14 @@ async function resolveAuth() {
3903
3915
  }
3904
3916
  async function resolveWorkspace(workspaceOpt) {
3905
3917
  try {
3906
- const ctx = await core.resolveWorkspace(store, workspaceOpt);
3918
+ const ctx = await sdk.resolveWorkspace(store, workspaceOpt);
3907
3919
  if (getConfig()?.notifications) {
3908
3920
  startBackgroundNotifications(ctx.config.baseUrl, ctx.accessToken).catch(() => {
3909
3921
  });
3910
3922
  }
3911
3923
  return ctx;
3912
3924
  } catch (err) {
3913
- if (err instanceof core.ArbiError) {
3925
+ if (err instanceof sdk.ArbiError) {
3914
3926
  error(err.message);
3915
3927
  process.exit(1);
3916
3928
  }
@@ -3942,7 +3954,7 @@ function registerWorkspacesCommand(program2) {
3942
3954
  program2.command("workspaces").description("List workspaces").action(
3943
3955
  runAction(async () => {
3944
3956
  const { arbi } = await resolveAuth();
3945
- const data = await core.workspaces.listWorkspaces(arbi);
3957
+ const data = await sdk.workspaces.listWorkspaces(arbi);
3946
3958
  if (data.length === 0) {
3947
3959
  console.log("No workspaces found.");
3948
3960
  return;
@@ -3970,7 +3982,7 @@ function registerWorkspacesCommand(program2) {
3970
3982
  workspace.command("select [id]").description("Select active workspace (interactive picker if no ID given)").action(
3971
3983
  (id) => runAction(async () => {
3972
3984
  const { arbi } = await resolveAuth();
3973
- const data = await core.workspaces.listWorkspaces(arbi);
3985
+ const data = await sdk.workspaces.listWorkspaces(arbi);
3974
3986
  if (data.length === 0) {
3975
3987
  console.log("No workspaces found.");
3976
3988
  return;
@@ -3986,10 +3998,11 @@ function registerWorkspacesCommand(program2) {
3986
3998
  }
3987
3999
  selectedId = id;
3988
4000
  } else {
3989
- const choices = core.formatWorkspaceChoices(data);
4001
+ const choices = sdk.formatWorkspaceChoices(data);
3990
4002
  selectedId = await promptSelect("Select workspace", choices);
3991
4003
  }
3992
4004
  updateConfig({ selectedWorkspaceId: selectedId });
4005
+ clearChatSession();
3993
4006
  const ws = data.find((w) => w.external_id === selectedId);
3994
4007
  success(`Selected: ${ws.name} (${ref(selectedId)})`);
3995
4008
  })()
@@ -3997,7 +4010,7 @@ function registerWorkspacesCommand(program2) {
3997
4010
  workspace.command("create <name>").description("Create a new workspace").option("-d, --description <text>", "Workspace description").option("--public", "Make workspace public", false).action(
3998
4011
  (name, opts) => runAction(async () => {
3999
4012
  const { arbi } = await resolveAuth();
4000
- const data = await core.workspaces.createWorkspace(
4013
+ const data = await sdk.workspaces.createWorkspace(
4001
4014
  arbi,
4002
4015
  name,
4003
4016
  opts.description,
@@ -4014,7 +4027,7 @@ function registerWorkspacesCommand(program2) {
4014
4027
  error("No workspace ID given and no workspace selected. Run: arbi workspace select");
4015
4028
  process.exit(1);
4016
4029
  }
4017
- await core.workspaces.deleteWorkspaces(arbi, [targetId]);
4030
+ await sdk.workspaces.deleteWorkspaces(arbi, [targetId]);
4018
4031
  success(`Deleted workspace ${targetId}`);
4019
4032
  })()
4020
4033
  );
@@ -4022,14 +4035,14 @@ function registerWorkspacesCommand(program2) {
4022
4035
  (id, json) => runAction(async () => {
4023
4036
  const body = parseJsonArg(json, `arbi workspace update wrk-123 '{"name": "New Name"}'`);
4024
4037
  const { arbi } = await resolveWorkspace(id);
4025
- const data = await core.workspaces.updateWorkspace(arbi, body);
4038
+ const data = await sdk.workspaces.updateWorkspace(arbi, body);
4026
4039
  success(`Updated: ${data.name} (${ref(data.external_id)})`);
4027
4040
  })()
4028
4041
  );
4029
4042
  workspace.command("users").description("List users in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
4030
4043
  (opts) => runAction(async () => {
4031
4044
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4032
- const data = await core.workspaces.listWorkspaceUsers(arbi);
4045
+ const data = await sdk.workspaces.listWorkspaceUsers(arbi);
4033
4046
  if (data.length === 0) {
4034
4047
  console.log("No users found.");
4035
4048
  return;
@@ -4066,21 +4079,21 @@ function registerWorkspacesCommand(program2) {
4066
4079
  (emails, opts) => runAction(async () => {
4067
4080
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4068
4081
  const role = opts.role ?? "collaborator";
4069
- const data = await core.workspaces.addWorkspaceUsers(arbi, emails, role);
4082
+ const data = await sdk.workspaces.addWorkspaceUsers(arbi, emails, role);
4070
4083
  for (const u of data) success(`Added: ${u.user.email} as ${u.role}`);
4071
4084
  })()
4072
4085
  );
4073
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(
4074
4087
  (userIds, opts) => runAction(async () => {
4075
4088
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4076
- await core.workspaces.removeWorkspaceUsers(arbi, userIds);
4089
+ await sdk.workspaces.removeWorkspaceUsers(arbi, userIds);
4077
4090
  success(`Removed ${userIds.length} user(s).`);
4078
4091
  })()
4079
4092
  );
4080
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(
4081
4094
  (role, userIds, opts) => runAction(async () => {
4082
4095
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4083
- const data = await core.workspaces.setUserRole(
4096
+ const data = await sdk.workspaces.setUserRole(
4084
4097
  arbi,
4085
4098
  userIds,
4086
4099
  role
@@ -4092,19 +4105,19 @@ function registerWorkspacesCommand(program2) {
4092
4105
  (targetId, docIds, opts) => runAction(async () => {
4093
4106
  const { arbi, loginResult } = await resolveWorkspace(opts.workspace);
4094
4107
  const signingPrivateKeyBase64 = arbi.crypto.bytesToBase64(loginResult.signingPrivateKey);
4095
- const wsList = await core.workspaces.listWorkspaces(arbi);
4108
+ const wsList = await sdk.workspaces.listWorkspaces(arbi);
4096
4109
  const targetWs = wsList.find((w) => w.external_id === targetId);
4097
4110
  if (!targetWs || !targetWs.wrapped_key) {
4098
4111
  error(`Target workspace ${targetId} not found or has no encryption key`);
4099
4112
  process.exit(1);
4100
4113
  }
4101
- const targetKey = await core.generateEncryptedWorkspaceKey(
4114
+ const targetKey = await sdk.generateEncryptedWorkspaceKey(
4102
4115
  arbi,
4103
4116
  targetWs.wrapped_key,
4104
4117
  loginResult.serverSessionKey,
4105
4118
  signingPrivateKeyBase64
4106
4119
  );
4107
- const data = await core.workspaces.copyDocuments(arbi, targetId, docIds, targetKey);
4120
+ const data = await sdk.workspaces.copyDocuments(arbi, targetId, docIds, targetKey);
4108
4121
  success(`${data.detail} (${data.documents_copied} document(s) copied)`);
4109
4122
  })()
4110
4123
  );
@@ -4128,7 +4141,7 @@ function statusSymbol(status2) {
4128
4141
  }
4129
4142
  }
4130
4143
  async function fetchDocChoices(arbi, workspaceId) {
4131
- const data = await core.documents.listDocuments(arbi);
4144
+ const data = await sdk.documents.listDocuments(arbi);
4132
4145
  if (data.length === 0) {
4133
4146
  console.log("No documents found.");
4134
4147
  process.exit(0);
@@ -4143,7 +4156,7 @@ function registerDocsCommand(program2) {
4143
4156
  program2.command("docs").description("List documents in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
4144
4157
  (opts) => runAction(async () => {
4145
4158
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4146
- const data = await core.documents.listDocuments(arbi);
4159
+ const data = await sdk.documents.listDocuments(arbi);
4147
4160
  if (data.length === 0) {
4148
4161
  console.log("No documents found.");
4149
4162
  return;
@@ -4192,7 +4205,7 @@ function registerDocsCommand(program2) {
4192
4205
  if (selected.length === 0) return;
4193
4206
  docIds = selected;
4194
4207
  }
4195
- const data = await core.documents.getDocuments(arbi, docIds);
4208
+ const data = await sdk.documents.getDocuments(arbi, docIds);
4196
4209
  console.log(JSON.stringify(data, null, 2));
4197
4210
  })()
4198
4211
  );
@@ -4206,7 +4219,7 @@ function registerDocsCommand(program2) {
4206
4219
  if (selected.length === 0) return;
4207
4220
  docIds = selected;
4208
4221
  }
4209
- await core.documents.deleteDocuments(arbi, docIds);
4222
+ await sdk.documents.deleteDocuments(arbi, docIds);
4210
4223
  success(`Deleted ${docIds.length} document(s).`);
4211
4224
  })()
4212
4225
  );
@@ -4216,7 +4229,7 @@ function registerDocsCommand(program2) {
4216
4229
  const parsed = parseJsonArg(json, `arbi doc update '[{"external_id": "doc-123", "shared": true}]'`);
4217
4230
  const docs = Array.isArray(parsed) ? parsed : parsed.documents;
4218
4231
  const { arbi } = await resolveWorkspace();
4219
- const data = await core.documents.updateDocuments(arbi, docs);
4232
+ const data = await sdk.documents.updateDocuments(arbi, docs);
4220
4233
  success(`Updated ${data.length} document(s).`);
4221
4234
  } else {
4222
4235
  const { arbi, workspaceId } = await resolveWorkspace();
@@ -4240,7 +4253,7 @@ function registerDocsCommand(program2) {
4240
4253
  } else {
4241
4254
  value = await promptInput(`${field.charAt(0).toUpperCase() + field.slice(1)}`);
4242
4255
  }
4243
- const data = await core.documents.updateDocuments(arbi, [
4256
+ const data = await sdk.documents.updateDocuments(arbi, [
4244
4257
  { external_id: docId, [field]: value }
4245
4258
  ]);
4246
4259
  success(`Updated ${data.length} document(s).`);
@@ -4250,7 +4263,7 @@ function registerDocsCommand(program2) {
4250
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(
4251
4264
  (urls, opts) => runAction(async () => {
4252
4265
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4253
- const data = await core.documents.uploadUrl(arbi, urls, workspaceId, opts.shared ?? false);
4266
+ const data = await sdk.documents.uploadUrl(arbi, urls, workspaceId, opts.shared ?? false);
4254
4267
  success(`Uploaded: ${data.doc_ext_ids.join(", ")}`);
4255
4268
  if (data.duplicates && data.duplicates.length > 0) {
4256
4269
  warn(`Duplicates: ${data.duplicates.join(", ")}`);
@@ -4275,7 +4288,7 @@ function registerDocsCommand(program2) {
4275
4288
  error(`Invalid stage: ${stage}. Must be one of: ${validStages.join(", ")}`);
4276
4289
  process.exit(1);
4277
4290
  }
4278
- const data = await core.documents.getParsedContent(
4291
+ const data = await sdk.documents.getParsedContent(
4279
4292
  { baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
4280
4293
  docId,
4281
4294
  stage
@@ -4299,7 +4312,7 @@ function registerUploadCommand(program2) {
4299
4312
  const uploadedDocs = /* @__PURE__ */ new Map();
4300
4313
  const auth = { baseUrl: config.baseUrl, accessToken, workspaceKeyHeader };
4301
4314
  for (const filePath of files) {
4302
- const result = await core.documents.uploadLocalFile(auth, workspaceId, filePath);
4315
+ const result = await sdk.documents.uploadLocalFile(auth, workspaceId, filePath);
4303
4316
  success(`Uploaded: ${result.fileName} (${result.doc_ext_ids.join(", ")})`);
4304
4317
  if (result.duplicates && result.duplicates.length > 0) {
4305
4318
  warn(` Duplicates: ${result.duplicates.join(", ")}`);
@@ -4310,11 +4323,11 @@ function registerUploadCommand(program2) {
4310
4323
  const pending = new Set(uploadedDocs.keys());
4311
4324
  console.log(`
4312
4325
  Watching ${pending.size} document(s)...`);
4313
- const conn = await core.connectWebSocket({
4326
+ const conn = await sdk.connectWebSocket({
4314
4327
  baseUrl: config.baseUrl,
4315
4328
  accessToken,
4316
4329
  onMessage: (msg) => {
4317
- if (sdk.isMessageType(msg, "task_update")) {
4330
+ if (client.isMessageType(msg, "task_update")) {
4318
4331
  if (!pending.has(msg.doc_ext_id)) return;
4319
4332
  console.log(
4320
4333
  ` ${uploadedDocs.get(msg.doc_ext_id) || msg.file_name}: ${status(msg.status)} (${msg.progress}%)`
@@ -4343,7 +4356,7 @@ function registerDownloadCommand(program2) {
4343
4356
  (docId, opts) => runAction(async () => {
4344
4357
  const { arbi, config, accessToken, workspaceKeyHeader, workspaceId } = await resolveWorkspace(opts.workspace);
4345
4358
  if (!docId) {
4346
- const data = await core.documents.listDocuments(arbi);
4359
+ const data = await sdk.documents.listDocuments(arbi);
4347
4360
  if (data.length === 0) {
4348
4361
  console.log("No documents found.");
4349
4362
  return;
@@ -4355,7 +4368,7 @@ function registerDownloadCommand(program2) {
4355
4368
  }));
4356
4369
  docId = await promptSearch("Select document to download", choices);
4357
4370
  }
4358
- const res = await core.documents.downloadDocument(
4371
+ const res = await sdk.documents.downloadDocument(
4359
4372
  { baseUrl: config.baseUrl, accessToken, workspaceKeyHeader },
4360
4373
  docId
4361
4374
  );
@@ -4384,23 +4397,40 @@ function registerAskCommand(program2) {
4384
4397
  clearChatSession();
4385
4398
  session.lastMessageExtId = null;
4386
4399
  }
4387
- const docs = await core.documents.listDocuments(arbi);
4400
+ const docs = await sdk.documents.listDocuments(arbi);
4388
4401
  const docIds = docs.map((d) => d.external_id);
4389
- const res = await core.assistant.queryAssistant({
4390
- baseUrl: config.baseUrl,
4391
- accessToken,
4392
- workspaceKeyHeader,
4393
- workspaceId,
4394
- question,
4395
- docIds,
4396
- previousResponseId: session.lastMessageExtId,
4397
- model: opts.config
4398
- });
4399
- const result = await core.streamSSE(res, {
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, {
4400
4430
  onToken: (content) => process.stdout.write(content),
4401
4431
  onAgentStep: (data) => {
4402
4432
  if (opts.verbose) {
4403
- const focus = data.focus || data.status || "";
4433
+ const focus = data.focus || data.step || "";
4404
4434
  console.error(chalk__default.default.dim(`
4405
4435
  [agent] ${focus}`));
4406
4436
  }
@@ -4433,11 +4463,11 @@ function registerWatchCommand(program2) {
4433
4463
  (opts) => runAction(async () => {
4434
4464
  const { config, accessToken, workspaceId } = await resolveWorkspace(opts.workspace);
4435
4465
  console.log(`Watching workspace ${workspaceId}... (Ctrl+C to stop)`);
4436
- await core.connectWebSocket({
4466
+ await sdk.connectWebSocket({
4437
4467
  baseUrl: config.baseUrl,
4438
4468
  accessToken,
4439
4469
  onMessage: (msg) => {
4440
- const { text, level } = core.formatWsMessage(msg);
4470
+ const { text, level } = sdk.formatWsMessage(msg);
4441
4471
  console.log(colorize2(level, text));
4442
4472
  },
4443
4473
  onClose: (code, reason) => {
@@ -4455,7 +4485,7 @@ function registerContactsCommand(program2) {
4455
4485
  contacts.command("list").description("List all contacts").action(
4456
4486
  runAction(async () => {
4457
4487
  const { arbi } = await resolveAuth();
4458
- const data = await core.contacts.listContacts(arbi);
4488
+ const data = await sdk.contacts.listContacts(arbi);
4459
4489
  if (data.length === 0) {
4460
4490
  console.log("No contacts found.");
4461
4491
  return;
@@ -4466,7 +4496,7 @@ function registerContactsCommand(program2) {
4466
4496
  {
4467
4497
  header: "NAME",
4468
4498
  width: 20,
4469
- value: (r) => core.formatUserName(r.user)
4499
+ value: (r) => sdk.formatUserName(r.user)
4470
4500
  },
4471
4501
  { header: "EMAIL", width: 30, value: (r) => r.email },
4472
4502
  { header: "STATUS", width: 18, value: (r) => r.status }
@@ -4483,7 +4513,7 @@ function registerContactsCommand(program2) {
4483
4513
  emails = input2.split(",").map((e) => e.trim()).filter(Boolean);
4484
4514
  if (emails.length === 0) return;
4485
4515
  }
4486
- const data = await core.contacts.addContacts(arbi, emails);
4516
+ const data = await sdk.contacts.addContacts(arbi, emails);
4487
4517
  for (const c of data) {
4488
4518
  success(`Added: ${c.email} (${c.external_id}) \u2014 ${c.status}`);
4489
4519
  }
@@ -4494,7 +4524,7 @@ function registerContactsCommand(program2) {
4494
4524
  const { arbi } = await resolveAuth();
4495
4525
  let contactIds = ids && ids.length > 0 ? ids : void 0;
4496
4526
  if (!contactIds) {
4497
- const data = await core.contacts.listContacts(arbi);
4527
+ const data = await sdk.contacts.listContacts(arbi);
4498
4528
  if (data.length === 0) {
4499
4529
  console.log("No contacts found.");
4500
4530
  return;
@@ -4502,7 +4532,7 @@ function registerContactsCommand(program2) {
4502
4532
  contactIds = await promptCheckbox(
4503
4533
  "Select contacts to remove",
4504
4534
  data.map((c) => {
4505
- const name = core.formatUserName(c.user);
4535
+ const name = sdk.formatUserName(c.user);
4506
4536
  return {
4507
4537
  name: name ? `${name} (${c.email})` : c.email,
4508
4538
  value: c.external_id
@@ -4511,7 +4541,7 @@ function registerContactsCommand(program2) {
4511
4541
  );
4512
4542
  if (contactIds.length === 0) return;
4513
4543
  }
4514
- await core.contacts.removeContacts(arbi, contactIds);
4544
+ await sdk.contacts.removeContacts(arbi, contactIds);
4515
4545
  success(`Removed ${contactIds.length} contact(s).`);
4516
4546
  })()
4517
4547
  );
@@ -4524,7 +4554,7 @@ function registerDmCommand(program2) {
4524
4554
  dm.command("list").description("List all DMs and notifications").action(
4525
4555
  runAction(async () => {
4526
4556
  const { arbi } = await resolveAuth();
4527
- const data = await core.dm.listDMs(arbi);
4557
+ const data = await sdk.dm.listDMs(arbi);
4528
4558
  if (data.length === 0) {
4529
4559
  console.log("No messages found.");
4530
4560
  return;
@@ -4538,7 +4568,7 @@ function registerDmCommand(program2) {
4538
4568
  width: 22,
4539
4569
  value: (r) => {
4540
4570
  const s = r.sender;
4541
- return core.formatUserName(s) || s?.email || "";
4571
+ return sdk.formatUserName(s) || s?.email || "";
4542
4572
  }
4543
4573
  },
4544
4574
  { header: "READ", width: 6, value: (r) => r.read ? "yes" : "no" },
@@ -4552,7 +4582,7 @@ function registerDmCommand(program2) {
4552
4582
  (recipient, content) => runAction(async () => {
4553
4583
  const { arbi } = await resolveAuth();
4554
4584
  if (!recipient) {
4555
- const contacts = await core.contacts.listContacts(arbi);
4585
+ const contacts = await sdk.contacts.listContacts(arbi);
4556
4586
  if (contacts.length === 0) {
4557
4587
  error("No contacts found. Add contacts first: arbi contacts add <email>");
4558
4588
  process.exit(1);
@@ -4561,7 +4591,7 @@ function registerDmCommand(program2) {
4561
4591
  "Send to",
4562
4592
  contacts.map((c) => {
4563
4593
  const u = c.user;
4564
- const name = core.formatUserName(u);
4594
+ const name = sdk.formatUserName(u);
4565
4595
  return {
4566
4596
  name: name ? `${name} (${c.email})` : c.email,
4567
4597
  value: u?.external_id ?? c.external_id,
@@ -4575,7 +4605,7 @@ function registerDmCommand(program2) {
4575
4605
  }
4576
4606
  let recipientExtId = recipient;
4577
4607
  if (recipient.includes("@")) {
4578
- const contacts = await core.contacts.listContacts(arbi);
4608
+ const contacts = await sdk.contacts.listContacts(arbi);
4579
4609
  const match = contacts.find((c) => c.email === recipient);
4580
4610
  if (!match) {
4581
4611
  error(`No contact found with email: ${recipient}`);
@@ -4584,7 +4614,7 @@ function registerDmCommand(program2) {
4584
4614
  }
4585
4615
  recipientExtId = match.user?.external_id ?? match.external_id;
4586
4616
  }
4587
- const data = await core.dm.sendDM(arbi, [{ recipient_ext_id: recipientExtId, content }]);
4617
+ const data = await sdk.dm.sendDM(arbi, [{ recipient_ext_id: recipientExtId, content }]);
4588
4618
  for (const n of data) {
4589
4619
  success(`Sent: ${n.external_id} \u2192 ${n.recipient.email}`);
4590
4620
  }
@@ -4595,7 +4625,7 @@ function registerDmCommand(program2) {
4595
4625
  const { arbi } = await resolveAuth();
4596
4626
  let msgIds = ids && ids.length > 0 ? ids : void 0;
4597
4627
  if (!msgIds) {
4598
- const data2 = await core.dm.listDMs(arbi);
4628
+ const data2 = await sdk.dm.listDMs(arbi);
4599
4629
  const unread = data2.filter((m) => !m.read);
4600
4630
  if (unread.length === 0) {
4601
4631
  console.log("No unread messages.");
@@ -4605,7 +4635,7 @@ function registerDmCommand(program2) {
4605
4635
  "Select messages to mark as read",
4606
4636
  unread.map((m) => {
4607
4637
  const s = m.sender;
4608
- const from = core.formatUserName(s) || s?.email || "";
4638
+ const from = sdk.formatUserName(s) || s?.email || "";
4609
4639
  return {
4610
4640
  name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
4611
4641
  value: m.external_id
@@ -4614,7 +4644,7 @@ function registerDmCommand(program2) {
4614
4644
  );
4615
4645
  if (msgIds.length === 0) return;
4616
4646
  }
4617
- const data = await core.dm.markRead(arbi, msgIds);
4647
+ const data = await sdk.dm.markRead(arbi, msgIds);
4618
4648
  success(`Marked ${data.length} message(s) as read.`);
4619
4649
  })()
4620
4650
  );
@@ -4623,7 +4653,7 @@ function registerDmCommand(program2) {
4623
4653
  const { arbi } = await resolveAuth();
4624
4654
  let msgIds = ids && ids.length > 0 ? ids : void 0;
4625
4655
  if (!msgIds) {
4626
- const data = await core.dm.listDMs(arbi);
4656
+ const data = await sdk.dm.listDMs(arbi);
4627
4657
  if (data.length === 0) {
4628
4658
  console.log("No messages found.");
4629
4659
  return;
@@ -4632,7 +4662,7 @@ function registerDmCommand(program2) {
4632
4662
  "Select messages to delete",
4633
4663
  data.map((m) => {
4634
4664
  const s = m.sender;
4635
- const from = core.formatUserName(s) || s?.email || "";
4665
+ const from = sdk.formatUserName(s) || s?.email || "";
4636
4666
  return {
4637
4667
  name: `${from}: ${(m.content ?? "").slice(0, 50)}`,
4638
4668
  value: m.external_id
@@ -4641,7 +4671,7 @@ function registerDmCommand(program2) {
4641
4671
  );
4642
4672
  if (msgIds.length === 0) return;
4643
4673
  }
4644
- await core.dm.deleteDMs(arbi, msgIds);
4674
+ await sdk.dm.deleteDMs(arbi, msgIds);
4645
4675
  success(`Deleted ${msgIds.length} message(s).`);
4646
4676
  })()
4647
4677
  );
@@ -4650,7 +4680,7 @@ function registerDmCommand(program2) {
4650
4680
  });
4651
4681
  }
4652
4682
  async function fetchTagChoices(arbi, workspaceId) {
4653
- const data = await core.tags.listTags(arbi);
4683
+ const data = await sdk.tags.listTags(arbi);
4654
4684
  if (data.length === 0) {
4655
4685
  console.log("No tags found.");
4656
4686
  process.exit(0);
@@ -4669,7 +4699,7 @@ function registerTagsCommand(program2) {
4669
4699
  tags.command("list").description("List tags in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
4670
4700
  (opts) => runAction(async () => {
4671
4701
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4672
- const data = await core.tags.listTags(arbi);
4702
+ const data = await sdk.tags.listTags(arbi);
4673
4703
  if (data.length === 0) {
4674
4704
  console.log("No tags found.");
4675
4705
  return;
@@ -4713,7 +4743,7 @@ function registerTagsCommand(program2) {
4713
4743
  ]);
4714
4744
  const instruction = interactive ? opts.instruction ?? (await promptInput("Instruction (optional)", false) || null) : opts.instruction ?? null;
4715
4745
  const shared = interactive ? opts.shared || await promptConfirm("Shared?", false) : opts.shared ?? false;
4716
- const data = await core.tags.createTag(arbi, {
4746
+ const data = await sdk.tags.createTag(arbi, {
4717
4747
  name,
4718
4748
  tagType: { type: tagType, options: [] },
4719
4749
  instruction,
@@ -4729,7 +4759,7 @@ function registerTagsCommand(program2) {
4729
4759
  const { choices } = await fetchTagChoices(arbi, workspaceId);
4730
4760
  id = await promptSelect("Select tag to delete", choices);
4731
4761
  }
4732
- const data = await core.tags.deleteTag(arbi, id);
4762
+ const data = await sdk.tags.deleteTag(arbi, id);
4733
4763
  success(data?.detail ?? `Deleted tag ${id}`);
4734
4764
  })()
4735
4765
  );
@@ -4755,7 +4785,7 @@ function registerTagsCommand(program2) {
4755
4785
  body = { [field]: await promptInput(field.charAt(0).toUpperCase() + field.slice(1)) };
4756
4786
  }
4757
4787
  }
4758
- const data = await core.tags.updateTag(arbi, id, body);
4788
+ const data = await sdk.tags.updateTag(arbi, id, body);
4759
4789
  success(`Updated: ${data.name} (${ref(data.external_id)})`);
4760
4790
  })()
4761
4791
  );
@@ -4764,7 +4794,7 @@ function registerTagsCommand(program2) {
4764
4794
  });
4765
4795
  }
4766
4796
  async function pickTag(arbi, workspaceId, message = "Select tag") {
4767
- const data = await core.tags.listTags(arbi);
4797
+ const data = await sdk.tags.listTags(arbi);
4768
4798
  if (data.length === 0) {
4769
4799
  console.log("No tags found.");
4770
4800
  process.exit(0);
@@ -4779,7 +4809,7 @@ async function pickTag(arbi, workspaceId, message = "Select tag") {
4779
4809
  );
4780
4810
  }
4781
4811
  async function pickDocs(arbi, workspaceId, message = "Select documents") {
4782
- const data = await core.documents.listDocuments(arbi);
4812
+ const data = await sdk.documents.listDocuments(arbi);
4783
4813
  if (data.length === 0) {
4784
4814
  console.log("No documents found.");
4785
4815
  process.exit(0);
@@ -4801,7 +4831,7 @@ function registerDoctagsCommand(program2) {
4801
4831
  if (!docIds || docIds.length === 0)
4802
4832
  docIds = await pickDocs(arbi, workspaceId, "Select documents to tag");
4803
4833
  if (docIds.length === 0) return;
4804
- const data = await core.doctags.assignDocTags(arbi, tagId, docIds, opts?.note);
4834
+ const data = await sdk.doctags.assignDocTags(arbi, tagId, docIds, opts?.note);
4805
4835
  success(`Created ${data.length} doctag(s) for tag ${tagId}.`);
4806
4836
  })()
4807
4837
  );
@@ -4812,7 +4842,7 @@ function registerDoctagsCommand(program2) {
4812
4842
  if (!docIds || docIds.length === 0)
4813
4843
  docIds = await pickDocs(arbi, workspaceId, "Select documents to untag");
4814
4844
  if (docIds.length === 0) return;
4815
- await core.doctags.removeDocTags(arbi, tagId, docIds);
4845
+ await sdk.doctags.removeDocTags(arbi, tagId, docIds);
4816
4846
  success(`Removed tag ${tagId} from ${docIds.length} document(s).`);
4817
4847
  })()
4818
4848
  );
@@ -4823,7 +4853,7 @@ function registerDoctagsCommand(program2) {
4823
4853
  if (opts.tags) {
4824
4854
  tagIds = opts.tags.split(",").map((s) => s.trim());
4825
4855
  } else {
4826
- const data2 = await core.tags.listTags(arbi);
4856
+ const data2 = await sdk.tags.listTags(arbi);
4827
4857
  if (data2.length === 0) {
4828
4858
  console.log("No tags found.");
4829
4859
  return;
@@ -4844,7 +4874,7 @@ function registerDoctagsCommand(program2) {
4844
4874
  docIds = await pickDocs(arbi, workspaceId, "Select documents for AI tagging");
4845
4875
  if (docIds.length === 0) return;
4846
4876
  }
4847
- const data = await core.doctags.generateDocTags(arbi, tagIds, docIds);
4877
+ const data = await sdk.doctags.generateDocTags(arbi, tagIds, docIds);
4848
4878
  console.log(
4849
4879
  `Generating doctags for ${data.doc_ext_ids.length} doc(s) with ${data.tag_ext_ids.length} tag(s).`
4850
4880
  );
@@ -4852,7 +4882,7 @@ function registerDoctagsCommand(program2) {
4852
4882
  );
4853
4883
  }
4854
4884
  async function pickConversation(arbi, workspaceId, message = "Select conversation") {
4855
- const data = await core.conversations.listConversations(arbi);
4885
+ const data = await sdk.conversations.listConversations(arbi);
4856
4886
  if (data.length === 0) {
4857
4887
  console.log("No conversations found.");
4858
4888
  process.exit(0);
@@ -4871,7 +4901,7 @@ function registerConversationsCommand(program2) {
4871
4901
  conv.command("list").description("List conversations in the active workspace").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").action(
4872
4902
  (opts) => runAction(async () => {
4873
4903
  const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
4874
- const data = await core.conversations.listConversations(arbi);
4904
+ const data = await sdk.conversations.listConversations(arbi);
4875
4905
  if (data.length === 0) {
4876
4906
  console.log("No conversations found.");
4877
4907
  return;
@@ -4891,7 +4921,7 @@ function registerConversationsCommand(program2) {
4891
4921
  (conversationId) => runAction(async () => {
4892
4922
  const { arbi, workspaceId } = await resolveWorkspace();
4893
4923
  if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
4894
- const data = await core.conversations.getConversationThreads(arbi, conversationId);
4924
+ const data = await sdk.conversations.getConversationThreads(arbi, conversationId);
4895
4925
  console.log(JSON.stringify(data, null, 2));
4896
4926
  })()
4897
4927
  );
@@ -4904,7 +4934,7 @@ function registerConversationsCommand(program2) {
4904
4934
  workspaceId,
4905
4935
  "Select conversation to delete"
4906
4936
  );
4907
- const data = await core.conversations.deleteConversation(arbi, conversationId);
4937
+ const data = await sdk.conversations.deleteConversation(arbi, conversationId);
4908
4938
  success(data?.detail ?? `Deleted conversation ${conversationId}`);
4909
4939
  })()
4910
4940
  );
@@ -4913,7 +4943,7 @@ function registerConversationsCommand(program2) {
4913
4943
  const { arbi, workspaceId } = await resolveWorkspace();
4914
4944
  if (!conversationId)
4915
4945
  conversationId = await pickConversation(arbi, workspaceId, "Select conversation to share");
4916
- const data = await core.conversations.shareConversation(arbi, conversationId);
4946
+ const data = await sdk.conversations.shareConversation(arbi, conversationId);
4917
4947
  success(data?.detail ?? `Shared conversation ${conversationId}`);
4918
4948
  })()
4919
4949
  );
@@ -4922,21 +4952,21 @@ function registerConversationsCommand(program2) {
4922
4952
  const { arbi, workspaceId } = await resolveWorkspace();
4923
4953
  if (!conversationId) conversationId = await pickConversation(arbi, workspaceId);
4924
4954
  if (!title) title = await promptInput("New title");
4925
- const data = await core.conversations.updateConversationTitle(arbi, conversationId, title);
4955
+ const data = await sdk.conversations.updateConversationTitle(arbi, conversationId, title);
4926
4956
  success(data?.detail ?? `Updated title to: ${title}`);
4927
4957
  })()
4928
4958
  );
4929
4959
  conv.command("message <message-id>").description("Get message details").action(
4930
4960
  (messageId) => runAction(async () => {
4931
4961
  const { arbi } = await resolveWorkspace();
4932
- const data = await core.conversations.getMessage(arbi, messageId);
4962
+ const data = await sdk.conversations.getMessage(arbi, messageId);
4933
4963
  console.log(JSON.stringify(data, null, 2));
4934
4964
  })()
4935
4965
  );
4936
4966
  conv.command("delete-message <message-id>").description("Delete a message and its descendants").action(
4937
4967
  (messageId) => runAction(async () => {
4938
4968
  const { arbi } = await resolveAuth();
4939
- const data = await core.conversations.deleteMessage(arbi, messageId);
4969
+ const data = await sdk.conversations.deleteMessage(arbi, messageId);
4940
4970
  success(data?.detail ?? `Deleted message ${messageId}`);
4941
4971
  })()
4942
4972
  );
@@ -4949,7 +4979,7 @@ function registerSettingsCommand(program2) {
4949
4979
  settings.command("get").description("Show current user settings").action(
4950
4980
  runAction(async () => {
4951
4981
  const { arbi } = await resolveAuth();
4952
- const data = await core.settings.getSettings(arbi);
4982
+ const data = await sdk.settings.getSettings(arbi);
4953
4983
  console.log(JSON.stringify(data, null, 2));
4954
4984
  })
4955
4985
  );
@@ -4957,7 +4987,7 @@ function registerSettingsCommand(program2) {
4957
4987
  (json) => runAction(async () => {
4958
4988
  const body = parseJsonArg(json, `arbi settings set '{"hide_online_status": true}'`);
4959
4989
  const { arbi } = await resolveAuth();
4960
- await core.settings.updateSettings(arbi, body);
4990
+ await sdk.settings.updateSettings(arbi, body);
4961
4991
  success("Settings updated.");
4962
4992
  })()
4963
4993
  );
@@ -4975,7 +5005,7 @@ var MODEL_SECTIONS = [
4975
5005
  "ArtifactLLM"
4976
5006
  ];
4977
5007
  async function pickConfig(arbi, message = "Select configuration") {
4978
- const data = await core.agentconfig.listConfigs(arbi);
5008
+ const data = await sdk.agentconfig.listConfigs(arbi);
4979
5009
  if (data.versions.length === 0) {
4980
5010
  console.log("No saved configurations found.");
4981
5011
  process.exit(0);
@@ -4990,7 +5020,7 @@ async function pickConfig(arbi, message = "Select configuration") {
4990
5020
  );
4991
5021
  }
4992
5022
  async function fetchModels(arbi) {
4993
- const data = await core.agentconfig.getModels(arbi);
5023
+ const data = await sdk.agentconfig.getModels(arbi);
4994
5024
  return data.models.map((m) => ({
4995
5025
  name: `${m.model_name} (${m.provider ?? m.api_type})`,
4996
5026
  value: m.model_name,
@@ -5112,7 +5142,7 @@ function registerAgentconfigCommand(program2) {
5112
5142
  ac.command("list").description("List saved configuration versions").action(
5113
5143
  runAction(async () => {
5114
5144
  const { arbi } = await resolveAuth();
5115
- const data = await core.agentconfig.listConfigs(arbi);
5145
+ const data = await sdk.agentconfig.listConfigs(arbi);
5116
5146
  if (data.versions.length === 0) {
5117
5147
  console.log("No saved configurations.");
5118
5148
  return;
@@ -5143,7 +5173,7 @@ function registerAgentconfigCommand(program2) {
5143
5173
  configId = await pickConfig(arbi);
5144
5174
  }
5145
5175
  }
5146
- const data = await core.agentconfig.getConfig(arbi, configId);
5176
+ const data = await sdk.agentconfig.getConfig(arbi, configId);
5147
5177
  console.log(JSON.stringify(data, null, 2));
5148
5178
  })()
5149
5179
  );
@@ -5162,7 +5192,7 @@ function registerAgentconfigCommand(program2) {
5162
5192
  }
5163
5193
  if (opts?.tag) body.tag_ext_id = opts.tag;
5164
5194
  if (opts?.message) body.parent_message_ext_id = opts.message;
5165
- const data = await core.agentconfig.saveConfig(arbi, body);
5195
+ const data = await sdk.agentconfig.saveConfig(arbi, body);
5166
5196
  success(`Saved: ${data.title || "(untitled)"} (${ref(data.external_id)})`);
5167
5197
  })()
5168
5198
  );
@@ -5170,14 +5200,14 @@ function registerAgentconfigCommand(program2) {
5170
5200
  (configId) => runAction(async () => {
5171
5201
  const { arbi } = await resolveAuth();
5172
5202
  if (!configId) configId = await pickConfig(arbi, "Select configuration to delete");
5173
- const data = await core.agentconfig.deleteConfig(arbi, configId);
5203
+ const data = await sdk.agentconfig.deleteConfig(arbi, configId);
5174
5204
  success(data.detail);
5175
5205
  })()
5176
5206
  );
5177
5207
  ac.command("schema").description("Show JSON schema for all configuration models").action(
5178
5208
  runAction(async () => {
5179
5209
  const { arbi } = await resolveAuth();
5180
- const data = await core.agentconfig.getSchema(arbi);
5210
+ const data = await sdk.agentconfig.getSchema(arbi);
5181
5211
  console.log(JSON.stringify(data, null, 2));
5182
5212
  })
5183
5213
  );
@@ -5189,7 +5219,7 @@ function registerHealthCommand(program2) {
5189
5219
  program2.command("health").description("Show server health status").action(
5190
5220
  runAction(async () => {
5191
5221
  const { arbi } = await resolveAuth();
5192
- const data = await core.health.getHealth(arbi);
5222
+ const data = await sdk.health.getHealth(arbi);
5193
5223
  label("Status:", status(data.status));
5194
5224
  if (data.backend_git_hash) label("Backend:", data.backend_git_hash);
5195
5225
  if (data.frontend_docker_version) label("Frontend:", data.frontend_docker_version);
@@ -5211,7 +5241,7 @@ Models (${data.models_health.application}):`);
5211
5241
  program2.command("models").description("List available AI models").action(
5212
5242
  runAction(async () => {
5213
5243
  const { arbi } = await resolveAuth();
5214
- const data = await core.health.getHealthModels(arbi);
5244
+ const data = await sdk.health.getHealthModels(arbi);
5215
5245
  if (data.models.length === 0) {
5216
5246
  console.log("No models available.");
5217
5247
  return;
@@ -5283,7 +5313,7 @@ console.info = (...args) => {
5283
5313
  _origInfo(...args);
5284
5314
  };
5285
5315
  var program = new commander.Command();
5286
- program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.9");
5316
+ program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.10");
5287
5317
  registerConfigCommand(program);
5288
5318
  registerLoginCommand(program);
5289
5319
  registerRegisterCommand(program);