@arbidocs/sdk 0.3.10 → 0.3.11
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.cjs +29 -5
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +29 -5
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -53,7 +53,7 @@ interface AuthFetchOptions extends AuthHeaders {
|
|
|
53
53
|
/**
|
|
54
54
|
* Make an authenticated fetch request with standard error handling.
|
|
55
55
|
* Automatically sets Authorization + workspace-key headers.
|
|
56
|
-
* Throws on non-ok responses with a human-readable message.
|
|
56
|
+
* Throws on non-ok responses with a human-readable message including server error details.
|
|
57
57
|
*/
|
|
58
58
|
declare function authenticatedFetch(options: AuthFetchOptions): Promise<Response>;
|
|
59
59
|
|
|
@@ -79,6 +79,8 @@ interface ChatSession {
|
|
|
79
79
|
lastMessageExtId: string | null;
|
|
80
80
|
/** Conversation external ID — used to restore chat history on restart */
|
|
81
81
|
conversationExtId: string | null;
|
|
82
|
+
/** Workspace ID where the conversation started — used to detect workspace changes */
|
|
83
|
+
workspaceId: string | null;
|
|
82
84
|
}
|
|
83
85
|
interface ConfigStore {
|
|
84
86
|
getConfig(): CliConfig | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ interface AuthFetchOptions extends AuthHeaders {
|
|
|
53
53
|
/**
|
|
54
54
|
* Make an authenticated fetch request with standard error handling.
|
|
55
55
|
* Automatically sets Authorization + workspace-key headers.
|
|
56
|
-
* Throws on non-ok responses with a human-readable message.
|
|
56
|
+
* Throws on non-ok responses with a human-readable message including server error details.
|
|
57
57
|
*/
|
|
58
58
|
declare function authenticatedFetch(options: AuthFetchOptions): Promise<Response>;
|
|
59
59
|
|
|
@@ -79,6 +79,8 @@ interface ChatSession {
|
|
|
79
79
|
lastMessageExtId: string | null;
|
|
80
80
|
/** Conversation external ID — used to restore chat history on restart */
|
|
81
81
|
conversationExtId: string | null;
|
|
82
|
+
/** Workspace ID where the conversation started — used to detect workspace changes */
|
|
83
|
+
workspaceId: string | null;
|
|
82
84
|
}
|
|
83
85
|
interface ConfigStore {
|
|
84
86
|
getConfig(): CliConfig | null;
|
package/dist/index.js
CHANGED
|
@@ -40,10 +40,31 @@ function getErrorMessage(err) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// src/fetch.ts
|
|
43
|
-
var
|
|
43
|
+
var STATUS_FALLBACKS = {
|
|
44
44
|
401: "Token has expired. Please run: arbi login",
|
|
45
|
+
403: "Access denied. You may not have permission for this workspace.",
|
|
46
|
+
404: "Resource not found.",
|
|
45
47
|
503: "The selected LLM is not responding. Please retry or select another model."
|
|
46
48
|
};
|
|
49
|
+
async function extractErrorMessage(res) {
|
|
50
|
+
let bodyDetail;
|
|
51
|
+
try {
|
|
52
|
+
const text = await res.text();
|
|
53
|
+
if (text) {
|
|
54
|
+
try {
|
|
55
|
+
const json = JSON.parse(text);
|
|
56
|
+
bodyDetail = json.detail || json.message || json.error || void 0;
|
|
57
|
+
} catch {
|
|
58
|
+
if (text.length < 200) bodyDetail = text;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
if (bodyDetail) return `Request failed (${res.status}): ${bodyDetail}`;
|
|
64
|
+
const fallback = STATUS_FALLBACKS[res.status];
|
|
65
|
+
if (fallback) return fallback;
|
|
66
|
+
return `Request failed: ${res.status} ${res.statusText}`;
|
|
67
|
+
}
|
|
47
68
|
async function authenticatedFetch(options) {
|
|
48
69
|
const { baseUrl, accessToken, workspaceKeyHeader, path: path3, method, body, headers } = options;
|
|
49
70
|
const res = await fetch(`${baseUrl}${path3}`, {
|
|
@@ -56,16 +77,15 @@ async function authenticatedFetch(options) {
|
|
|
56
77
|
body
|
|
57
78
|
});
|
|
58
79
|
if (!res.ok) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const text = await res.text().catch(() => "");
|
|
62
|
-
throw new Error(`Request failed: ${res.status} ${text}`);
|
|
80
|
+
const message = await extractErrorMessage(res);
|
|
81
|
+
throw new ArbiApiError(message, { status: res.status, statusText: res.statusText });
|
|
63
82
|
}
|
|
64
83
|
return res;
|
|
65
84
|
}
|
|
66
85
|
var DEFAULT_SESSION = {
|
|
67
86
|
lastMessageExtId: null,
|
|
68
|
-
conversationExtId: null
|
|
87
|
+
conversationExtId: null,
|
|
88
|
+
workspaceId: null
|
|
69
89
|
};
|
|
70
90
|
var FileConfigStore = class {
|
|
71
91
|
configDir;
|
|
@@ -343,6 +363,11 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
343
363
|
usage = data.response.usage;
|
|
344
364
|
callbacks.onUsage?.(data.response.usage);
|
|
345
365
|
}
|
|
366
|
+
if (data.response?.metadata) {
|
|
367
|
+
const meta = data.response.metadata;
|
|
368
|
+
metadata = meta;
|
|
369
|
+
callbacks.onMetadata?.(meta);
|
|
370
|
+
}
|
|
346
371
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
347
372
|
callbacks.onComplete?.();
|
|
348
373
|
},
|