@arbidocs/sdk 0.3.16 → 0.3.17
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/README.md +58 -81
- package/dist/{browser-DFRwcoc1.d.cts → browser-BtAHbiq_.d.cts} +78 -5
- package/dist/{browser-DFRwcoc1.d.ts → browser-BtAHbiq_.d.ts} +78 -5
- package/dist/browser.cjs +77 -0
- 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 +74 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +108 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +104 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/browser.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore,
|
|
1
|
+
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, n as CitationSummary, a as CliConfig, b as CliCredentials, C as ConfigStore, o as ConnectOptions, L as LIFECYCLE_LABELS, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, ag as formatUserName, ah as formatWorkspaceChoices, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as requireData, aq as requireOk, ar as resolveAuth, as as resolveCitations, at as resolveWorkspace, au as responses, av as selectWorkspace, aw as selectWorkspaceById, ax as settings, ay as streamSSE, az as stripCitationMarkdown, aA as summarizeCitations, aB as tags, aC as workspaces } from './browser-BtAHbiq_.cjs';
|
|
2
2
|
import '@arbidocs/client';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore,
|
|
1
|
+
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, n as CitationSummary, a as CliConfig, b as CliCredentials, C as ConfigStore, o as ConnectOptions, L as LIFECYCLE_LABELS, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, ag as formatUserName, ah as formatWorkspaceChoices, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as requireData, aq as requireOk, ar as resolveAuth, as as resolveCitations, at as resolveWorkspace, au as responses, av as selectWorkspace, aw as selectWorkspaceById, ax as settings, ay as streamSSE, az as stripCitationMarkdown, aA as summarizeCitations, aB as tags, aC as workspaces } from './browser-BtAHbiq_.js';
|
|
2
2
|
import '@arbidocs/client';
|
package/dist/browser.js
CHANGED
|
@@ -580,6 +580,66 @@ function formatUserName(user) {
|
|
|
580
580
|
return [user.given_name, user.family_name].filter(Boolean).join(" ");
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
+
// src/citations.ts
|
|
584
|
+
function resolveCitations(metadata) {
|
|
585
|
+
if (!metadata?.tools) return [];
|
|
586
|
+
const tools = metadata.tools;
|
|
587
|
+
const modelCitations = tools.model_citations;
|
|
588
|
+
const citationMap = modelCitations?.tool_responses;
|
|
589
|
+
if (!citationMap || Object.keys(citationMap).length === 0) return [];
|
|
590
|
+
const chunkLookup = buildChunkLookup(tools);
|
|
591
|
+
const resolved = [];
|
|
592
|
+
for (const [citationNum, citationData] of Object.entries(citationMap)) {
|
|
593
|
+
const chunks = [];
|
|
594
|
+
for (const chunkId of citationData.chunk_ids ?? []) {
|
|
595
|
+
const chunk = chunkLookup.get(chunkId);
|
|
596
|
+
if (chunk) chunks.push(chunk);
|
|
597
|
+
}
|
|
598
|
+
resolved.push({ citationNum, citationData, chunks });
|
|
599
|
+
}
|
|
600
|
+
resolved.sort((a, b) => Number(a.citationNum) - Number(b.citationNum));
|
|
601
|
+
return resolved;
|
|
602
|
+
}
|
|
603
|
+
function summarizeCitations(resolved) {
|
|
604
|
+
return resolved.map((r) => {
|
|
605
|
+
const firstChunk = r.chunks[0];
|
|
606
|
+
return {
|
|
607
|
+
citationNum: r.citationNum,
|
|
608
|
+
statement: r.citationData.statement ?? "",
|
|
609
|
+
docTitle: firstChunk?.metadata?.doc_title ?? "Unknown document",
|
|
610
|
+
pageNumber: firstChunk?.metadata?.page_number ?? null,
|
|
611
|
+
chunkCount: r.chunks.length
|
|
612
|
+
};
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function countCitations(metadata) {
|
|
616
|
+
if (!metadata?.tools) return 0;
|
|
617
|
+
const tools = metadata.tools;
|
|
618
|
+
const modelCitations = tools.model_citations;
|
|
619
|
+
const responses = modelCitations?.tool_responses;
|
|
620
|
+
return responses ? Object.keys(responses).length : 0;
|
|
621
|
+
}
|
|
622
|
+
function stripCitationMarkdown(text) {
|
|
623
|
+
return text.replace(/\[([^\]]+)\]\(#cite-(\d+)\)/g, "$1[$2]");
|
|
624
|
+
}
|
|
625
|
+
function buildChunkLookup(tools) {
|
|
626
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
627
|
+
for (const toolName of ["retrieval_chunk", "retrieval_full_context"]) {
|
|
628
|
+
const tool = tools[toolName];
|
|
629
|
+
if (!tool?.tool_responses) continue;
|
|
630
|
+
for (const chunks of Object.values(tool.tool_responses)) {
|
|
631
|
+
if (!Array.isArray(chunks)) continue;
|
|
632
|
+
for (const chunk of chunks) {
|
|
633
|
+
const id = chunk.metadata?.chunk_ext_id;
|
|
634
|
+
if (id && !lookup.has(id)) {
|
|
635
|
+
lookup.set(id, chunk);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return lookup;
|
|
641
|
+
}
|
|
642
|
+
|
|
583
643
|
// src/operations/documents.ts
|
|
584
644
|
var documents_exports = {};
|
|
585
645
|
__export(documents_exports, {
|
|
@@ -1277,6 +1337,19 @@ var Arbi = class {
|
|
|
1277
1337
|
lr.serverSessionKey,
|
|
1278
1338
|
signingPrivateKeyBase64
|
|
1279
1339
|
);
|
|
1340
|
+
const workspaceKeyHeader = client.session.getWorkspaceKeyHeader();
|
|
1341
|
+
if (workspaceKeyHeader) {
|
|
1342
|
+
const { data: openResult, error: openError } = await client.fetch.POST(
|
|
1343
|
+
"/v1/workspace/{workspace_ext_id}/open",
|
|
1344
|
+
{
|
|
1345
|
+
params: { path: { workspace_ext_id: ws.external_id } },
|
|
1346
|
+
body: { workspace_key: workspaceKeyHeader }
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
if (!openError && openResult?.access_token) {
|
|
1350
|
+
client.session.setAccessToken(openResult.access_token);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1280
1353
|
this.currentWorkspaceId = ws.external_id;
|
|
1281
1354
|
}
|
|
1282
1355
|
/** Log out and clear internal state. */
|
|
@@ -1561,6 +1634,6 @@ function extractResponseText(response) {
|
|
|
1561
1634
|
return parts.join("");
|
|
1562
1635
|
}
|
|
1563
1636
|
|
|
1564
|
-
export { Arbi, ArbiApiError, ArbiError, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, tags_exports as tags, workspaces_exports as workspaces };
|
|
1637
|
+
export { Arbi, ArbiApiError, ArbiError, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, workspaces_exports as workspaces };
|
|
1565
1638
|
//# sourceMappingURL=browser.js.map
|
|
1566
1639
|
//# sourceMappingURL=browser.js.map
|