@arbidocs/sdk 0.3.13 → 0.3.14
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-BszYf6lU.d.cts → browser-DtwXhEkG.d.cts} +48 -1
- package/dist/{browser-BszYf6lU.d.ts → browser-DtwXhEkG.d.ts} +48 -1
- package/dist/browser.cjs +76 -1
- 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 +76 -2
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +83 -1
- 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 +83 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -514,11 +514,13 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
514
514
|
let text = "";
|
|
515
515
|
let assistantMessageExtId = null;
|
|
516
516
|
const agentSteps = [];
|
|
517
|
+
let toolCallCount = 0;
|
|
517
518
|
const errors = [];
|
|
518
519
|
const artifacts = [];
|
|
519
520
|
let userMessage = null;
|
|
520
521
|
let metadata = null;
|
|
521
522
|
let usage = null;
|
|
523
|
+
let context = null;
|
|
522
524
|
const eventHandlers = {
|
|
523
525
|
// OpenAI Responses API events (dot-separated names from server)
|
|
524
526
|
"response.created": (raw) => {
|
|
@@ -562,6 +564,9 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
562
564
|
metadata = meta;
|
|
563
565
|
callbacks.onMetadata?.(meta);
|
|
564
566
|
}
|
|
567
|
+
if (data.context) {
|
|
568
|
+
context = data.context;
|
|
569
|
+
}
|
|
565
570
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
566
571
|
callbacks.onComplete?.();
|
|
567
572
|
},
|
|
@@ -576,6 +581,10 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
576
581
|
const data = JSON.parse(raw);
|
|
577
582
|
const label = formatAgentStepLabel(data);
|
|
578
583
|
if (label) agentSteps.push(label);
|
|
584
|
+
const detail = data.detail;
|
|
585
|
+
if (detail && Array.isArray(detail)) {
|
|
586
|
+
toolCallCount += detail.filter((d) => d.tool).length;
|
|
587
|
+
}
|
|
579
588
|
callbacks.onAgentStep?.(data);
|
|
580
589
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
581
590
|
},
|
|
@@ -626,11 +635,13 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
626
635
|
text,
|
|
627
636
|
assistantMessageExtId,
|
|
628
637
|
agentSteps,
|
|
638
|
+
toolCallCount,
|
|
629
639
|
errors,
|
|
630
640
|
userMessage,
|
|
631
641
|
metadata,
|
|
632
642
|
artifacts,
|
|
633
|
-
usage
|
|
643
|
+
usage,
|
|
644
|
+
context
|
|
634
645
|
};
|
|
635
646
|
}
|
|
636
647
|
var consumeSSEStream = streamSSE;
|
|
@@ -829,6 +840,13 @@ function formatWsMessage(msg) {
|
|
|
829
840
|
if (client.isMessageType(msg, "presence_update")) {
|
|
830
841
|
return { text: `${msg.user_id} is ${msg.status}`, level: "info" };
|
|
831
842
|
}
|
|
843
|
+
if (client.isMessageType(msg, "response_complete")) {
|
|
844
|
+
const icon = msg.status === "completed" ? "\u2713" : "\u2717";
|
|
845
|
+
return {
|
|
846
|
+
text: `${icon} Task ${msg.response_id} ${msg.status}`,
|
|
847
|
+
level: msg.status === "completed" ? "success" : "error"
|
|
848
|
+
};
|
|
849
|
+
}
|
|
832
850
|
if (isNotification(msg)) {
|
|
833
851
|
const sender = msg.sender?.email || "someone";
|
|
834
852
|
const content = msg.content ?? msg.type;
|
|
@@ -1885,6 +1903,69 @@ async function uploadZip(auth, workspaceId, zipPath) {
|
|
|
1885
1903
|
return { doc_ext_ids: allDocIds, duplicates: allDuplicates, folders };
|
|
1886
1904
|
}
|
|
1887
1905
|
|
|
1906
|
+
// src/operations/responses.ts
|
|
1907
|
+
var responses_exports = {};
|
|
1908
|
+
__export(responses_exports, {
|
|
1909
|
+
extractResponseText: () => extractResponseText,
|
|
1910
|
+
getResponse: () => getResponse,
|
|
1911
|
+
submitBackgroundQuery: () => submitBackgroundQuery
|
|
1912
|
+
});
|
|
1913
|
+
async function submitBackgroundQuery(options) {
|
|
1914
|
+
const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
|
|
1915
|
+
const tools = {};
|
|
1916
|
+
if (docIds.length > 0) {
|
|
1917
|
+
tools.retrieval_chunk = {
|
|
1918
|
+
name: "retrieval_chunk",
|
|
1919
|
+
description: "retrieval chunk",
|
|
1920
|
+
tool_args: { doc_ext_ids: docIds },
|
|
1921
|
+
tool_responses: {}
|
|
1922
|
+
};
|
|
1923
|
+
tools.retrieval_full_context = {
|
|
1924
|
+
name: "retrieval_full_context",
|
|
1925
|
+
description: "retrieval full context",
|
|
1926
|
+
tool_args: { doc_ext_ids: [] },
|
|
1927
|
+
tool_responses: {}
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
const body = {
|
|
1931
|
+
input: question,
|
|
1932
|
+
workspace_ext_id: workspaceId,
|
|
1933
|
+
stream: false,
|
|
1934
|
+
background: true,
|
|
1935
|
+
store: true,
|
|
1936
|
+
tools,
|
|
1937
|
+
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
1938
|
+
...model ? { model } : {}
|
|
1939
|
+
};
|
|
1940
|
+
const res = await authenticatedFetch({
|
|
1941
|
+
...auth,
|
|
1942
|
+
path: "/v1/responses",
|
|
1943
|
+
method: "POST",
|
|
1944
|
+
body: JSON.stringify(body),
|
|
1945
|
+
headers: { "Content-Type": "application/json" }
|
|
1946
|
+
});
|
|
1947
|
+
return await res.json();
|
|
1948
|
+
}
|
|
1949
|
+
async function getResponse(auth, responseId) {
|
|
1950
|
+
const res = await authenticatedFetch({
|
|
1951
|
+
...auth,
|
|
1952
|
+
path: `/v1/responses/${responseId}`,
|
|
1953
|
+
method: "GET"
|
|
1954
|
+
});
|
|
1955
|
+
return await res.json();
|
|
1956
|
+
}
|
|
1957
|
+
function extractResponseText(response) {
|
|
1958
|
+
const parts = [];
|
|
1959
|
+
for (const msg of response.output) {
|
|
1960
|
+
for (const item of msg.content) {
|
|
1961
|
+
if ("type" in item && item.type === "output_text" && "text" in item) {
|
|
1962
|
+
parts.push(item.text);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
return parts.join("");
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1888
1969
|
exports.Arbi = Arbi;
|
|
1889
1970
|
exports.ArbiApiError = ArbiApiError;
|
|
1890
1971
|
exports.ArbiError = ArbiError;
|
|
@@ -1924,6 +2005,7 @@ exports.requireData = requireData;
|
|
|
1924
2005
|
exports.requireOk = requireOk;
|
|
1925
2006
|
exports.resolveAuth = resolveAuth;
|
|
1926
2007
|
exports.resolveWorkspace = resolveWorkspace;
|
|
2008
|
+
exports.responses = responses_exports;
|
|
1927
2009
|
exports.selectWorkspace = selectWorkspace;
|
|
1928
2010
|
exports.selectWorkspaceById = selectWorkspaceById;
|
|
1929
2011
|
exports.settings = settings_exports;
|