@arbidocs/sdk 0.5.145 → 0.5.147
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/{browser-C2Fm_iTe.d.cts → browser-8ZBWzFtx.d.cts} +245 -33
- package/dist/{browser-Cnw8-hVH.d.ts → browser-DKHZ8Q9X.d.ts} +245 -33
- package/dist/browser.cjs +219 -80
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +215 -81
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +289 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +281 -146
- package/dist/index.js.map +1 -1
- package/examples/human-review/package.json +1 -1
- package/examples/react-chat/package.json +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs2, { readFileSync } from 'fs';
|
|
2
|
-
import
|
|
2
|
+
import path4, { 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, sealedBoxEncrypt, sealedBoxDecrypt, sealSecureMail, decodeSecureMailKey, openSecureMail, secureMailClaim, bytesToBase64 as bytesToBase64$1, encryptWithChatKey, decryptWithChatKey, decryptFile, deriveDirectChatKey, openSealedChatKey, generateChatKey, sealChatKey, sealCallKey, encryptMessage, createSessionManager, authRequestError, isAbortError, changePassword, openCallKeyOf, decryptCallTitle, generateCallKey, encryptCallTitle, sealCallKeyForPeers, openSealedCallKey, readSessionClaims } from '@arbidocs/client';
|
|
5
5
|
import { execSync, spawn } from 'child_process';
|
|
@@ -3710,7 +3710,7 @@ async function authenticatedFetch(options) {
|
|
|
3710
3710
|
const {
|
|
3711
3711
|
baseUrl,
|
|
3712
3712
|
accessToken,
|
|
3713
|
-
path:
|
|
3713
|
+
path: path6,
|
|
3714
3714
|
method,
|
|
3715
3715
|
body,
|
|
3716
3716
|
headers,
|
|
@@ -3719,7 +3719,7 @@ async function authenticatedFetch(options) {
|
|
|
3719
3719
|
} = options;
|
|
3720
3720
|
let res;
|
|
3721
3721
|
try {
|
|
3722
|
-
res = await send(`${baseUrl}${
|
|
3722
|
+
res = await send(`${baseUrl}${path6}`, {
|
|
3723
3723
|
method: method ?? (body ? "POST" : "GET"),
|
|
3724
3724
|
headers: {
|
|
3725
3725
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -3821,13 +3821,13 @@ var FileConfigStore = class {
|
|
|
3821
3821
|
sessionFile;
|
|
3822
3822
|
metadataFile;
|
|
3823
3823
|
constructor(configDir) {
|
|
3824
|
-
const arbiBase = process.env.ARBI_CONFIG_DIR ?? (fs2.existsSync(
|
|
3824
|
+
const arbiBase = process.env.ARBI_CONFIG_DIR ?? (fs2.existsSync(path4.join(process.cwd(), ".arbi", "credentials.json")) ? path4.join(process.cwd(), ".arbi") : path4.join(os2.homedir(), ".arbi"));
|
|
3825
3825
|
const arbiId = process.env.ARBI_ID;
|
|
3826
|
-
this.configDir = configDir ?? (arbiId ?
|
|
3827
|
-
this.configFile =
|
|
3828
|
-
this.credentialsFile =
|
|
3829
|
-
this.sessionFile =
|
|
3830
|
-
this.metadataFile =
|
|
3826
|
+
this.configDir = configDir ?? (arbiId ? path4.join(arbiBase, arbiId) : arbiBase);
|
|
3827
|
+
this.configFile = path4.join(this.configDir, "config.json");
|
|
3828
|
+
this.credentialsFile = path4.join(this.configDir, "credentials.json");
|
|
3829
|
+
this.sessionFile = path4.join(this.configDir, "session.json");
|
|
3830
|
+
this.metadataFile = path4.join(this.configDir, "last-metadata.json");
|
|
3831
3831
|
}
|
|
3832
3832
|
ensureConfigDir() {
|
|
3833
3833
|
if (!fs2.existsSync(this.configDir)) {
|
|
@@ -3975,12 +3975,12 @@ var FileConfigStore = class {
|
|
|
3975
3975
|
return { config: config2, source: "ARBI_SERVER_URL env var" };
|
|
3976
3976
|
}
|
|
3977
3977
|
const dir = searchDir || process.cwd();
|
|
3978
|
-
const dotenvConfig = this.readDotEnvDomain(
|
|
3978
|
+
const dotenvConfig = this.readDotEnvDomain(path4.join(dir, ".env"));
|
|
3979
3979
|
if (dotenvConfig) {
|
|
3980
3980
|
this.saveConfig(dotenvConfig);
|
|
3981
3981
|
return { config: dotenvConfig, source: ".env file" };
|
|
3982
3982
|
}
|
|
3983
|
-
const publicConfig = this.readPublicConfigDomain(
|
|
3983
|
+
const publicConfig = this.readPublicConfigDomain(path4.join(dir, "public", "config.json"));
|
|
3984
3984
|
if (publicConfig) {
|
|
3985
3985
|
this.saveConfig(publicConfig);
|
|
3986
3986
|
return { config: publicConfig, source: "public/config.json" };
|
|
@@ -4544,6 +4544,7 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4544
4544
|
let assistantMessageExtId = null;
|
|
4545
4545
|
const agentSteps = [];
|
|
4546
4546
|
let toolCallCount = 0;
|
|
4547
|
+
let agentStepCount = 0;
|
|
4547
4548
|
const errors = [];
|
|
4548
4549
|
const artifacts = [];
|
|
4549
4550
|
let userMessage = null;
|
|
@@ -4623,7 +4624,8 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4623
4624
|
if (item?.type === "function_call" || item?.type === "reasoning") {
|
|
4624
4625
|
const label = formatItemLabel(item);
|
|
4625
4626
|
if (label) agentSteps.push(label);
|
|
4626
|
-
if (item.type === "function_call") toolCallCount += 1;
|
|
4627
|
+
if (item.type === "function_call" && item.name) toolCallCount += 1;
|
|
4628
|
+
if (item.type === "reasoning" && item.arbi?.step !== "goal") agentStepCount += 1;
|
|
4627
4629
|
}
|
|
4628
4630
|
callbacks.onOutputItemDone?.(data);
|
|
4629
4631
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
@@ -4791,6 +4793,7 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4791
4793
|
assistantMessageExtId,
|
|
4792
4794
|
agentSteps,
|
|
4793
4795
|
toolCallCount,
|
|
4796
|
+
agentStepCount,
|
|
4794
4797
|
errors,
|
|
4795
4798
|
userMessage,
|
|
4796
4799
|
metadata,
|
|
@@ -4805,7 +4808,8 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
4805
4808
|
function formatStreamSummary(result, elapsedTime) {
|
|
4806
4809
|
const parts = [];
|
|
4807
4810
|
if (result.agentSteps.length > 0) {
|
|
4808
|
-
|
|
4811
|
+
const steps = result.agentStepCount > 0 ? result.agentStepCount : result.agentSteps.length;
|
|
4812
|
+
let stepLabel = `${steps} step${steps === 1 ? "" : "s"}`;
|
|
4809
4813
|
if (result.toolCallCount > 0) {
|
|
4810
4814
|
stepLabel += ` (${result.toolCallCount} tool call${result.toolCallCount === 1 ? "" : "s"})`;
|
|
4811
4815
|
}
|
|
@@ -5585,7 +5589,7 @@ async function diagnoseSetup(options) {
|
|
|
5585
5589
|
);
|
|
5586
5590
|
return { ok: false, checks };
|
|
5587
5591
|
}
|
|
5588
|
-
const request = (
|
|
5592
|
+
const request = (path6, authenticated = false) => (options.fetch ?? globalThis.fetch)(`${base.href.replace(/\/$/, "")}${path6}`, {
|
|
5589
5593
|
method: "GET",
|
|
5590
5594
|
credentials: "omit",
|
|
5591
5595
|
redirect: "error",
|
|
@@ -7311,12 +7315,12 @@ async function prepareSecureMail(compose, sender, { requestId, senderPublicKey,
|
|
|
7311
7315
|
async function claimSecureMail(mail, id, fragmentKey, recipientPublicKey) {
|
|
7312
7316
|
const key = decodeSecureMailKey(fragmentKey);
|
|
7313
7317
|
try {
|
|
7314
|
-
const
|
|
7315
|
-
const response = await mail(
|
|
7318
|
+
const path6 = `/secure/${encodeURIComponent(id)}`;
|
|
7319
|
+
const response = await mail(path6);
|
|
7316
7320
|
const { raw } = await openSecureMail(await response.json(), key);
|
|
7317
7321
|
raw.fill(0);
|
|
7318
7322
|
const claim = await secureMailClaim(key, recipientPublicKey);
|
|
7319
|
-
const claimed = await mail(`${
|
|
7323
|
+
const claimed = await mail(`${path6}/claim`, { method: "POST", body: JSON.stringify(claim) });
|
|
7320
7324
|
return await claimed.json();
|
|
7321
7325
|
} finally {
|
|
7322
7326
|
key.fill(0);
|
|
@@ -9694,43 +9698,112 @@ async function confirmSpendLimits(arbi, projectExtId, body) {
|
|
|
9694
9698
|
"Failed to confirm spending limits"
|
|
9695
9699
|
);
|
|
9696
9700
|
}
|
|
9697
|
-
|
|
9701
|
+
|
|
9702
|
+
// src/operations/pages.ts
|
|
9703
|
+
var pages_exports = {};
|
|
9704
|
+
__export(pages_exports, {
|
|
9705
|
+
PagePrivateContentError: () => PagePrivateContentError,
|
|
9706
|
+
createPage: () => createPage,
|
|
9707
|
+
deletePage: () => deletePage,
|
|
9708
|
+
getPage: () => getPage,
|
|
9709
|
+
listPages: () => listPages,
|
|
9710
|
+
sharePage: () => sharePage,
|
|
9711
|
+
updatePage: () => updatePage
|
|
9712
|
+
});
|
|
9713
|
+
var PagePrivateContentError = class extends ArbiApiError {
|
|
9714
|
+
views;
|
|
9715
|
+
documents;
|
|
9716
|
+
constructor(message, views, documents, apiError) {
|
|
9717
|
+
super(message, apiError, 409, { code: "page_uses_private_content" });
|
|
9718
|
+
this.name = "PagePrivateContentError";
|
|
9719
|
+
this.views = views;
|
|
9720
|
+
this.documents = documents;
|
|
9721
|
+
}
|
|
9722
|
+
};
|
|
9698
9723
|
var decoder = new TextDecoder();
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
const
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9724
|
+
function refusal3(result, fallback) {
|
|
9725
|
+
if (!result.error) return null;
|
|
9726
|
+
const detail = result.error.detail;
|
|
9727
|
+
if (result.response?.status === 409 && detail?.code === "page_uses_private_content") {
|
|
9728
|
+
return new PagePrivateContentError(
|
|
9729
|
+
detail.message ?? fallback,
|
|
9730
|
+
detail.views ?? [],
|
|
9731
|
+
detail.documents ?? [],
|
|
9732
|
+
result.error
|
|
9733
|
+
);
|
|
9734
|
+
}
|
|
9735
|
+
return null;
|
|
9736
|
+
}
|
|
9737
|
+
function pageOf(row, keypair) {
|
|
9738
|
+
let legacyJson = null;
|
|
9739
|
+
if (row.sealed && keypair) {
|
|
9707
9740
|
try {
|
|
9708
|
-
|
|
9741
|
+
legacyJson = decoder.decode(sealedBoxDecrypt(row.sealed, keypair.secretKey));
|
|
9709
9742
|
} catch {
|
|
9710
9743
|
}
|
|
9711
|
-
|
|
9712
|
-
|
|
9744
|
+
}
|
|
9745
|
+
return {
|
|
9746
|
+
id: row.external_id,
|
|
9747
|
+
workspaceId: row.workspace_id ?? null,
|
|
9748
|
+
shared: row.shared,
|
|
9749
|
+
spec: row.spec ?? null,
|
|
9750
|
+
legacyJson,
|
|
9751
|
+
unreadable: !!row.sealed && legacyJson === null,
|
|
9752
|
+
viewIds: row.view_ids ?? [],
|
|
9753
|
+
documentIds: row.document_ids ?? [],
|
|
9754
|
+
createdBy: row.created_by ?? null,
|
|
9755
|
+
updatedBy: row.updated_by ?? null,
|
|
9756
|
+
createdAt: row.created_at,
|
|
9757
|
+
updatedAt: row.updated_at
|
|
9758
|
+
};
|
|
9713
9759
|
}
|
|
9714
|
-
async function
|
|
9715
|
-
const
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
}),
|
|
9721
|
-
"Failed to
|
|
9722
|
-
)
|
|
9723
|
-
|
|
9724
|
-
|
|
9760
|
+
async function pagesOf(rows, keypair) {
|
|
9761
|
+
const key = rows.some((r2) => r2.sealed) ? await keypair().catch(() => null) : null;
|
|
9762
|
+
return rows.map((r2) => pageOf(r2, key));
|
|
9763
|
+
}
|
|
9764
|
+
async function listPages(arbi, keypair, query2 = {}) {
|
|
9765
|
+
const rows = requireData(
|
|
9766
|
+
await arbi.fetch.GET("/v1/pages", { params: { query: query2 } }),
|
|
9767
|
+
"Failed to load the pages"
|
|
9768
|
+
);
|
|
9769
|
+
return pagesOf(rows, keypair);
|
|
9770
|
+
}
|
|
9771
|
+
async function getPage(arbi, keypair, id) {
|
|
9772
|
+
const row = requireData(
|
|
9773
|
+
await arbi.fetch.GET("/v1/pages/{page_id}", { params: { path: { page_id: id } } }),
|
|
9774
|
+
"Failed to open the page"
|
|
9725
9775
|
);
|
|
9726
|
-
return
|
|
9776
|
+
return (await pagesOf([row], keypair))[0];
|
|
9777
|
+
}
|
|
9778
|
+
async function createPage(arbi, page) {
|
|
9779
|
+
const result = await arbi.fetch.POST("/v1/pages", {
|
|
9780
|
+
body: { spec: page.spec, shared: page.shared ?? false }
|
|
9781
|
+
});
|
|
9782
|
+
const refused = refusal3(result, "The page could not be shared");
|
|
9783
|
+
if (refused) throw refused;
|
|
9784
|
+
return pageOf(requireData(result, "Failed to save the page"), null);
|
|
9785
|
+
}
|
|
9786
|
+
async function updatePage(arbi, id, spec) {
|
|
9787
|
+
const result = await arbi.fetch.PUT("/v1/pages/{page_id}", {
|
|
9788
|
+
params: { path: { page_id: id } },
|
|
9789
|
+
body: { spec }
|
|
9790
|
+
});
|
|
9791
|
+
const refused = refusal3(result, "The page could not be saved");
|
|
9792
|
+
if (refused) throw refused;
|
|
9793
|
+
return pageOf(requireData(result, "Failed to save the page"), null);
|
|
9727
9794
|
}
|
|
9728
|
-
async function
|
|
9795
|
+
async function sharePage(arbi, id) {
|
|
9796
|
+
const result = await arbi.fetch.POST("/v1/pages/{page_id}/share", {
|
|
9797
|
+
params: { path: { page_id: id } }
|
|
9798
|
+
});
|
|
9799
|
+
const refused = refusal3(result, "The page could not be shared");
|
|
9800
|
+
if (refused) throw refused;
|
|
9801
|
+
return pageOf(requireData(result, "Failed to share the page"), null);
|
|
9802
|
+
}
|
|
9803
|
+
async function deletePage(arbi, id) {
|
|
9729
9804
|
requireOk(
|
|
9730
|
-
await arbi.fetch.DELETE("/v1/
|
|
9731
|
-
|
|
9732
|
-
}),
|
|
9733
|
-
"Failed to delete the dashboard"
|
|
9805
|
+
await arbi.fetch.DELETE("/v1/pages/{page_id}", { params: { path: { page_id: id } } }),
|
|
9806
|
+
"Failed to delete the page"
|
|
9734
9807
|
);
|
|
9735
9808
|
}
|
|
9736
9809
|
|
|
@@ -9749,7 +9822,6 @@ __export(work_exports, {
|
|
|
9749
9822
|
listConversationPeople: () => listConversationPeople,
|
|
9750
9823
|
notifyConversation: () => notifyConversation,
|
|
9751
9824
|
planWork: () => planWork,
|
|
9752
|
-
removeConversationPerson: () => removeConversationPerson,
|
|
9753
9825
|
runConversation: () => runConversation,
|
|
9754
9826
|
sendBackStep: () => sendBackStep,
|
|
9755
9827
|
skipStep: () => skipStep,
|
|
@@ -10507,14 +10579,6 @@ async function listConversationPeople(arbi, conversationId) {
|
|
|
10507
10579
|
"Failed to fetch the people of the conversation"
|
|
10508
10580
|
);
|
|
10509
10581
|
}
|
|
10510
|
-
async function removeConversationPerson(arbi, conversationId, userId) {
|
|
10511
|
-
requireOk(
|
|
10512
|
-
await arbi.fetch.DELETE("/v1/conversation/{conversation_ext_id}/people/{user_ext_id}", {
|
|
10513
|
-
params: { path: { conversation_ext_id: conversationId, user_ext_id: userId } }
|
|
10514
|
-
}),
|
|
10515
|
-
"Failed to remove the person from the conversation"
|
|
10516
|
-
);
|
|
10517
|
-
}
|
|
10518
10582
|
async function getActivity(arbi, conversationId) {
|
|
10519
10583
|
return requireData(
|
|
10520
10584
|
await arbi.fetch.GET("/v1/conversation/{conversation_ext_id}/activity", byId(conversationId)),
|
|
@@ -10798,13 +10862,13 @@ async function addDatabaseRows(arbi, databaseId, rows, options = {}) {
|
|
|
10798
10862
|
"Failed to add rows"
|
|
10799
10863
|
);
|
|
10800
10864
|
}
|
|
10801
|
-
async function shareDatabaseRow(arbi, databaseId, rowId
|
|
10865
|
+
async function shareDatabaseRow(arbi, databaseId, rowId) {
|
|
10802
10866
|
return requireData(
|
|
10803
10867
|
await arbi.fetch.POST("/v1/databases/{database_id}/rows/{row_id}/share", {
|
|
10804
10868
|
params: { path: { database_id: databaseId, row_id: rowId } },
|
|
10805
|
-
body: { shared }
|
|
10869
|
+
body: { shared: true }
|
|
10806
10870
|
}),
|
|
10807
|
-
|
|
10871
|
+
"Failed to submit the row"
|
|
10808
10872
|
);
|
|
10809
10873
|
}
|
|
10810
10874
|
async function updateDatabaseRow(arbi, databaseId, rowId, values) {
|
|
@@ -10853,6 +10917,63 @@ async function exportDatabase(arbi, databaseId, format) {
|
|
|
10853
10917
|
);
|
|
10854
10918
|
}
|
|
10855
10919
|
|
|
10920
|
+
// src/operations/views.ts
|
|
10921
|
+
var views_exports = {};
|
|
10922
|
+
__export(views_exports, {
|
|
10923
|
+
DOCUMENTS_VIEW_TARGET: () => DOCUMENTS_VIEW_TARGET,
|
|
10924
|
+
createTableView: () => createTableView,
|
|
10925
|
+
deleteTableView: () => deleteTableView,
|
|
10926
|
+
filterText: () => filterText,
|
|
10927
|
+
getTableView: () => getTableView,
|
|
10928
|
+
listTableViews: () => listTableViews,
|
|
10929
|
+
shareTableView: () => shareTableView,
|
|
10930
|
+
updateTableView: () => updateTableView
|
|
10931
|
+
});
|
|
10932
|
+
var DOCUMENTS_VIEW_TARGET = "documents";
|
|
10933
|
+
var path3 = (viewId) => ({ path: { view_id: viewId } });
|
|
10934
|
+
async function listTableViews(arbi, target) {
|
|
10935
|
+
return requireData(
|
|
10936
|
+
await arbi.fetch.GET("/v1/views", { params: { query: target ? { target } : {} } }),
|
|
10937
|
+
"Failed to list the views"
|
|
10938
|
+
);
|
|
10939
|
+
}
|
|
10940
|
+
async function getTableView(arbi, viewId) {
|
|
10941
|
+
return requireData(
|
|
10942
|
+
await arbi.fetch.GET("/v1/views/{view_id}", { params: path3(viewId) }),
|
|
10943
|
+
"Failed to read the view"
|
|
10944
|
+
);
|
|
10945
|
+
}
|
|
10946
|
+
async function createTableView(arbi, target, spec, options = {}) {
|
|
10947
|
+
return requireData(
|
|
10948
|
+
await arbi.fetch.POST("/v1/views", {
|
|
10949
|
+
body: { target, spec, shared: options.shared ?? false }
|
|
10950
|
+
}),
|
|
10951
|
+
"Failed to save the view"
|
|
10952
|
+
);
|
|
10953
|
+
}
|
|
10954
|
+
async function updateTableView(arbi, viewId, spec) {
|
|
10955
|
+
return requireData(
|
|
10956
|
+
await arbi.fetch.PATCH("/v1/views/{view_id}", { params: path3(viewId), body: { spec } }),
|
|
10957
|
+
"Failed to update the view"
|
|
10958
|
+
);
|
|
10959
|
+
}
|
|
10960
|
+
async function shareTableView(arbi, viewId) {
|
|
10961
|
+
return requireData(
|
|
10962
|
+
await arbi.fetch.POST("/v1/views/{view_id}/share", { params: path3(viewId) }),
|
|
10963
|
+
"Failed to share the view"
|
|
10964
|
+
);
|
|
10965
|
+
}
|
|
10966
|
+
async function deleteTableView(arbi, viewId) {
|
|
10967
|
+
requireOk(
|
|
10968
|
+
await arbi.fetch.DELETE("/v1/views/{view_id}", { params: path3(viewId) }),
|
|
10969
|
+
"Failed to delete the view"
|
|
10970
|
+
);
|
|
10971
|
+
}
|
|
10972
|
+
function filterText(filter) {
|
|
10973
|
+
const value = filter.value;
|
|
10974
|
+
return value === null || value === void 0 || value === "" ? `${filter.column}:${filter.op}` : `${filter.column}:${filter.op}:${String(value)}`;
|
|
10975
|
+
}
|
|
10976
|
+
|
|
10856
10977
|
// src/operations/mail.ts
|
|
10857
10978
|
var mail_exports = {};
|
|
10858
10979
|
__export(mail_exports, {
|
|
@@ -10886,9 +11007,9 @@ __export(mail_exports, {
|
|
|
10886
11007
|
});
|
|
10887
11008
|
var NATIVE_ACCOUNT = "native";
|
|
10888
11009
|
function createMailFetch(auth) {
|
|
10889
|
-
return (
|
|
11010
|
+
return (path6, init = {}) => authenticatedFetch({
|
|
10890
11011
|
...auth,
|
|
10891
|
-
path: `/v1/mail${
|
|
11012
|
+
path: `/v1/mail${path6}`,
|
|
10892
11013
|
method: init.method,
|
|
10893
11014
|
body: init.body,
|
|
10894
11015
|
headers: {
|
|
@@ -11028,8 +11149,8 @@ function getMessage2(mail, messageId2, accountId = NATIVE_ACCOUNT) {
|
|
|
11028
11149
|
return json(mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId2)}`));
|
|
11029
11150
|
}
|
|
11030
11151
|
async function downloadAttachment(mail, messageId2, attachmentId, accountId = NATIVE_ACCOUNT) {
|
|
11031
|
-
const
|
|
11032
|
-
return new Uint8Array(await (await mail(
|
|
11152
|
+
const path6 = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId2)}/attachments/${encodeURIComponent(attachmentId)}`;
|
|
11153
|
+
return new Uint8Array(await (await mail(path6)).arrayBuffer());
|
|
11033
11154
|
}
|
|
11034
11155
|
async function updateMessage(mail, messageId2, update, accountId = NATIVE_ACCOUNT) {
|
|
11035
11156
|
await mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId2)}`, {
|
|
@@ -12885,21 +13006,22 @@ var Arbi = class {
|
|
|
12885
13006
|
*/
|
|
12886
13007
|
me: () => getCurrentUser(this.requireClient())
|
|
12887
13008
|
};
|
|
12888
|
-
// ──
|
|
12889
|
-
|
|
12890
|
-
/** The
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
),
|
|
12901
|
-
remove: (id) => deleteUserDashboard(this.requireClient(), id)
|
|
13009
|
+
// ── Pages (the open workspace's; private until shared) ──
|
|
13010
|
+
pages = {
|
|
13011
|
+
/** The open workspace's pages the user can see, oldest first (with their dashboards from
|
|
13012
|
+
* before pages, opened with their key). */
|
|
13013
|
+
list: (query2) => listPages(this.requireClient(), this.sealedPageKey, query2),
|
|
13014
|
+
get: (id) => getPage(this.requireClient(), this.sealedPageKey, id),
|
|
13015
|
+
/** Create a page, private unless `shared`. */
|
|
13016
|
+
create: (page) => createPage(this.requireClient(), page),
|
|
13017
|
+
/** Replace a page's spec (a dashboard from before pages is placed in the open workspace). */
|
|
13018
|
+
update: (id, spec) => updatePage(this.requireClient(), id, spec),
|
|
13019
|
+
/** Share a page with the workspace (one-way: a shared page stays shared). */
|
|
13020
|
+
share: (id) => sharePage(this.requireClient(), id),
|
|
13021
|
+
remove: (id) => deletePage(this.requireClient(), id)
|
|
12902
13022
|
};
|
|
13023
|
+
/** The user's own key, which opens their dashboards from before pages. */
|
|
13024
|
+
sealedPageKey = async () => (await this.requireChatCrypto()).encryptionKeypair;
|
|
12903
13025
|
// ── Firm ──────────────────────────────────────────────────────────────
|
|
12904
13026
|
firm = {
|
|
12905
13027
|
/** The firm's pooled monthly £ of AI usage (`has_pool` false where there is none). */
|
|
@@ -13309,9 +13431,9 @@ var Arbi = class {
|
|
|
13309
13431
|
await this.requireTargetWorkspace(options?.workspaceId)
|
|
13310
13432
|
),
|
|
13311
13433
|
/**
|
|
13312
|
-
* Patch a conversation: `title`, `shared` (
|
|
13313
|
-
* (`bound_document_ext_id`, `null` unbinds), and the work fields (`description`,
|
|
13314
|
-
* `parent_conversation_ext_id`, `status`, `plan`). The one call behind rename, share
|
|
13434
|
+
* Patch a conversation: `title`, `shared: true` (its creator only; sharing is one-way), its
|
|
13435
|
+
* bound document (`bound_document_ext_id`, `null` unbinds), and the work fields (`description`,
|
|
13436
|
+
* `due_at`, `parent_conversation_ext_id`, `status`, `plan`). The one call behind rename, share
|
|
13315
13437
|
* and attaching a thread to a document.
|
|
13316
13438
|
*/
|
|
13317
13439
|
update: (conversationId, body) => updateConversation(this.requireClient(), conversationId, body),
|
|
@@ -13347,8 +13469,6 @@ var Arbi = class {
|
|
|
13347
13469
|
notify: (conversationId, userIds) => notifyConversation(this.requireClient(), conversationId, userIds),
|
|
13348
13470
|
/** The people a conversation is shared with by name (cc'd or @mentioned). */
|
|
13349
13471
|
people: (conversationId) => listConversationPeople(this.requireClient(), conversationId),
|
|
13350
|
-
/** Take a named person off a conversation (a workspace owner only). */
|
|
13351
|
-
removePerson: (conversationId, userId) => removeConversationPerson(this.requireClient(), conversationId, userId),
|
|
13352
13472
|
/** Draft an editable plan from an objective, in the current workspace or `options.workspaceId`. */
|
|
13353
13473
|
plan: async (body, options) => planWork(
|
|
13354
13474
|
this.requireClient(),
|
|
@@ -13431,11 +13551,11 @@ var Arbi = class {
|
|
|
13431
13551
|
};
|
|
13432
13552
|
/** Authenticated native Word transport, with normal session recovery. */
|
|
13433
13553
|
editor = {
|
|
13434
|
-
request: (
|
|
13554
|
+
request: (path6, options = {}) => this.recovering(async () => {
|
|
13435
13555
|
const { baseUrl, accessToken, fetch: send = globalThis.fetch } = this.getAuthHeaders();
|
|
13436
13556
|
const headers = new Headers(options.headers);
|
|
13437
13557
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
13438
|
-
const response = await send(`${baseUrl}/v1/editor${
|
|
13558
|
+
const response = await send(`${baseUrl}/v1/editor${path6}`, { ...options, headers });
|
|
13439
13559
|
if (!response.ok) {
|
|
13440
13560
|
const body = await response.json().catch(() => null);
|
|
13441
13561
|
throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
|
|
@@ -13458,10 +13578,10 @@ var Arbi = class {
|
|
|
13458
13578
|
* With no token yet (a new tab) the session is restored first; a 401 re-logs in and is sent
|
|
13459
13579
|
* again once.
|
|
13460
13580
|
*/
|
|
13461
|
-
fetch: (
|
|
13462
|
-
const nativeRead =
|
|
13581
|
+
fetch: (path6, init = {}, { nativeUnlocked = false } = {}) => this.recovering(async () => {
|
|
13582
|
+
const nativeRead = path6.startsWith("/accounts/native/") && (init.method ?? "GET").toUpperCase() !== "POST";
|
|
13463
13583
|
if (nativeRead && !nativeUnlocked) await this.mail.unlockNative();
|
|
13464
|
-
return this.mailRequest(
|
|
13584
|
+
return this.mailRequest(path6, init);
|
|
13465
13585
|
}),
|
|
13466
13586
|
/**
|
|
13467
13587
|
* Unlock the signed-in user's native inbox for this server session (see `unlockNativeMail`).
|
|
@@ -13504,7 +13624,7 @@ var Arbi = class {
|
|
|
13504
13624
|
/** The native inbox unlock in flight (`mail.unlockNative`). */
|
|
13505
13625
|
nativeUnlock = null;
|
|
13506
13626
|
/** One request under `/v1/mail` on the session's token (see `mail.fetch`). */
|
|
13507
|
-
async mailRequest(
|
|
13627
|
+
async mailRequest(path6, init) {
|
|
13508
13628
|
const client = this.requireClient();
|
|
13509
13629
|
let token = client.session.getState().accessToken;
|
|
13510
13630
|
if (!token) token = await client.auth.relogin();
|
|
@@ -13514,7 +13634,7 @@ var Arbi = class {
|
|
|
13514
13634
|
const headers = new Headers(init.headers);
|
|
13515
13635
|
headers.set("Authorization", `Bearer ${bearer}`);
|
|
13516
13636
|
if (init.body && !headers.has("Content-Type")) headers.set("Content-Type", "application/json");
|
|
13517
|
-
return send(`${this.options.url}/v1/mail${
|
|
13637
|
+
return send(`${this.options.url}/v1/mail${path6}`, { ...init, headers });
|
|
13518
13638
|
};
|
|
13519
13639
|
let response = await request(token);
|
|
13520
13640
|
if (response.status === 401) {
|
|
@@ -14669,14 +14789,29 @@ var Arbi = class {
|
|
|
14669
14789
|
update: (databaseId, body) => updateDatabase(this.requireClient(), databaseId, body),
|
|
14670
14790
|
delete: (databaseId) => deleteDatabase(this.requireClient(), databaseId),
|
|
14671
14791
|
addRows: (databaseId, rows, options) => addDatabaseRows(this.requireClient(), databaseId, rows, options),
|
|
14672
|
-
/** Submit a draft row
|
|
14673
|
-
shareRow: (databaseId, rowId
|
|
14792
|
+
/** Submit a draft row: share it with the workspace (one-way: it never becomes a draft again). */
|
|
14793
|
+
shareRow: (databaseId, rowId) => shareDatabaseRow(this.requireClient(), databaseId, rowId),
|
|
14674
14794
|
updateRow: (databaseId, rowId, values) => updateDatabaseRow(this.requireClient(), databaseId, rowId, values),
|
|
14675
14795
|
deleteRows: (databaseId, ids) => deleteDatabaseRows(this.requireClient(), databaseId, ids),
|
|
14676
14796
|
import: (file, name) => importDatabase(this.requireClient(), file, name),
|
|
14677
14797
|
importRows: (databaseId, file) => importDatabaseRows(this.requireClient(), databaseId, file),
|
|
14678
14798
|
export: (databaseId, format) => exportDatabase(this.requireClient(), databaseId, format)
|
|
14679
14799
|
};
|
|
14800
|
+
// ── Table views (saved views of a database grid or the document table) ──
|
|
14801
|
+
/**
|
|
14802
|
+
* Saved views: private to their creator until shared with the workspace, for good (sharing is one
|
|
14803
|
+
* way); only a workspace owner deletes a shared view. `target` is a database id or `documents`.
|
|
14804
|
+
*/
|
|
14805
|
+
views = {
|
|
14806
|
+
/** The views the caller can see: of one table, or of every table of the open workspace. */
|
|
14807
|
+
list: (target) => listTableViews(this.requireClient(), target),
|
|
14808
|
+
get: (viewId) => getTableView(this.requireClient(), viewId),
|
|
14809
|
+
create: (target, spec, options) => createTableView(this.requireClient(), target, spec, options),
|
|
14810
|
+
update: (viewId, spec) => updateTableView(this.requireClient(), viewId, spec),
|
|
14811
|
+
/** Share with the workspace (one way: it is never made private again). */
|
|
14812
|
+
share: (viewId) => shareTableView(this.requireClient(), viewId),
|
|
14813
|
+
remove: (viewId) => deleteTableView(this.requireClient(), viewId)
|
|
14814
|
+
};
|
|
14680
14815
|
// ── Workspace facts ─────────────────────────────────────────────────
|
|
14681
14816
|
/**
|
|
14682
14817
|
* Notes. Create, list and search act in the current workspace, or `workspaceId` (opened for this
|
|
@@ -14776,16 +14911,16 @@ function collectFiles(dirPath, baseDir) {
|
|
|
14776
14911
|
const root = baseDir ?? dirPath;
|
|
14777
14912
|
const results = [];
|
|
14778
14913
|
for (const entry of fs2.readdirSync(dirPath, { withFileTypes: true })) {
|
|
14779
|
-
const fullPath =
|
|
14914
|
+
const fullPath = path4.join(dirPath, entry.name);
|
|
14780
14915
|
if (entry.isDirectory()) {
|
|
14781
14916
|
results.push(...collectFiles(fullPath, root));
|
|
14782
14917
|
} else if (entry.isFile()) {
|
|
14783
|
-
const ext =
|
|
14918
|
+
const ext = path4.extname(entry.name).toLowerCase();
|
|
14784
14919
|
if (SUPPORTED_EXTENSIONS.has(ext)) {
|
|
14785
14920
|
const stat = fs2.statSync(fullPath);
|
|
14786
14921
|
results.push({
|
|
14787
14922
|
absolutePath: fullPath,
|
|
14788
|
-
relativePath:
|
|
14923
|
+
relativePath: path4.relative(root, fullPath),
|
|
14789
14924
|
size: stat.size
|
|
14790
14925
|
});
|
|
14791
14926
|
}
|
|
@@ -14821,14 +14956,14 @@ function readFileAsBlob(filePath, fileSize, fileName) {
|
|
|
14821
14956
|
}
|
|
14822
14957
|
async function uploadLocalFile(auth, filePath, options) {
|
|
14823
14958
|
const stat = fs2.statSync(filePath);
|
|
14824
|
-
const fileName =
|
|
14959
|
+
const fileName = path4.basename(filePath);
|
|
14825
14960
|
const blob = readFileAsBlob(filePath, stat.size, fileName);
|
|
14826
14961
|
const result = await uploadFile(auth, blob, fileName, options);
|
|
14827
14962
|
return { ...result, fileName };
|
|
14828
14963
|
}
|
|
14829
14964
|
async function uploadLocalFilesDirect(arbi, workspaceKey, filePaths, options) {
|
|
14830
14965
|
const files = filePaths.map((fp) => {
|
|
14831
|
-
const resolved =
|
|
14966
|
+
const resolved = path4.resolve(fp);
|
|
14832
14967
|
const stat = fs2.statSync(resolved);
|
|
14833
14968
|
if (stat.size > NODE_BUFFER_LIMIT) {
|
|
14834
14969
|
throw new Error(
|
|
@@ -14836,9 +14971,9 @@ async function uploadLocalFilesDirect(arbi, workspaceKey, filePaths, options) {
|
|
|
14836
14971
|
);
|
|
14837
14972
|
}
|
|
14838
14973
|
return {
|
|
14839
|
-
name:
|
|
14974
|
+
name: path4.basename(resolved),
|
|
14840
14975
|
data: new Uint8Array(fs2.readFileSync(resolved)),
|
|
14841
|
-
contentType: mimeFromName(
|
|
14976
|
+
contentType: mimeFromName(path4.basename(resolved))
|
|
14842
14977
|
};
|
|
14843
14978
|
});
|
|
14844
14979
|
return uploadDocumentsDirect(arbi, workspaceKey, files, options);
|
|
@@ -14887,8 +15022,8 @@ async function runGroupedDirectUpload(arbi, workspaceKey, groups, options) {
|
|
|
14887
15022
|
return { doc_ext_ids: allDocIds, skipped: allSkipped, folders };
|
|
14888
15023
|
}
|
|
14889
15024
|
async function uploadLocalDirectoryDirect(arbi, workspaceKey, dirPath, options) {
|
|
14890
|
-
const resolvedDir =
|
|
14891
|
-
const dirName =
|
|
15025
|
+
const resolvedDir = path4.resolve(dirPath);
|
|
15026
|
+
const dirName = path4.basename(resolvedDir);
|
|
14892
15027
|
const entries = collectFiles(resolvedDir);
|
|
14893
15028
|
if (entries.length === 0) {
|
|
14894
15029
|
return { doc_ext_ids: [], skipped: [], folders: /* @__PURE__ */ new Map() };
|
|
@@ -14900,9 +15035,9 @@ async function uploadLocalDirectoryDirect(arbi, workspaceKey, dirPath, options)
|
|
|
14900
15035
|
`File ${entry.absolutePath} is ${entry.size} bytes \u2014 direct upload currently loads the full file into memory; skip --s3 for files > 2 GiB.`
|
|
14901
15036
|
);
|
|
14902
15037
|
}
|
|
14903
|
-
const relDir =
|
|
15038
|
+
const relDir = path4.dirname(entry.relativePath);
|
|
14904
15039
|
const folder = sanitizeFolderPath(relDir === "." ? dirName : `${dirName}/${relDir}`);
|
|
14905
|
-
const name =
|
|
15040
|
+
const name = path4.basename(entry.relativePath);
|
|
14906
15041
|
if (!buckets.has(folder)) buckets.set(folder, []);
|
|
14907
15042
|
buckets.get(folder).push({
|
|
14908
15043
|
name,
|
|
@@ -14918,11 +15053,11 @@ async function uploadLocalZipDirect(arbi, workspaceKey, zipPath, options) {
|
|
|
14918
15053
|
const JSZip = (await import('jszip')).default;
|
|
14919
15054
|
const zipBuffer = fs2.readFileSync(zipPath);
|
|
14920
15055
|
const zip = await JSZip.loadAsync(zipBuffer);
|
|
14921
|
-
const zipBaseName =
|
|
15056
|
+
const zipBaseName = path4.basename(zipPath).replace(/\.zip$/i, "");
|
|
14922
15057
|
const entries = [];
|
|
14923
15058
|
zip.forEach((relativePath, zipEntry) => {
|
|
14924
15059
|
if (zipEntry.dir) return;
|
|
14925
|
-
const ext =
|
|
15060
|
+
const ext = path4.extname(relativePath).toLowerCase();
|
|
14926
15061
|
if (SUPPORTED_EXTENSIONS.has(ext)) {
|
|
14927
15062
|
entries.push({ zipEntryPath: relativePath, zipEntry });
|
|
14928
15063
|
}
|
|
@@ -14935,8 +15070,8 @@ async function uploadLocalZipDirect(arbi, workspaceKey, zipPath, options) {
|
|
|
14935
15070
|
const buckets = /* @__PURE__ */ new Map();
|
|
14936
15071
|
for (const entry of entries) {
|
|
14937
15072
|
const data = await entry.zipEntry.async("uint8array");
|
|
14938
|
-
const fileName =
|
|
14939
|
-
const relDir =
|
|
15073
|
+
const fileName = path4.basename(entry.zipEntryPath);
|
|
15074
|
+
const relDir = path4.dirname(entry.zipEntryPath);
|
|
14940
15075
|
let folder;
|
|
14941
15076
|
if (hasSingleRoot) {
|
|
14942
15077
|
folder = relDir === "." ? zipBaseName : relDir;
|
|
@@ -14961,17 +15096,17 @@ async function uploadLocalArchiveDirect(arbi, workspaceKey, archivePath, options
|
|
|
14961
15096
|
} catch {
|
|
14962
15097
|
throw new Error("7z is not installed. Install p7zip-full to extract archives.");
|
|
14963
15098
|
}
|
|
14964
|
-
const tmpDir = fs2.mkdtempSync(
|
|
15099
|
+
const tmpDir = fs2.mkdtempSync(path4.join(os2.tmpdir(), "arbi-archive-"));
|
|
14965
15100
|
let uploadDir;
|
|
14966
15101
|
let namedDir;
|
|
14967
15102
|
try {
|
|
14968
|
-
execSync(`7z x -y -o"${tmpDir}" "${
|
|
15103
|
+
execSync(`7z x -y -o"${tmpDir}" "${path4.resolve(archivePath)}"`, { stdio: "ignore" });
|
|
14969
15104
|
const topLevel = fs2.readdirSync(tmpDir);
|
|
14970
|
-
if (topLevel.length === 1 && fs2.statSync(
|
|
14971
|
-
uploadDir =
|
|
15105
|
+
if (topLevel.length === 1 && fs2.statSync(path4.join(tmpDir, topLevel[0])).isDirectory()) {
|
|
15106
|
+
uploadDir = path4.join(tmpDir, topLevel[0]);
|
|
14972
15107
|
} else {
|
|
14973
|
-
const baseName =
|
|
14974
|
-
namedDir =
|
|
15108
|
+
const baseName = path4.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
|
|
15109
|
+
namedDir = path4.join(path4.dirname(tmpDir), baseName);
|
|
14975
15110
|
fs2.renameSync(tmpDir, namedDir);
|
|
14976
15111
|
uploadDir = namedDir;
|
|
14977
15112
|
}
|
|
@@ -14986,20 +15121,20 @@ async function uploadLocalArchiveDirect(arbi, workspaceKey, archivePath, options
|
|
|
14986
15121
|
}
|
|
14987
15122
|
}
|
|
14988
15123
|
async function uploadDirectory(auth, dirPath, options) {
|
|
14989
|
-
const resolvedDir =
|
|
14990
|
-
const dirName =
|
|
15124
|
+
const resolvedDir = path4.resolve(dirPath);
|
|
15125
|
+
const dirName = path4.basename(resolvedDir);
|
|
14991
15126
|
const entries = collectFiles(resolvedDir);
|
|
14992
15127
|
if (entries.length === 0) {
|
|
14993
15128
|
return { doc_ext_ids: [], skipped: [], folders: /* @__PURE__ */ new Map() };
|
|
14994
15129
|
}
|
|
14995
15130
|
const groups = /* @__PURE__ */ new Map();
|
|
14996
15131
|
for (const entry of entries) {
|
|
14997
|
-
const relDir =
|
|
15132
|
+
const relDir = path4.dirname(entry.relativePath);
|
|
14998
15133
|
const folder = relDir === "." ? dirName : `${dirName}/${relDir}`;
|
|
14999
15134
|
if (!groups.has(folder)) groups.set(folder, []);
|
|
15000
15135
|
groups.get(folder).push({
|
|
15001
15136
|
absolutePath: entry.absolutePath,
|
|
15002
|
-
name:
|
|
15137
|
+
name: path4.basename(entry.relativePath),
|
|
15003
15138
|
size: entry.size
|
|
15004
15139
|
});
|
|
15005
15140
|
}
|
|
@@ -15085,11 +15220,11 @@ async function uploadZip(auth, zipPath, options) {
|
|
|
15085
15220
|
const JSZip = (await import('jszip')).default;
|
|
15086
15221
|
const zipBuffer = fs2.readFileSync(zipPath);
|
|
15087
15222
|
const zip = await JSZip.loadAsync(zipBuffer);
|
|
15088
|
-
const zipBaseName =
|
|
15223
|
+
const zipBaseName = path4.basename(zipPath).replace(/\.zip$/i, "");
|
|
15089
15224
|
const entries = [];
|
|
15090
15225
|
zip.forEach((relativePath, zipEntry) => {
|
|
15091
15226
|
if (zipEntry.dir) return;
|
|
15092
|
-
const ext =
|
|
15227
|
+
const ext = path4.extname(relativePath).toLowerCase();
|
|
15093
15228
|
if (SUPPORTED_EXTENSIONS.has(ext)) {
|
|
15094
15229
|
entries.push({ zipEntryPath: relativePath, zipEntry });
|
|
15095
15230
|
}
|
|
@@ -15102,8 +15237,8 @@ async function uploadZip(auth, zipPath, options) {
|
|
|
15102
15237
|
const groups = /* @__PURE__ */ new Map();
|
|
15103
15238
|
for (const entry of entries) {
|
|
15104
15239
|
const data = await entry.zipEntry.async("uint8array");
|
|
15105
|
-
const fileName =
|
|
15106
|
-
const relDir =
|
|
15240
|
+
const fileName = path4.basename(entry.zipEntryPath);
|
|
15241
|
+
const relDir = path4.dirname(entry.zipEntryPath);
|
|
15107
15242
|
let folder;
|
|
15108
15243
|
if (hasSingleRoot) {
|
|
15109
15244
|
folder = relDir === "." ? zipBaseName : relDir;
|
|
@@ -15173,9 +15308,9 @@ async function uploadZip(auth, zipPath, options) {
|
|
|
15173
15308
|
return { doc_ext_ids: allDocIds, skipped: allSkipped, folders };
|
|
15174
15309
|
}
|
|
15175
15310
|
function commonParentDir(absolutePaths) {
|
|
15176
|
-
if (absolutePaths.length === 0) return
|
|
15177
|
-
if (absolutePaths.length === 1) return
|
|
15178
|
-
const split = absolutePaths.map((p2) =>
|
|
15311
|
+
if (absolutePaths.length === 0) return path4.sep;
|
|
15312
|
+
if (absolutePaths.length === 1) return path4.dirname(absolutePaths[0]);
|
|
15313
|
+
const split = absolutePaths.map((p2) => path4.dirname(p2).split(path4.sep));
|
|
15179
15314
|
const minLen = Math.min(...split.map((s2) => s2.length));
|
|
15180
15315
|
const common = [];
|
|
15181
15316
|
for (let i2 = 0; i2 < minLen; i2++) {
|
|
@@ -15183,21 +15318,21 @@ function commonParentDir(absolutePaths) {
|
|
|
15183
15318
|
if (split.every((s2) => s2[i2] === seg)) common.push(seg);
|
|
15184
15319
|
else break;
|
|
15185
15320
|
}
|
|
15186
|
-
const joined = common.join(
|
|
15187
|
-
return joined ||
|
|
15321
|
+
const joined = common.join(path4.sep);
|
|
15322
|
+
return joined || path4.sep;
|
|
15188
15323
|
}
|
|
15189
15324
|
function deriveFolder(absolutePath, rootDir, rootBasename) {
|
|
15190
|
-
const parent =
|
|
15191
|
-
const rel =
|
|
15325
|
+
const parent = path4.dirname(absolutePath);
|
|
15326
|
+
const rel = path4.relative(rootDir, parent);
|
|
15192
15327
|
let folderPath;
|
|
15193
15328
|
if (rel === "" || rel === ".") {
|
|
15194
15329
|
folderPath = rootBasename;
|
|
15195
15330
|
} else if (rel.startsWith("..")) {
|
|
15196
|
-
folderPath =
|
|
15331
|
+
folderPath = path4.basename(parent) || rootBasename;
|
|
15197
15332
|
} else {
|
|
15198
|
-
folderPath =
|
|
15333
|
+
folderPath = path4.join(rootBasename, rel);
|
|
15199
15334
|
}
|
|
15200
|
-
return sanitizeFolderPath(folderPath.split(
|
|
15335
|
+
return sanitizeFolderPath(folderPath.split(path4.sep).join("/"));
|
|
15201
15336
|
}
|
|
15202
15337
|
function classifySkipReason(reason) {
|
|
15203
15338
|
const lower = reason.toLowerCase();
|
|
@@ -15238,9 +15373,9 @@ async function uploadManifest(auth, paths, options) {
|
|
|
15238
15373
|
if (options?.failFast && o2.status === "error") abortedByFailFast = true;
|
|
15239
15374
|
};
|
|
15240
15375
|
const prepared = [];
|
|
15241
|
-
const absoluteInputs = paths.map((p2) =>
|
|
15242
|
-
const rootDir = options?.rootDir ?
|
|
15243
|
-
const rootBasename =
|
|
15376
|
+
const absoluteInputs = paths.map((p2) => path4.resolve(p2));
|
|
15377
|
+
const rootDir = options?.rootDir ? path4.resolve(options.rootDir) : commonParentDir(absoluteInputs);
|
|
15378
|
+
const rootBasename = path4.basename(rootDir) || "root";
|
|
15244
15379
|
for (let i2 = 0; i2 < paths.length; i2++) {
|
|
15245
15380
|
if (options?.signal?.aborted || abortedByFailFast) {
|
|
15246
15381
|
await emit({
|
|
@@ -15278,7 +15413,7 @@ async function uploadManifest(auth, paths, options) {
|
|
|
15278
15413
|
});
|
|
15279
15414
|
continue;
|
|
15280
15415
|
}
|
|
15281
|
-
const ext =
|
|
15416
|
+
const ext = path4.extname(abs).toLowerCase();
|
|
15282
15417
|
if (!SUPPORTED_EXTENSIONS.has(ext)) {
|
|
15283
15418
|
await emit({
|
|
15284
15419
|
path: inputPath,
|
|
@@ -15305,7 +15440,7 @@ async function uploadManifest(auth, paths, options) {
|
|
|
15305
15440
|
prepared.push({
|
|
15306
15441
|
inputPath,
|
|
15307
15442
|
absolutePath: abs,
|
|
15308
|
-
basename:
|
|
15443
|
+
basename: path4.basename(abs),
|
|
15309
15444
|
folder: deriveFolder(abs, rootDir, rootBasename),
|
|
15310
15445
|
size: stat.size
|
|
15311
15446
|
});
|
|
@@ -15460,7 +15595,7 @@ async function uploadManifest(auth, paths, options) {
|
|
|
15460
15595
|
}
|
|
15461
15596
|
function walkSupportedFiles(dirPath) {
|
|
15462
15597
|
const out = [];
|
|
15463
|
-
const resolved =
|
|
15598
|
+
const resolved = path4.resolve(dirPath);
|
|
15464
15599
|
const stack = [resolved];
|
|
15465
15600
|
while (stack.length > 0) {
|
|
15466
15601
|
const current = stack.pop();
|
|
@@ -15471,11 +15606,11 @@ function walkSupportedFiles(dirPath) {
|
|
|
15471
15606
|
continue;
|
|
15472
15607
|
}
|
|
15473
15608
|
for (const entry of entries) {
|
|
15474
|
-
const full =
|
|
15609
|
+
const full = path4.join(current, entry.name);
|
|
15475
15610
|
if (entry.isDirectory()) {
|
|
15476
15611
|
stack.push(full);
|
|
15477
15612
|
} else if (entry.isFile()) {
|
|
15478
|
-
const ext =
|
|
15613
|
+
const ext = path4.extname(entry.name).toLowerCase();
|
|
15479
15614
|
if (SUPPORTED_EXTENSIONS.has(ext)) out.push(full);
|
|
15480
15615
|
}
|
|
15481
15616
|
}
|
|
@@ -15488,16 +15623,16 @@ async function uploadArchive(auth, archivePath, options) {
|
|
|
15488
15623
|
} catch {
|
|
15489
15624
|
throw new Error("7z is not installed. Install p7zip-full to extract archives.");
|
|
15490
15625
|
}
|
|
15491
|
-
const tmpDir = fs2.mkdtempSync(
|
|
15626
|
+
const tmpDir = fs2.mkdtempSync(path4.join(os2.tmpdir(), "arbi-archive-"));
|
|
15492
15627
|
try {
|
|
15493
|
-
execSync(`7z x -y -o"${tmpDir}" "${
|
|
15628
|
+
execSync(`7z x -y -o"${tmpDir}" "${path4.resolve(archivePath)}"`, { stdio: "ignore" });
|
|
15494
15629
|
const topLevel = fs2.readdirSync(tmpDir);
|
|
15495
15630
|
let uploadDir;
|
|
15496
|
-
if (topLevel.length === 1 && fs2.statSync(
|
|
15497
|
-
uploadDir =
|
|
15631
|
+
if (topLevel.length === 1 && fs2.statSync(path4.join(tmpDir, topLevel[0])).isDirectory()) {
|
|
15632
|
+
uploadDir = path4.join(tmpDir, topLevel[0]);
|
|
15498
15633
|
} else {
|
|
15499
|
-
const baseName =
|
|
15500
|
-
const namedDir =
|
|
15634
|
+
const baseName = path4.basename(archivePath).replace(/\.(7z|rar|zip)$/i, "");
|
|
15635
|
+
const namedDir = path4.join(path4.dirname(tmpDir), baseName);
|
|
15501
15636
|
fs2.renameSync(tmpDir, namedDir);
|
|
15502
15637
|
uploadDir = namedDir;
|
|
15503
15638
|
}
|
|
@@ -15513,8 +15648,8 @@ __export(mail_node_exports, {
|
|
|
15513
15648
|
attachmentFromFile: () => attachmentFromFile
|
|
15514
15649
|
});
|
|
15515
15650
|
function attachmentFromFile(filePath) {
|
|
15516
|
-
const resolved =
|
|
15517
|
-
const name =
|
|
15651
|
+
const resolved = path4.resolve(filePath);
|
|
15652
|
+
const name = path4.basename(resolved);
|
|
15518
15653
|
return attachmentFromBytes(
|
|
15519
15654
|
name,
|
|
15520
15655
|
mimeFromName(name) || "application/octet-stream",
|
|
@@ -16560,6 +16695,6 @@ function composeTools(base, next, mode) {
|
|
|
16560
16695
|
return structuredClone(mode === "add" ? { ...base, ...next } : next);
|
|
16561
16696
|
}
|
|
16562
16697
|
|
|
16563
|
-
export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ArbiStructuredOutputError, ArbiTransportError, ArbiWorkspaceChangedError, ArbiWorkspaceSupersededError, ArbiWorkspaceUnavailableError, 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, ResponseStream, 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, capabilities, chats_exports as chats, composeConfiguration, composeTools, computeRunStats, connectErrorMessage, connectWebSocket, connectWithReconnect, connectors_exports as connectors, contacts_exports as contacts, continuityPrompt, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, createIndexAssigner, databases_exports as databases, defaultKindForFormat, device_flow_exports as deviceFlow, diagnoseSetup, doctags_exports as doctags, documentTools, 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, instructions, 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, mcpTools, mergeAgentSteps, model_connections_exports as modelConnections, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, parseStructuredResponse, 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, secure_mail_exports as secureMail, selectFullContextDocument, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, sliceToSubagentThread, startDmListener, streamSSE, stripCitationMarkdown, subagentJobLabel, summarizeCitations, support_exports as support, tagUseCount, tags_exports as tags, tagsForScope, tagsOfGroup, topLevelAgentSteps, uploadSkill, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspace_assistant_exports as workspaceAssistant, workspaceConflictOf, workspaces_exports as workspaces, wouldCreateTagCycle };
|
|
16698
|
+
export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ArbiStructuredOutputError, ArbiTransportError, ArbiWorkspaceChangedError, ArbiWorkspaceSupersededError, ArbiWorkspaceUnavailableError, CallApiError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOCUMENTS_VIEW_TARGET, 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, PagePrivateContentError, PlanStepsError, PublicBookingError, ResponseStream, 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, capabilities, chats_exports as chats, composeConfiguration, composeTools, computeRunStats, connectErrorMessage, connectWebSocket, connectWithReconnect, connectors_exports as connectors, contacts_exports as contacts, continuityPrompt, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, createIndexAssigner, databases_exports as databases, defaultKindForFormat, device_flow_exports as deviceFlow, diagnoseSetup, doctags_exports as doctags, documentTools, documents_exports as documents, documents_node_exports as documentsNode, estimateDraftTokens, extractDocumentIdsFromMessages, extractFactIdsFromMessages, extractSubagentLanes, facts_exports as facts, files_exports as files, filterDocumentTags, filterSkills, filterText, 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, instructions, 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, mcpTools, mergeAgentSteps, model_connections_exports as modelConnections, notifications_exports as notifications, pages_exports as pages, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, parseStructuredResponse, 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, secure_mail_exports as secureMail, selectFullContextDocument, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, sliceToSubagentThread, startDmListener, streamSSE, stripCitationMarkdown, subagentJobLabel, summarizeCitations, support_exports as support, tagUseCount, tags_exports as tags, tagsForScope, tagsOfGroup, topLevelAgentSteps, uploadSkill, usdToGbp, views_exports as views, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspace_assistant_exports as workspaceAssistant, workspaceConflictOf, workspaces_exports as workspaces, wouldCreateTagCycle };
|
|
16564
16699
|
//# sourceMappingURL=index.js.map
|
|
16565
16700
|
//# sourceMappingURL=index.js.map
|