@arbidocs/sdk 0.5.13 → 0.5.15

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
@@ -1,5 +1,5 @@
1
1
  import fs2, { readFileSync } from 'fs';
2
- import path2, { dirname, resolve } from 'path';
2
+ import path3, { dirname, resolve } from 'path';
3
3
  import os2 from 'os';
4
4
  import { createArbiClient, base64ToBytes, unwrapWorkspaceKey, sealKeyForSession, buildWebSocketUrl, createAuthMessage, parseServerMessage, isMessageType, createContentHash, encryptFile, initSodium, encryptionKeypairFromSigningKey, sealedBoxDecrypt, bytesToBase64, encryptWithChatKey, decryptWithChatKey, decryptFile, deriveDirectChatKey, openSealedChatKey, generateChatKey, sealChatKey, sealCallKey, encryptMessage, decodeSecureMailKey, openSecureMail, secureMailClaim, createSessionManager, authRequestError, changePassword, openCallKeyOf, decryptCallTitle, generateCallKey, encryptCallTitle, sealCallKeyForPeers, openSealedCallKey, readSessionClaims } from '@arbidocs/client';
5
5
  import { execSync, spawn } from 'child_process';
@@ -3625,8 +3625,8 @@ async function extractErrorMessage(res) {
3625
3625
  return `Request failed: ${res.status} ${res.statusText}`;
3626
3626
  }
3627
3627
  async function authenticatedFetch(options) {
3628
- const { baseUrl, accessToken, path: path4, method, body, headers, signal } = options;
3629
- const res = await fetch(`${baseUrl}${path4}`, {
3628
+ const { baseUrl, accessToken, path: path5, method, body, headers, signal } = options;
3629
+ const res = await fetch(`${baseUrl}${path5}`, {
3630
3630
  method: method ?? (body ? "POST" : "GET"),
3631
3631
  headers: {
3632
3632
  Authorization: `Bearer ${accessToken}`,
@@ -3699,13 +3699,13 @@ var FileConfigStore = class {
3699
3699
  sessionFile;
3700
3700
  metadataFile;
3701
3701
  constructor(configDir) {
3702
- const arbiBase = process.env.ARBI_CONFIG_DIR ?? (fs2.existsSync(path2.join(process.cwd(), ".arbi", "credentials.json")) ? path2.join(process.cwd(), ".arbi") : path2.join(os2.homedir(), ".arbi"));
3702
+ const arbiBase = process.env.ARBI_CONFIG_DIR ?? (fs2.existsSync(path3.join(process.cwd(), ".arbi", "credentials.json")) ? path3.join(process.cwd(), ".arbi") : path3.join(os2.homedir(), ".arbi"));
3703
3703
  const arbiId = process.env.ARBI_ID;
3704
- this.configDir = configDir ?? (arbiId ? path2.join(arbiBase, arbiId) : arbiBase);
3705
- this.configFile = path2.join(this.configDir, "config.json");
3706
- this.credentialsFile = path2.join(this.configDir, "credentials.json");
3707
- this.sessionFile = path2.join(this.configDir, "session.json");
3708
- this.metadataFile = path2.join(this.configDir, "last-metadata.json");
3704
+ this.configDir = configDir ?? (arbiId ? path3.join(arbiBase, arbiId) : arbiBase);
3705
+ this.configFile = path3.join(this.configDir, "config.json");
3706
+ this.credentialsFile = path3.join(this.configDir, "credentials.json");
3707
+ this.sessionFile = path3.join(this.configDir, "session.json");
3708
+ this.metadataFile = path3.join(this.configDir, "last-metadata.json");
3709
3709
  }
3710
3710
  ensureConfigDir() {
3711
3711
  if (!fs2.existsSync(this.configDir)) {
@@ -3853,12 +3853,12 @@ var FileConfigStore = class {
3853
3853
  return { config: config2, source: "ARBI_SERVER_URL env var" };
3854
3854
  }
3855
3855
  const dir = searchDir || process.cwd();
3856
- const dotenvConfig = this.readDotEnvDomain(path2.join(dir, ".env"));
3856
+ const dotenvConfig = this.readDotEnvDomain(path3.join(dir, ".env"));
3857
3857
  if (dotenvConfig) {
3858
3858
  this.saveConfig(dotenvConfig);
3859
3859
  return { config: dotenvConfig, source: ".env file" };
3860
3860
  }
3861
- const publicConfig = this.readPublicConfigDomain(path2.join(dir, "public", "config.json"));
3861
+ const publicConfig = this.readPublicConfigDomain(path3.join(dir, "public", "config.json"));
3862
3862
  if (publicConfig) {
3863
3863
  this.saveConfig(publicConfig);
3864
3864
  return { config: publicConfig, source: "public/config.json" };
@@ -5643,6 +5643,7 @@ __export(workspaces_exports, {
5643
5643
  listWorkspaceTransfers: () => listWorkspaceTransfers,
5644
5644
  listWorkspaceUsers: () => listWorkspaceUsers,
5645
5645
  listWorkspaces: () => listWorkspaces,
5646
+ moveWorkspaceToProject: () => moveWorkspaceToProject,
5646
5647
  planWorkspaceTransfer: () => planWorkspaceTransfer,
5647
5648
  primeWorkspaceKey: () => primeWorkspaceKey,
5648
5649
  removeWorkspaceUsers: () => removeWorkspaceUsers,
@@ -5668,6 +5669,15 @@ async function createWorkspace(arbi, name, encryptedWorkspaceKey, projectExtId,
5668
5669
  "Failed to create workspace"
5669
5670
  );
5670
5671
  }
5672
+ async function moveWorkspaceToProject(arbi, workspaceExtId, projectExtId) {
5673
+ return requireData(
5674
+ await arbi.fetch.PUT("/v1/workspace/{workspace_ext_id}/project", {
5675
+ params: { path: { workspace_ext_id: workspaceExtId } },
5676
+ body: { project_ext_id: projectExtId }
5677
+ }),
5678
+ "Failed to move workspace"
5679
+ );
5680
+ }
5671
5681
  async function deleteWorkspaces(arbi, workspaceIds) {
5672
5682
  requireOk(
5673
5683
  await arbi.fetch.DELETE("/v1/workspace/", {
@@ -5856,6 +5866,7 @@ __export(conversations_exports, {
5856
5866
  importConversations: () => importConversations,
5857
5867
  listConversations: () => listConversations,
5858
5868
  postConversationMessage: () => postConversationMessage,
5869
+ searchConversations: () => searchConversations,
5859
5870
  updateConversationAssistantMode: () => updateConversationAssistantMode
5860
5871
  });
5861
5872
  async function listConversations(arbi) {
@@ -5888,6 +5899,12 @@ async function deleteConversation(arbi, conversationId) {
5888
5899
  "Failed to delete conversation"
5889
5900
  );
5890
5901
  }
5902
+ async function searchConversations(arbi, body) {
5903
+ return requireData(
5904
+ await arbi.fetch.POST("/v1/conversation/search", { body }),
5905
+ "Failed to search conversations"
5906
+ );
5907
+ }
5891
5908
  async function getMessage(arbi, messageId) {
5892
5909
  return requireData(
5893
5910
  await arbi.fetch.GET("/v1/conversation/message/{message_ext_id}", {
@@ -9175,6 +9192,118 @@ async function remindFact(arbi, factId, options = {}) {
9175
9192
  );
9176
9193
  }
9177
9194
 
9195
+ // src/operations/databases.ts
9196
+ var databases_exports = {};
9197
+ __export(databases_exports, {
9198
+ addDatabaseRows: () => addDatabaseRows,
9199
+ createDatabase: () => createDatabase,
9200
+ deleteDatabase: () => deleteDatabase,
9201
+ deleteDatabaseRows: () => deleteDatabaseRows,
9202
+ exportDatabase: () => exportDatabase,
9203
+ getDatabase: () => getDatabase,
9204
+ importDatabase: () => importDatabase,
9205
+ importDatabaseRows: () => importDatabaseRows,
9206
+ listDatabaseRows: () => listDatabaseRows,
9207
+ listDatabases: () => listDatabases,
9208
+ updateDatabase: () => updateDatabase,
9209
+ updateDatabaseRow: () => updateDatabaseRow
9210
+ });
9211
+ var path2 = (databaseId) => ({ path: { database_id: databaseId } });
9212
+ function spreadsheet(file) {
9213
+ const form = new FormData();
9214
+ form.append("file", file);
9215
+ return { body: form, bodySerializer: () => form };
9216
+ }
9217
+ async function listDatabases(arbi) {
9218
+ return requireData(await arbi.fetch.GET("/v1/databases"), "Failed to list databases");
9219
+ }
9220
+ async function getDatabase(arbi, databaseId) {
9221
+ return requireData(
9222
+ await arbi.fetch.GET("/v1/databases/{database_id}", { params: path2(databaseId) }),
9223
+ "Failed to read the database"
9224
+ );
9225
+ }
9226
+ async function listDatabaseRows(arbi, databaseId, query2 = {}) {
9227
+ return requireData(
9228
+ await arbi.fetch.GET("/v1/databases/{database_id}/rows", {
9229
+ params: { ...path2(databaseId), query: query2 }
9230
+ }),
9231
+ "Failed to read the rows"
9232
+ );
9233
+ }
9234
+ async function createDatabase(arbi, body) {
9235
+ return requireData(
9236
+ await arbi.fetch.POST("/v1/databases", { body }),
9237
+ "Failed to create the database"
9238
+ );
9239
+ }
9240
+ async function updateDatabase(arbi, databaseId, body) {
9241
+ return requireData(
9242
+ await arbi.fetch.PATCH("/v1/databases/{database_id}", { params: path2(databaseId), body }),
9243
+ "Failed to update the database"
9244
+ );
9245
+ }
9246
+ async function deleteDatabase(arbi, databaseId) {
9247
+ requireOk(
9248
+ await arbi.fetch.DELETE("/v1/databases/{database_id}", { params: path2(databaseId) }),
9249
+ "Failed to delete the database"
9250
+ );
9251
+ }
9252
+ async function addDatabaseRows(arbi, databaseId, rows) {
9253
+ return requireData(
9254
+ await arbi.fetch.POST("/v1/databases/{database_id}/rows", {
9255
+ params: path2(databaseId),
9256
+ body: { rows }
9257
+ }),
9258
+ "Failed to add rows"
9259
+ );
9260
+ }
9261
+ async function updateDatabaseRow(arbi, databaseId, rowId, values) {
9262
+ return requireData(
9263
+ await arbi.fetch.PATCH("/v1/databases/{database_id}/rows/{row_id}", {
9264
+ params: { path: { database_id: databaseId, row_id: rowId } },
9265
+ body: { values }
9266
+ }),
9267
+ "Failed to update the row"
9268
+ );
9269
+ }
9270
+ async function deleteDatabaseRows(arbi, databaseId, ids) {
9271
+ requireOk(
9272
+ await arbi.fetch.POST("/v1/databases/{database_id}/rows/delete", {
9273
+ params: path2(databaseId),
9274
+ body: { ids }
9275
+ }),
9276
+ "Failed to delete rows"
9277
+ );
9278
+ }
9279
+ async function importDatabase(arbi, file, name) {
9280
+ return requireData(
9281
+ await arbi.fetch.POST("/v1/databases/import", {
9282
+ params: { query: { name } },
9283
+ ...spreadsheet(file)
9284
+ }),
9285
+ "Import failed"
9286
+ );
9287
+ }
9288
+ async function importDatabaseRows(arbi, databaseId, file) {
9289
+ return requireData(
9290
+ await arbi.fetch.POST("/v1/databases/{database_id}/import", {
9291
+ params: { ...path2(databaseId), query: { add_columns: true } },
9292
+ ...spreadsheet(file)
9293
+ }),
9294
+ "Import failed"
9295
+ );
9296
+ }
9297
+ async function exportDatabase(arbi, databaseId, format) {
9298
+ return requireData(
9299
+ await arbi.fetch.GET("/v1/databases/{database_id}/export", {
9300
+ params: { ...path2(databaseId), query: { format } },
9301
+ parseAs: "blob"
9302
+ }),
9303
+ "Export failed"
9304
+ );
9305
+ }
9306
+
9178
9307
  // src/operations/mail.ts
9179
9308
  var mail_exports = {};
9180
9309
  __export(mail_exports, {
@@ -9196,9 +9325,9 @@ __export(mail_exports, {
9196
9325
  });
9197
9326
  var NATIVE_ACCOUNT = "native";
9198
9327
  function createMailFetch(auth) {
9199
- return (path4, init = {}) => authenticatedFetch({
9328
+ return (path5, init = {}) => authenticatedFetch({
9200
9329
  ...auth,
9201
- path: `/v1/mail${path4}`,
9330
+ path: `/v1/mail${path5}`,
9202
9331
  method: init.method,
9203
9332
  body: init.body,
9204
9333
  headers: {
@@ -9237,8 +9366,8 @@ function getMessage2(mail, messageId, accountId = NATIVE_ACCOUNT) {
9237
9366
  return json(mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`));
9238
9367
  }
9239
9368
  async function downloadAttachment(mail, messageId, attachmentId, accountId = NATIVE_ACCOUNT) {
9240
- const path4 = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachmentId)}`;
9241
- return new Uint8Array(await (await mail(path4)).arrayBuffer());
9369
+ const path5 = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachmentId)}`;
9370
+ return new Uint8Array(await (await mail(path5)).arrayBuffer());
9242
9371
  }
9243
9372
  async function updateMessage(mail, messageId, update, accountId = NATIVE_ACCOUNT) {
9244
9373
  await mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`, {
@@ -9290,11 +9419,11 @@ async function unlockNativeMail(mail, keys) {
9290
9419
  async function claimSecureMail(mail, id, fragmentKey, recipientPublicKey) {
9291
9420
  const key = decodeSecureMailKey(fragmentKey);
9292
9421
  try {
9293
- const path4 = `/secure/${encodeURIComponent(id)}`;
9294
- const { raw } = await openSecureMail(await json(mail(path4)), key);
9422
+ const path5 = `/secure/${encodeURIComponent(id)}`;
9423
+ const { raw } = await openSecureMail(await json(mail(path5)), key);
9295
9424
  raw.fill(0);
9296
9425
  const claim = await secureMailClaim(key, recipientPublicKey);
9297
- return await json(mail(`${path4}/claim`, { method: "POST", body: JSON.stringify(claim) }));
9426
+ return await json(mail(`${path5}/claim`, { method: "POST", body: JSON.stringify(claim) }));
9298
9427
  } finally {
9299
9428
  key.fill(0);
9300
9429
  }
@@ -11141,6 +11270,8 @@ var Arbi = class {
11141
11270
  this.requireClient().workspaceKeys.forget(workspaceIds);
11142
11271
  },
11143
11272
  update: (body) => updateWorkspace(this.requireClient(), body),
11273
+ /** Move a workspace (open or not) to another project. */
11274
+ moveToProject: (workspaceId, projectExtId) => moveWorkspaceToProject(this.requireClient(), workspaceId, projectExtId),
11144
11275
  listUsers: () => listWorkspaceUsers(this.requireClient()),
11145
11276
  /** One page of a workspace's activity feed, newest first (see `getWorkspaceActivity`). */
11146
11277
  activity: (workspaceId, options) => getWorkspaceActivity(this.requireClient(), workspaceId, options),
@@ -11312,6 +11443,8 @@ var Arbi = class {
11312
11443
  list: () => listConversations(this.requireClient()),
11313
11444
  getThreads: (conversationId) => getConversationThreads(this.requireClient(), conversationId),
11314
11445
  delete: (conversationId) => deleteConversation(this.requireClient(), conversationId),
11446
+ /** Search the open workspace's past conversation messages (keyword + semantic), grouped. */
11447
+ search: (body) => searchConversations(this.requireClient(), body),
11315
11448
  /**
11316
11449
  * Patch a conversation: `title`, `shared` (owner only), its bound document
11317
11450
  * (`bound_document_ext_id`, `null` unbinds), and the work fields (`description`, `due_at`,
@@ -11399,11 +11532,11 @@ var Arbi = class {
11399
11532
  };
11400
11533
  /** Authenticated native Word transport, with normal session recovery. */
11401
11534
  editor = {
11402
- request: (path4, options = {}) => this.recovering(async () => {
11535
+ request: (path5, options = {}) => this.recovering(async () => {
11403
11536
  const { baseUrl, accessToken } = this.getAuthHeaders();
11404
11537
  const headers = new Headers(options.headers);
11405
11538
  headers.set("Authorization", `Bearer ${accessToken}`);
11406
- const response = await fetch(`${baseUrl}/v1/editor${path4}`, { ...options, headers });
11539
+ const response = await fetch(`${baseUrl}/v1/editor${path5}`, { ...options, headers });
11407
11540
  if (!response.ok) {
11408
11541
  const body = await response.json().catch(() => null);
11409
11542
  throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
@@ -11420,13 +11553,13 @@ var Arbi = class {
11420
11553
  */
11421
11554
  mail = {
11422
11555
  /** Fetch a path under `/v1/mail`; rejects a non-2xx response with an `ArbiApiError` (`status`). */
11423
- fetch: (path4, init = {}) => this.recovering(async () => {
11556
+ fetch: (path5, init = {}) => this.recovering(async () => {
11424
11557
  const { baseUrl, accessToken } = this.getAuthHeaders();
11425
11558
  const headers = new Headers(init.headers);
11426
11559
  headers.set("Authorization", `Bearer ${accessToken}`);
11427
11560
  if (init.body && !headers.has("Content-Type"))
11428
11561
  headers.set("Content-Type", "application/json");
11429
- const response = await fetch(`${baseUrl}/v1/mail${path4}`, { ...init, headers });
11562
+ const response = await fetch(`${baseUrl}/v1/mail${path5}`, { ...init, headers });
11430
11563
  if (!response.ok) {
11431
11564
  const body = await response.json().catch(() => null);
11432
11565
  throw new ArbiApiError(
@@ -12239,6 +12372,22 @@ var Arbi = class {
12239
12372
  /** The documents the open workspace may use as its house template. */
12240
12373
  candidates: () => listHouseTemplateCandidates(this.requireClient())
12241
12374
  };
12375
+ // ── Databases (user-defined tables of the open workspace) ──────────
12376
+ databases = {
12377
+ list: () => listDatabases(this.requireClient()),
12378
+ get: (databaseId) => getDatabase(this.requireClient(), databaseId),
12379
+ /** A search of the rows (any cell), sorted and paged on the server. */
12380
+ rows: (databaseId, query2) => listDatabaseRows(this.requireClient(), databaseId, query2),
12381
+ create: (body) => createDatabase(this.requireClient(), body),
12382
+ update: (databaseId, body) => updateDatabase(this.requireClient(), databaseId, body),
12383
+ delete: (databaseId) => deleteDatabase(this.requireClient(), databaseId),
12384
+ addRows: (databaseId, rows) => addDatabaseRows(this.requireClient(), databaseId, rows),
12385
+ updateRow: (databaseId, rowId, values) => updateDatabaseRow(this.requireClient(), databaseId, rowId, values),
12386
+ deleteRows: (databaseId, ids) => deleteDatabaseRows(this.requireClient(), databaseId, ids),
12387
+ import: (file, name) => importDatabase(this.requireClient(), file, name),
12388
+ importRows: (databaseId, file) => importDatabaseRows(this.requireClient(), databaseId, file),
12389
+ export: (databaseId, format) => exportDatabase(this.requireClient(), databaseId, format)
12390
+ };
12242
12391
  // ── Workspace facts ─────────────────────────────────────────────────
12243
12392
  facts = {
12244
12393
  create: (body) => createFact(this.requireClient(), body),
@@ -12310,16 +12459,16 @@ function collectFiles(dirPath, baseDir) {
12310
12459
  const root = baseDir ?? dirPath;
12311
12460
  const results = [];
12312
12461
  for (const entry of fs2.readdirSync(dirPath, { withFileTypes: true })) {
12313
- const fullPath = path2.join(dirPath, entry.name);
12462
+ const fullPath = path3.join(dirPath, entry.name);
12314
12463
  if (entry.isDirectory()) {
12315
12464
  results.push(...collectFiles(fullPath, root));
12316
12465
  } else if (entry.isFile()) {
12317
- const ext = path2.extname(entry.name).toLowerCase();
12466
+ const ext = path3.extname(entry.name).toLowerCase();
12318
12467
  if (SUPPORTED_EXTENSIONS.has(ext)) {
12319
12468
  const stat = fs2.statSync(fullPath);
12320
12469
  results.push({
12321
12470
  absolutePath: fullPath,
12322
- relativePath: path2.relative(root, fullPath),
12471
+ relativePath: path3.relative(root, fullPath),
12323
12472
  size: stat.size
12324
12473
  });
12325
12474
  }
@@ -12355,14 +12504,14 @@ function readFileAsBlob(filePath, fileSize, fileName) {
12355
12504
  }
12356
12505
  async function uploadLocalFile(auth, filePath, options) {
12357
12506
  const stat = fs2.statSync(filePath);
12358
- const fileName = path2.basename(filePath);
12507
+ const fileName = path3.basename(filePath);
12359
12508
  const blob = readFileAsBlob(filePath, stat.size, fileName);
12360
12509
  const result = await uploadFile(auth, blob, fileName, options);
12361
12510
  return { ...result, fileName };
12362
12511
  }
12363
12512
  async function uploadLocalFilesDirect(arbi, workspaceKey, filePaths, options) {
12364
12513
  const files = filePaths.map((fp) => {
12365
- const resolved = path2.resolve(fp);
12514
+ const resolved = path3.resolve(fp);
12366
12515
  const stat = fs2.statSync(resolved);
12367
12516
  if (stat.size > NODE_BUFFER_LIMIT) {
12368
12517
  throw new Error(
@@ -12370,9 +12519,9 @@ async function uploadLocalFilesDirect(arbi, workspaceKey, filePaths, options) {
12370
12519
  );
12371
12520
  }
12372
12521
  return {
12373
- name: path2.basename(resolved),
12522
+ name: path3.basename(resolved),
12374
12523
  data: new Uint8Array(fs2.readFileSync(resolved)),
12375
- contentType: mimeFromName(path2.basename(resolved))
12524
+ contentType: mimeFromName(path3.basename(resolved))
12376
12525
  };
12377
12526
  });
12378
12527
  return uploadDocumentsDirect(arbi, workspaceKey, files, options);
@@ -12418,8 +12567,8 @@ async function runGroupedDirectUpload(arbi, workspaceKey, groups, options) {
12418
12567
  return { doc_ext_ids: allDocIds, skipped: allSkipped, folders };
12419
12568
  }
12420
12569
  async function uploadLocalDirectoryDirect(arbi, workspaceKey, dirPath, options) {
12421
- const resolvedDir = path2.resolve(dirPath);
12422
- const dirName = path2.basename(resolvedDir);
12570
+ const resolvedDir = path3.resolve(dirPath);
12571
+ const dirName = path3.basename(resolvedDir);
12423
12572
  const entries = collectFiles(resolvedDir);
12424
12573
  if (entries.length === 0) {
12425
12574
  return { doc_ext_ids: [], skipped: [], folders: /* @__PURE__ */ new Map() };
@@ -12431,9 +12580,9 @@ async function uploadLocalDirectoryDirect(arbi, workspaceKey, dirPath, options)
12431
12580
  `File ${entry.absolutePath} is ${entry.size} bytes \u2014 direct upload currently loads the full file into memory; skip --s3 for files > 2 GiB.`
12432
12581
  );
12433
12582
  }
12434
- const relDir = path2.dirname(entry.relativePath);
12583
+ const relDir = path3.dirname(entry.relativePath);
12435
12584
  const folder = sanitizeFolderPath(relDir === "." ? dirName : `${dirName}/${relDir}`);
12436
- const name = path2.basename(entry.relativePath);
12585
+ const name = path3.basename(entry.relativePath);
12437
12586
  if (!buckets.has(folder)) buckets.set(folder, []);
12438
12587
  buckets.get(folder).push({
12439
12588
  name,
@@ -12449,11 +12598,11 @@ async function uploadLocalZipDirect(arbi, workspaceKey, zipPath, options) {
12449
12598
  const JSZip = (await import('jszip')).default;
12450
12599
  const zipBuffer = fs2.readFileSync(zipPath);
12451
12600
  const zip = await JSZip.loadAsync(zipBuffer);
12452
- const zipBaseName = path2.basename(zipPath).replace(/\.zip$/i, "");
12601
+ const zipBaseName = path3.basename(zipPath).replace(/\.zip$/i, "");
12453
12602
  const entries = [];
12454
12603
  zip.forEach((relativePath, zipEntry) => {
12455
12604
  if (zipEntry.dir) return;
12456
- const ext = path2.extname(relativePath).toLowerCase();
12605
+ const ext = path3.extname(relativePath).toLowerCase();
12457
12606
  if (SUPPORTED_EXTENSIONS.has(ext)) {
12458
12607
  entries.push({ zipEntryPath: relativePath, zipEntry });
12459
12608
  }
@@ -12466,8 +12615,8 @@ async function uploadLocalZipDirect(arbi, workspaceKey, zipPath, options) {
12466
12615
  const buckets = /* @__PURE__ */ new Map();
12467
12616
  for (const entry of entries) {
12468
12617
  const data = await entry.zipEntry.async("uint8array");
12469
- const fileName = path2.basename(entry.zipEntryPath);
12470
- const relDir = path2.dirname(entry.zipEntryPath);
12618
+ const fileName = path3.basename(entry.zipEntryPath);
12619
+ const relDir = path3.dirname(entry.zipEntryPath);
12471
12620
  let folder;
12472
12621
  if (hasSingleRoot) {
12473
12622
  folder = relDir === "." ? zipBaseName : relDir;
@@ -12492,17 +12641,17 @@ async function uploadLocalArchiveDirect(arbi, workspaceKey, archivePath, options
12492
12641
  } catch {
12493
12642
  throw new Error("7z is not installed. Install p7zip-full to extract archives.");
12494
12643
  }
12495
- const tmpDir = fs2.mkdtempSync(path2.join(os2.tmpdir(), "arbi-archive-"));
12644
+ const tmpDir = fs2.mkdtempSync(path3.join(os2.tmpdir(), "arbi-archive-"));
12496
12645
  let uploadDir;
12497
12646
  let namedDir;
12498
12647
  try {
12499
- execSync(`7z x -y -o"${tmpDir}" "${path2.resolve(archivePath)}"`, { stdio: "ignore" });
12648
+ execSync(`7z x -y -o"${tmpDir}" "${path3.resolve(archivePath)}"`, { stdio: "ignore" });
12500
12649
  const topLevel = fs2.readdirSync(tmpDir);
12501
- if (topLevel.length === 1 && fs2.statSync(path2.join(tmpDir, topLevel[0])).isDirectory()) {
12502
- uploadDir = path2.join(tmpDir, topLevel[0]);
12650
+ if (topLevel.length === 1 && fs2.statSync(path3.join(tmpDir, topLevel[0])).isDirectory()) {
12651
+ uploadDir = path3.join(tmpDir, topLevel[0]);
12503
12652
  } else {
12504
- const baseName = path2.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
12505
- namedDir = path2.join(path2.dirname(tmpDir), baseName);
12653
+ const baseName = path3.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
12654
+ namedDir = path3.join(path3.dirname(tmpDir), baseName);
12506
12655
  fs2.renameSync(tmpDir, namedDir);
12507
12656
  uploadDir = namedDir;
12508
12657
  }
@@ -12517,20 +12666,20 @@ async function uploadLocalArchiveDirect(arbi, workspaceKey, archivePath, options
12517
12666
  }
12518
12667
  }
12519
12668
  async function uploadDirectory(auth, dirPath, options) {
12520
- const resolvedDir = path2.resolve(dirPath);
12521
- const dirName = path2.basename(resolvedDir);
12669
+ const resolvedDir = path3.resolve(dirPath);
12670
+ const dirName = path3.basename(resolvedDir);
12522
12671
  const entries = collectFiles(resolvedDir);
12523
12672
  if (entries.length === 0) {
12524
12673
  return { doc_ext_ids: [], skipped: [], folders: /* @__PURE__ */ new Map() };
12525
12674
  }
12526
12675
  const groups = /* @__PURE__ */ new Map();
12527
12676
  for (const entry of entries) {
12528
- const relDir = path2.dirname(entry.relativePath);
12677
+ const relDir = path3.dirname(entry.relativePath);
12529
12678
  const folder = relDir === "." ? dirName : `${dirName}/${relDir}`;
12530
12679
  if (!groups.has(folder)) groups.set(folder, []);
12531
12680
  groups.get(folder).push({
12532
12681
  absolutePath: entry.absolutePath,
12533
- name: path2.basename(entry.relativePath),
12682
+ name: path3.basename(entry.relativePath),
12534
12683
  size: entry.size
12535
12684
  });
12536
12685
  }
@@ -12612,11 +12761,11 @@ async function uploadZip(auth, zipPath, options) {
12612
12761
  const JSZip = (await import('jszip')).default;
12613
12762
  const zipBuffer = fs2.readFileSync(zipPath);
12614
12763
  const zip = await JSZip.loadAsync(zipBuffer);
12615
- const zipBaseName = path2.basename(zipPath).replace(/\.zip$/i, "");
12764
+ const zipBaseName = path3.basename(zipPath).replace(/\.zip$/i, "");
12616
12765
  const entries = [];
12617
12766
  zip.forEach((relativePath, zipEntry) => {
12618
12767
  if (zipEntry.dir) return;
12619
- const ext = path2.extname(relativePath).toLowerCase();
12768
+ const ext = path3.extname(relativePath).toLowerCase();
12620
12769
  if (SUPPORTED_EXTENSIONS.has(ext)) {
12621
12770
  entries.push({ zipEntryPath: relativePath, zipEntry });
12622
12771
  }
@@ -12629,8 +12778,8 @@ async function uploadZip(auth, zipPath, options) {
12629
12778
  const groups = /* @__PURE__ */ new Map();
12630
12779
  for (const entry of entries) {
12631
12780
  const data = await entry.zipEntry.async("uint8array");
12632
- const fileName = path2.basename(entry.zipEntryPath);
12633
- const relDir = path2.dirname(entry.zipEntryPath);
12781
+ const fileName = path3.basename(entry.zipEntryPath);
12782
+ const relDir = path3.dirname(entry.zipEntryPath);
12634
12783
  let folder;
12635
12784
  if (hasSingleRoot) {
12636
12785
  folder = relDir === "." ? zipBaseName : relDir;
@@ -12698,9 +12847,9 @@ async function uploadZip(auth, zipPath, options) {
12698
12847
  return { doc_ext_ids: allDocIds, skipped: allSkipped, folders };
12699
12848
  }
12700
12849
  function commonParentDir(absolutePaths) {
12701
- if (absolutePaths.length === 0) return path2.sep;
12702
- if (absolutePaths.length === 1) return path2.dirname(absolutePaths[0]);
12703
- const split = absolutePaths.map((p2) => path2.dirname(p2).split(path2.sep));
12850
+ if (absolutePaths.length === 0) return path3.sep;
12851
+ if (absolutePaths.length === 1) return path3.dirname(absolutePaths[0]);
12852
+ const split = absolutePaths.map((p2) => path3.dirname(p2).split(path3.sep));
12704
12853
  const minLen = Math.min(...split.map((s2) => s2.length));
12705
12854
  const common = [];
12706
12855
  for (let i2 = 0; i2 < minLen; i2++) {
@@ -12708,21 +12857,21 @@ function commonParentDir(absolutePaths) {
12708
12857
  if (split.every((s2) => s2[i2] === seg)) common.push(seg);
12709
12858
  else break;
12710
12859
  }
12711
- const joined = common.join(path2.sep);
12712
- return joined || path2.sep;
12860
+ const joined = common.join(path3.sep);
12861
+ return joined || path3.sep;
12713
12862
  }
12714
12863
  function deriveFolder(absolutePath, rootDir, rootBasename) {
12715
- const parent = path2.dirname(absolutePath);
12716
- const rel = path2.relative(rootDir, parent);
12864
+ const parent = path3.dirname(absolutePath);
12865
+ const rel = path3.relative(rootDir, parent);
12717
12866
  let folderPath;
12718
12867
  if (rel === "" || rel === ".") {
12719
12868
  folderPath = rootBasename;
12720
12869
  } else if (rel.startsWith("..")) {
12721
- folderPath = path2.basename(parent) || rootBasename;
12870
+ folderPath = path3.basename(parent) || rootBasename;
12722
12871
  } else {
12723
- folderPath = path2.join(rootBasename, rel);
12872
+ folderPath = path3.join(rootBasename, rel);
12724
12873
  }
12725
- return sanitizeFolderPath(folderPath.split(path2.sep).join("/"));
12874
+ return sanitizeFolderPath(folderPath.split(path3.sep).join("/"));
12726
12875
  }
12727
12876
  function classifySkipReason(reason) {
12728
12877
  const lower = reason.toLowerCase();
@@ -12763,9 +12912,9 @@ async function uploadManifest(auth, paths, options) {
12763
12912
  if (options?.failFast && o2.status === "error") abortedByFailFast = true;
12764
12913
  };
12765
12914
  const prepared = [];
12766
- const absoluteInputs = paths.map((p2) => path2.resolve(p2));
12767
- const rootDir = options?.rootDir ? path2.resolve(options.rootDir) : commonParentDir(absoluteInputs);
12768
- const rootBasename = path2.basename(rootDir) || "root";
12915
+ const absoluteInputs = paths.map((p2) => path3.resolve(p2));
12916
+ const rootDir = options?.rootDir ? path3.resolve(options.rootDir) : commonParentDir(absoluteInputs);
12917
+ const rootBasename = path3.basename(rootDir) || "root";
12769
12918
  for (let i2 = 0; i2 < paths.length; i2++) {
12770
12919
  if (options?.signal?.aborted || abortedByFailFast) {
12771
12920
  await emit({
@@ -12803,7 +12952,7 @@ async function uploadManifest(auth, paths, options) {
12803
12952
  });
12804
12953
  continue;
12805
12954
  }
12806
- const ext = path2.extname(abs).toLowerCase();
12955
+ const ext = path3.extname(abs).toLowerCase();
12807
12956
  if (!SUPPORTED_EXTENSIONS.has(ext)) {
12808
12957
  await emit({
12809
12958
  path: inputPath,
@@ -12830,7 +12979,7 @@ async function uploadManifest(auth, paths, options) {
12830
12979
  prepared.push({
12831
12980
  inputPath,
12832
12981
  absolutePath: abs,
12833
- basename: path2.basename(abs),
12982
+ basename: path3.basename(abs),
12834
12983
  folder: deriveFolder(abs, rootDir, rootBasename),
12835
12984
  size: stat.size
12836
12985
  });
@@ -12984,7 +13133,7 @@ async function uploadManifest(auth, paths, options) {
12984
13133
  }
12985
13134
  function walkSupportedFiles(dirPath) {
12986
13135
  const out = [];
12987
- const resolved = path2.resolve(dirPath);
13136
+ const resolved = path3.resolve(dirPath);
12988
13137
  const stack = [resolved];
12989
13138
  while (stack.length > 0) {
12990
13139
  const current = stack.pop();
@@ -12995,11 +13144,11 @@ function walkSupportedFiles(dirPath) {
12995
13144
  continue;
12996
13145
  }
12997
13146
  for (const entry of entries) {
12998
- const full = path2.join(current, entry.name);
13147
+ const full = path3.join(current, entry.name);
12999
13148
  if (entry.isDirectory()) {
13000
13149
  stack.push(full);
13001
13150
  } else if (entry.isFile()) {
13002
- const ext = path2.extname(entry.name).toLowerCase();
13151
+ const ext = path3.extname(entry.name).toLowerCase();
13003
13152
  if (SUPPORTED_EXTENSIONS.has(ext)) out.push(full);
13004
13153
  }
13005
13154
  }
@@ -13012,16 +13161,16 @@ async function uploadArchive(auth, archivePath, options) {
13012
13161
  } catch {
13013
13162
  throw new Error("7z is not installed. Install p7zip-full to extract archives.");
13014
13163
  }
13015
- const tmpDir = fs2.mkdtempSync(path2.join(os2.tmpdir(), "arbi-archive-"));
13164
+ const tmpDir = fs2.mkdtempSync(path3.join(os2.tmpdir(), "arbi-archive-"));
13016
13165
  try {
13017
- execSync(`7z x -y -o"${tmpDir}" "${path2.resolve(archivePath)}"`, { stdio: "ignore" });
13166
+ execSync(`7z x -y -o"${tmpDir}" "${path3.resolve(archivePath)}"`, { stdio: "ignore" });
13018
13167
  const topLevel = fs2.readdirSync(tmpDir);
13019
13168
  let uploadDir;
13020
- if (topLevel.length === 1 && fs2.statSync(path2.join(tmpDir, topLevel[0])).isDirectory()) {
13021
- uploadDir = path2.join(tmpDir, topLevel[0]);
13169
+ if (topLevel.length === 1 && fs2.statSync(path3.join(tmpDir, topLevel[0])).isDirectory()) {
13170
+ uploadDir = path3.join(tmpDir, topLevel[0]);
13022
13171
  } else {
13023
- const baseName = path2.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
13024
- const namedDir = path2.join(path2.dirname(tmpDir), baseName);
13172
+ const baseName = path3.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
13173
+ const namedDir = path3.join(path3.dirname(tmpDir), baseName);
13025
13174
  fs2.renameSync(tmpDir, namedDir);
13026
13175
  uploadDir = namedDir;
13027
13176
  }
@@ -13037,8 +13186,8 @@ __export(mail_node_exports, {
13037
13186
  attachmentFromFile: () => attachmentFromFile
13038
13187
  });
13039
13188
  function attachmentFromFile(filePath) {
13040
- const resolved = path2.resolve(filePath);
13041
- const name = path2.basename(resolved);
13189
+ const resolved = path3.resolve(filePath);
13190
+ const name = path3.basename(resolved);
13042
13191
  return attachmentFromBytes(
13043
13192
  name,
13044
13193
  mimeFromName(name) || "application/octet-stream",
@@ -14034,6 +14183,6 @@ function getRunToAttach(localGeneration, messages) {
14034
14183
  return getAttachableRunId(messages);
14035
14184
  }
14036
14185
 
14037
- export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ArbiWorkspaceChangedError, ArbiWorkspaceSupersededError, CallApiError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, DRIVE_SYNC_VENDORS, DuplicateContactError, ENTITY_KINDS, FLAT_TAG_KINDS, FileConfigStore, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, OpenClawOrchestrator, PRESENCE_KINDS, PROMPT_CONTEXT_CHARS, PlanStepsError, PublicBookingError, SHAREPOINT_VENDORS, STEP_FIELD_OPTION_TONES, STOP_ID_WAIT_MS, STOP_REPEAT_WINDOW_MS, TAG_KINDS, TAG_NESTING_MAX_DEPTH, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, appendTranscriptionHints, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildDocNameMap, buildDocumentTools, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, buildTurnRequest, calendar_exports as calendar, calls_exports as calls, canTagHaveParent, cancelPublicBooking, chats_exports as chats, computeRunStats, connectErrorMessage, connectWebSocket, connectWithReconnect, connectors_exports as connectors, consumeSSEStream, contacts_exports as contacts, continuityPrompt, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, createIndexAssigner, defaultKindForFormat, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, estimateDraftTokens, extractDocumentIdsFromMessages, extractFactIdsFromMessages, extractSubagentLanes, facts_exports as facts, files_exports as files, filterDocumentTags, filterSkills, findLeafForTaskMessage, findMainSiblingLeaf, findReplyTarget, findSubagentRunId, firm_exports as firm, flattenTagTree, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatTokens, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getAgentStepLabel, getAttachableRunId, getChildTags, getContextRemainingPercent, getContextUsedPercent, getContextUsedTokens, getCurrentStep, getEligibleParentTags, getErrorCode, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, getRunToAttach, getRunToCancel, getStepDisplay, getStepTool, getSubagentBranchRecord, getTagDescendantIds, health_exports as health, house_template_exports as houseTemplates, hydrateAgentSteps, identityErrorCode, identity_exports as identityVerification, isAnnotationTag, isConnectorVendorVisible, isDriveSyncVendor, isEntityTag, isFlatKind, isLabelTag, isMailboxSyncVendor, isNearAiUsageBudget, isPresenceTag, isSharePointVendor, isSharedSkill, isTraceItem, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, mergeAgentSteps, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, pickMainThread, profile_exports as profile, progressFetch, projects_exports as projects, quotaExceededFrom, quotaFromStreamError, reduceOutputItem, refusalReason, requireData, requireOk, resolveAuth, resolveCitations, resolveSummary, resolveWorkspace, responses_exports as responses, searchChunks, selectFullContextDocument, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, sliceToSubagentThread, startDmListener, streamSSE, stripCitationMarkdown, subagentJobLabel, summarizeCitations, tagUseCount, tags_exports as tags, tagsForScope, tagsOfGroup, topLevelAgentSteps, uploadSkill, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces, wouldCreateTagCycle };
14186
+ export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ArbiWorkspaceChangedError, ArbiWorkspaceSupersededError, CallApiError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, DRIVE_SYNC_VENDORS, DuplicateContactError, ENTITY_KINDS, FLAT_TAG_KINDS, FileConfigStore, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, OpenClawOrchestrator, PRESENCE_KINDS, PROMPT_CONTEXT_CHARS, PlanStepsError, PublicBookingError, SHAREPOINT_VENDORS, STEP_FIELD_OPTION_TONES, STOP_ID_WAIT_MS, STOP_REPEAT_WINDOW_MS, TAG_KINDS, TAG_NESTING_MAX_DEPTH, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, appendTranscriptionHints, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildDocNameMap, buildDocumentTools, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, buildTurnRequest, calendar_exports as calendar, calls_exports as calls, canTagHaveParent, cancelPublicBooking, chats_exports as chats, computeRunStats, connectErrorMessage, connectWebSocket, connectWithReconnect, connectors_exports as connectors, consumeSSEStream, contacts_exports as contacts, continuityPrompt, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, createIndexAssigner, databases_exports as databases, defaultKindForFormat, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, estimateDraftTokens, extractDocumentIdsFromMessages, extractFactIdsFromMessages, extractSubagentLanes, facts_exports as facts, files_exports as files, filterDocumentTags, filterSkills, findLeafForTaskMessage, findMainSiblingLeaf, findReplyTarget, findSubagentRunId, firm_exports as firm, flattenTagTree, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatTokens, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getAgentStepLabel, getAttachableRunId, getChildTags, getContextRemainingPercent, getContextUsedPercent, getContextUsedTokens, getCurrentStep, getEligibleParentTags, getErrorCode, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, getRunToAttach, getRunToCancel, getStepDisplay, getStepTool, getSubagentBranchRecord, getTagDescendantIds, health_exports as health, house_template_exports as houseTemplates, hydrateAgentSteps, identityErrorCode, identity_exports as identityVerification, isAnnotationTag, isConnectorVendorVisible, isDriveSyncVendor, isEntityTag, isFlatKind, isLabelTag, isMailboxSyncVendor, isNearAiUsageBudget, isPresenceTag, isSharePointVendor, isSharedSkill, isTraceItem, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, mergeAgentSteps, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, pickMainThread, profile_exports as profile, progressFetch, projects_exports as projects, quotaExceededFrom, quotaFromStreamError, reduceOutputItem, refusalReason, requireData, requireOk, resolveAuth, resolveCitations, resolveSummary, resolveWorkspace, responses_exports as responses, searchChunks, selectFullContextDocument, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, sliceToSubagentThread, startDmListener, streamSSE, stripCitationMarkdown, subagentJobLabel, summarizeCitations, tagUseCount, tags_exports as tags, tagsForScope, tagsOfGroup, topLevelAgentSteps, uploadSkill, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces, wouldCreateTagCycle };
14038
14187
  //# sourceMappingURL=index.js.map
14039
14188
  //# sourceMappingURL=index.js.map