@arbidocs/sdk 0.4.27 → 0.4.28
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-C9-wve7D.d.cts → browser-AwN8DBBO.d.cts} +501 -45
- package/dist/{browser-C9-wve7D.d.ts → browser-AwN8DBBO.d.ts} +501 -45
- package/dist/browser.cjs +176 -67
- 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 +176 -67
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +182 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -335
- package/dist/index.d.ts +4 -335
- package/dist/index.js +182 -68
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/browser.cjs
CHANGED
|
@@ -3502,19 +3502,21 @@ function apiErrorDetail(apiError) {
|
|
|
3502
3502
|
return detailText(body.detail) || (typeof body.message === "string" ? body.message : void 0);
|
|
3503
3503
|
}
|
|
3504
3504
|
var ArbiApiError = class extends ArbiError {
|
|
3505
|
+
status;
|
|
3505
3506
|
apiError;
|
|
3506
3507
|
/** Why the server refused, in its words (e.g. "run_at must be in the future"), when it said. */
|
|
3507
3508
|
detail;
|
|
3508
|
-
constructor(message, apiError) {
|
|
3509
|
+
constructor(message, apiError, status) {
|
|
3509
3510
|
super(message);
|
|
3510
3511
|
this.name = "ArbiApiError";
|
|
3511
3512
|
this.apiError = apiError;
|
|
3513
|
+
this.status = status;
|
|
3512
3514
|
this.detail = apiErrorDetail(apiError);
|
|
3513
3515
|
}
|
|
3514
3516
|
};
|
|
3515
3517
|
function requireData(result, message) {
|
|
3516
3518
|
if (result.error || !result.data) {
|
|
3517
|
-
throw new ArbiApiError(message, result.error);
|
|
3519
|
+
throw new ArbiApiError(message, result.error, result.response?.status);
|
|
3518
3520
|
}
|
|
3519
3521
|
return result.data;
|
|
3520
3522
|
}
|
|
@@ -4873,6 +4875,7 @@ __export(assistant_exports, {
|
|
|
4873
4875
|
buildRetrievalChunkTool: () => buildRetrievalChunkTool,
|
|
4874
4876
|
buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
|
|
4875
4877
|
buildRetrievalTocTool: () => buildRetrievalTocTool,
|
|
4878
|
+
cancelAssistantRun: () => cancelAssistantRun,
|
|
4876
4879
|
filterSkills: () => filterSkills,
|
|
4877
4880
|
listCommands: () => listCommands,
|
|
4878
4881
|
listSkills: () => listSkills,
|
|
@@ -4948,6 +4951,9 @@ async function queryAssistant(options) {
|
|
|
4948
4951
|
question,
|
|
4949
4952
|
docIds,
|
|
4950
4953
|
previousResponseId,
|
|
4954
|
+
conversationId,
|
|
4955
|
+
assistantMode,
|
|
4956
|
+
agentId,
|
|
4951
4957
|
model,
|
|
4952
4958
|
mentions,
|
|
4953
4959
|
signal,
|
|
@@ -4958,14 +4964,17 @@ async function queryAssistant(options) {
|
|
|
4958
4964
|
input: question,
|
|
4959
4965
|
...activeArtifactExtId ? { active_artifact_ext_id: activeArtifactExtId } : {},
|
|
4960
4966
|
workspace_ext_id: workspaceId,
|
|
4967
|
+
...agentId ? { agent_ext_id: agentId } : {},
|
|
4961
4968
|
stream: true,
|
|
4962
4969
|
background: false,
|
|
4963
4970
|
store: true,
|
|
4964
|
-
tools: {
|
|
4971
|
+
tools: agentId ? {} : {
|
|
4965
4972
|
retrieval_chunk: buildRetrievalChunkTool(docIds),
|
|
4966
4973
|
retrieval_full_context: buildRetrievalFullContextTool([])
|
|
4967
4974
|
},
|
|
4968
4975
|
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
4976
|
+
...conversationId ? { conversation_ext_id: conversationId } : {},
|
|
4977
|
+
...assistantMode ? { assistant_mode: assistantMode } : {},
|
|
4969
4978
|
...model ? { model } : {},
|
|
4970
4979
|
...mentions && mentions.length > 0 ? { mentions } : {}
|
|
4971
4980
|
};
|
|
@@ -5027,6 +5036,91 @@ function filterSkills(items, query, pinned = []) {
|
|
|
5027
5036
|
});
|
|
5028
5037
|
return matched;
|
|
5029
5038
|
}
|
|
5039
|
+
async function cancelAssistantRun(auth, responseId) {
|
|
5040
|
+
await authenticatedFetch({
|
|
5041
|
+
...auth,
|
|
5042
|
+
path: `/v1/assistant/run/${encodeURIComponent(responseId)}/cancel`,
|
|
5043
|
+
method: "POST"
|
|
5044
|
+
});
|
|
5045
|
+
}
|
|
5046
|
+
|
|
5047
|
+
// src/operations/responses.ts
|
|
5048
|
+
var responses_exports = {};
|
|
5049
|
+
__export(responses_exports, {
|
|
5050
|
+
extractResponseText: () => extractResponseText,
|
|
5051
|
+
getResponse: () => getResponse,
|
|
5052
|
+
submitBackgroundQuery: () => submitBackgroundQuery
|
|
5053
|
+
});
|
|
5054
|
+
async function submitBackgroundQuery(options) {
|
|
5055
|
+
const {
|
|
5056
|
+
workspaceId,
|
|
5057
|
+
question,
|
|
5058
|
+
docIds,
|
|
5059
|
+
previousResponseId,
|
|
5060
|
+
model,
|
|
5061
|
+
task,
|
|
5062
|
+
conversationId,
|
|
5063
|
+
mentions,
|
|
5064
|
+
activeArtifactExtId,
|
|
5065
|
+
...auth
|
|
5066
|
+
} = options;
|
|
5067
|
+
const tools = {};
|
|
5068
|
+
if (docIds.length > 0) {
|
|
5069
|
+
tools.retrieval_chunk = {
|
|
5070
|
+
name: "retrieval_chunk",
|
|
5071
|
+
description: "retrieval chunk",
|
|
5072
|
+
tool_args: { doc_ext_ids: docIds },
|
|
5073
|
+
tool_responses: {}
|
|
5074
|
+
};
|
|
5075
|
+
tools.retrieval_full_context = {
|
|
5076
|
+
name: "retrieval_full_context",
|
|
5077
|
+
description: "retrieval full context",
|
|
5078
|
+
tool_args: { doc_ext_ids: docIds },
|
|
5079
|
+
tool_responses: {}
|
|
5080
|
+
};
|
|
5081
|
+
}
|
|
5082
|
+
const body = {
|
|
5083
|
+
input: question,
|
|
5084
|
+
workspace_ext_id: workspaceId,
|
|
5085
|
+
stream: false,
|
|
5086
|
+
background: true,
|
|
5087
|
+
store: true,
|
|
5088
|
+
tools,
|
|
5089
|
+
...task !== void 0 ? { task } : {},
|
|
5090
|
+
...conversationId ? { conversation_ext_id: conversationId } : {},
|
|
5091
|
+
...mentions !== void 0 ? { mentions } : {},
|
|
5092
|
+
...activeArtifactExtId ? { active_artifact_ext_id: activeArtifactExtId } : {},
|
|
5093
|
+
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
5094
|
+
...model ? { model } : {}
|
|
5095
|
+
};
|
|
5096
|
+
const res = await authenticatedFetch({
|
|
5097
|
+
...auth,
|
|
5098
|
+
path: "/v1/responses",
|
|
5099
|
+
method: "POST",
|
|
5100
|
+
body: JSON.stringify(body),
|
|
5101
|
+
headers: { "Content-Type": "application/json" }
|
|
5102
|
+
});
|
|
5103
|
+
return await res.json();
|
|
5104
|
+
}
|
|
5105
|
+
async function getResponse(auth, responseId) {
|
|
5106
|
+
const res = await authenticatedFetch({
|
|
5107
|
+
...auth,
|
|
5108
|
+
path: `/v1/responses/${responseId}`,
|
|
5109
|
+
method: "GET"
|
|
5110
|
+
});
|
|
5111
|
+
return await res.json();
|
|
5112
|
+
}
|
|
5113
|
+
function extractResponseText(response) {
|
|
5114
|
+
const parts = [];
|
|
5115
|
+
for (const msg of response.output) {
|
|
5116
|
+
for (const item of msg.content) {
|
|
5117
|
+
if ("type" in item && item.type === "output_text" && "text" in item) {
|
|
5118
|
+
parts.push(item.text);
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5122
|
+
return parts.join("");
|
|
5123
|
+
}
|
|
5030
5124
|
|
|
5031
5125
|
// src/operations/tags.ts
|
|
5032
5126
|
var tags_exports = {};
|
|
@@ -5214,6 +5308,48 @@ async function getAuthorizeLimits(arbi) {
|
|
|
5214
5308
|
"Failed to fetch authorize limits"
|
|
5215
5309
|
);
|
|
5216
5310
|
}
|
|
5311
|
+
async function getAgentSession(arbi, agentId) {
|
|
5312
|
+
return requireData(
|
|
5313
|
+
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/session", {
|
|
5314
|
+
params: { path: { agent_ext_id: agentId } }
|
|
5315
|
+
}),
|
|
5316
|
+
"Failed to read agent session"
|
|
5317
|
+
);
|
|
5318
|
+
}
|
|
5319
|
+
async function startAgentSession(arbi, agentId, workspaceId) {
|
|
5320
|
+
return requireData(
|
|
5321
|
+
await arbi.fetch.POST("/v1/agents/{agent_ext_id}/session", {
|
|
5322
|
+
params: { path: { agent_ext_id: agentId } },
|
|
5323
|
+
body: { workspace_ext_id: workspaceId ?? null }
|
|
5324
|
+
}),
|
|
5325
|
+
"Failed to start agent session"
|
|
5326
|
+
);
|
|
5327
|
+
}
|
|
5328
|
+
async function closeAgentSession(arbi, agentId) {
|
|
5329
|
+
const { error } = await arbi.fetch.DELETE("/v1/agents/{agent_ext_id}/session", {
|
|
5330
|
+
params: { path: { agent_ext_id: agentId } }
|
|
5331
|
+
});
|
|
5332
|
+
if (error) throw new Error("Failed to close agent session");
|
|
5333
|
+
}
|
|
5334
|
+
async function listAgentChats(arbi, agentId) {
|
|
5335
|
+
return requireData(
|
|
5336
|
+
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/chats", {
|
|
5337
|
+
params: { path: { agent_ext_id: agentId } }
|
|
5338
|
+
}),
|
|
5339
|
+
"Failed to read agent chats"
|
|
5340
|
+
);
|
|
5341
|
+
}
|
|
5342
|
+
async function stageAgentFile(auth, agentId, file, name) {
|
|
5343
|
+
const body = new FormData();
|
|
5344
|
+
body.append("file", file, name);
|
|
5345
|
+
const response = await authenticatedFetch({
|
|
5346
|
+
...auth,
|
|
5347
|
+
path: `/v1/agents/${encodeURIComponent(agentId)}/files`,
|
|
5348
|
+
method: "POST",
|
|
5349
|
+
body
|
|
5350
|
+
});
|
|
5351
|
+
return response.json();
|
|
5352
|
+
}
|
|
5217
5353
|
|
|
5218
5354
|
// src/operations/dm.ts
|
|
5219
5355
|
function createDmCryptoContext(arbi, signingPrivateKeyBytes, userExtId) {
|
|
@@ -5923,6 +6059,18 @@ var Arbi = class {
|
|
|
5923
6059
|
this.loginResult = await client.auth.loginWithKey({ email, signingPrivateKey });
|
|
5924
6060
|
this.userProfile = this.loginResult.profile ?? null;
|
|
5925
6061
|
}
|
|
6062
|
+
/** Recover browser authentication using the encrypted signing key already in IndexedDB. */
|
|
6063
|
+
async restoreSession(email) {
|
|
6064
|
+
const client = await this.init();
|
|
6065
|
+
const saved = await client.storage.getSession();
|
|
6066
|
+
if (!saved?.signingPrivateKey) return false;
|
|
6067
|
+
this.loginResult = await client.auth.loginWithKey({
|
|
6068
|
+
email,
|
|
6069
|
+
signingPrivateKey: saved.signingPrivateKey
|
|
6070
|
+
});
|
|
6071
|
+
this.userProfile = this.loginResult.profile ?? null;
|
|
6072
|
+
return true;
|
|
6073
|
+
}
|
|
5926
6074
|
/** A workspace's key, sealed to the caller's own session (what `/open` and `POST /workspace/users` take). */
|
|
5927
6075
|
async sealWorkspaceKey(workspaceId) {
|
|
5928
6076
|
const client = this.requireClient();
|
|
@@ -6370,19 +6518,38 @@ var Arbi = class {
|
|
|
6370
6518
|
};
|
|
6371
6519
|
// ── Assistant ─────────────────────────────────────────────────────────
|
|
6372
6520
|
assistant = {
|
|
6521
|
+
cancelRun: (responseId) => this.recovering(() => cancelAssistantRun(this.getAuthHeaders(), responseId)),
|
|
6522
|
+
/** Start a durable background turn; task options make its thread a reviewable work item. */
|
|
6523
|
+
submit: (question, options) => {
|
|
6524
|
+
const workspaceId = this.requireWorkspace();
|
|
6525
|
+
return this.recovering(
|
|
6526
|
+
() => submitBackgroundQuery({
|
|
6527
|
+
...this.getAuthHeaders(),
|
|
6528
|
+
...options,
|
|
6529
|
+
workspaceId,
|
|
6530
|
+
question
|
|
6531
|
+
})
|
|
6532
|
+
);
|
|
6533
|
+
},
|
|
6534
|
+
/** Read the status of a background turn. */
|
|
6535
|
+
getResponse: (id) => this.recovering(() => getResponse(this.getAuthHeaders(), id)),
|
|
6373
6536
|
/**
|
|
6374
6537
|
* Send a question to the RAG assistant with streaming support.
|
|
6375
6538
|
* Returns the accumulated result after the stream completes.
|
|
6376
6539
|
*/
|
|
6377
6540
|
query: async (question, options) => {
|
|
6378
|
-
const workspaceId = this.requireWorkspace();
|
|
6541
|
+
const workspaceId = options.workspaceId ?? this.requireWorkspace();
|
|
6379
6542
|
const response = await this.recovering(
|
|
6380
6543
|
() => queryAssistant({
|
|
6381
6544
|
...this.getAuthHeaders(),
|
|
6382
6545
|
workspaceId,
|
|
6383
6546
|
question,
|
|
6547
|
+
agentId: options.agentId,
|
|
6384
6548
|
docIds: options.docIds,
|
|
6385
6549
|
previousResponseId: options.previousResponseId,
|
|
6550
|
+
conversationId: options.conversationId,
|
|
6551
|
+
assistantMode: options.assistantMode,
|
|
6552
|
+
mentions: options.mentions,
|
|
6386
6553
|
model: options.model,
|
|
6387
6554
|
activeArtifactExtId: options.activeArtifactExtId,
|
|
6388
6555
|
signal: options.signal
|
|
@@ -6560,6 +6727,11 @@ var Arbi = class {
|
|
|
6560
6727
|
};
|
|
6561
6728
|
// ── Agents ──────────────────────────────────────────────────────────
|
|
6562
6729
|
agents = {
|
|
6730
|
+
getSession: (agentId) => getAgentSession(this.requireClient(), agentId),
|
|
6731
|
+
startSession: (agentId, workspaceId) => startAgentSession(this.requireClient(), agentId, workspaceId),
|
|
6732
|
+
closeSession: (agentId) => closeAgentSession(this.requireClient(), agentId),
|
|
6733
|
+
listChats: (agentId) => listAgentChats(this.requireClient(), agentId),
|
|
6734
|
+
stageFile: (agentId, file, name) => this.recovering(() => stageAgentFile(this.getAuthHeaders(), agentId, file, name)),
|
|
6563
6735
|
list: () => listAgents(this.requireClient()),
|
|
6564
6736
|
create: (name) => createAgent(this.requireClient(), name),
|
|
6565
6737
|
getConfig: (agentExtId) => getAgentConfig(this.requireClient(), agentExtId),
|
|
@@ -6646,69 +6818,6 @@ var Arbi = class {
|
|
|
6646
6818
|
}
|
|
6647
6819
|
};
|
|
6648
6820
|
|
|
6649
|
-
// src/operations/responses.ts
|
|
6650
|
-
var responses_exports = {};
|
|
6651
|
-
__export(responses_exports, {
|
|
6652
|
-
extractResponseText: () => extractResponseText,
|
|
6653
|
-
getResponse: () => getResponse,
|
|
6654
|
-
submitBackgroundQuery: () => submitBackgroundQuery
|
|
6655
|
-
});
|
|
6656
|
-
async function submitBackgroundQuery(options) {
|
|
6657
|
-
const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
|
|
6658
|
-
const tools = {};
|
|
6659
|
-
if (docIds.length > 0) {
|
|
6660
|
-
tools.retrieval_chunk = {
|
|
6661
|
-
name: "retrieval_chunk",
|
|
6662
|
-
description: "retrieval chunk",
|
|
6663
|
-
tool_args: { doc_ext_ids: docIds },
|
|
6664
|
-
tool_responses: {}
|
|
6665
|
-
};
|
|
6666
|
-
tools.retrieval_full_context = {
|
|
6667
|
-
name: "retrieval_full_context",
|
|
6668
|
-
description: "retrieval full context",
|
|
6669
|
-
tool_args: { doc_ext_ids: [] },
|
|
6670
|
-
tool_responses: {}
|
|
6671
|
-
};
|
|
6672
|
-
}
|
|
6673
|
-
const body = {
|
|
6674
|
-
input: question,
|
|
6675
|
-
workspace_ext_id: workspaceId,
|
|
6676
|
-
stream: false,
|
|
6677
|
-
background: true,
|
|
6678
|
-
store: true,
|
|
6679
|
-
tools,
|
|
6680
|
-
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
6681
|
-
...model ? { model } : {}
|
|
6682
|
-
};
|
|
6683
|
-
const res = await authenticatedFetch({
|
|
6684
|
-
...auth,
|
|
6685
|
-
path: "/v1/responses",
|
|
6686
|
-
method: "POST",
|
|
6687
|
-
body: JSON.stringify(body),
|
|
6688
|
-
headers: { "Content-Type": "application/json" }
|
|
6689
|
-
});
|
|
6690
|
-
return await res.json();
|
|
6691
|
-
}
|
|
6692
|
-
async function getResponse(auth, responseId) {
|
|
6693
|
-
const res = await authenticatedFetch({
|
|
6694
|
-
...auth,
|
|
6695
|
-
path: `/v1/responses/${responseId}`,
|
|
6696
|
-
method: "GET"
|
|
6697
|
-
});
|
|
6698
|
-
return await res.json();
|
|
6699
|
-
}
|
|
6700
|
-
function extractResponseText(response) {
|
|
6701
|
-
const parts = [];
|
|
6702
|
-
for (const msg of response.output) {
|
|
6703
|
-
for (const item of msg.content) {
|
|
6704
|
-
if ("type" in item && item.type === "output_text" && "text" in item) {
|
|
6705
|
-
parts.push(item.text);
|
|
6706
|
-
}
|
|
6707
|
-
}
|
|
6708
|
-
}
|
|
6709
|
-
return parts.join("");
|
|
6710
|
-
}
|
|
6711
|
-
|
|
6712
6821
|
exports.Arbi = Arbi;
|
|
6713
6822
|
exports.ArbiApiError = ArbiApiError;
|
|
6714
6823
|
exports.ArbiError = ArbiError;
|