@personaai/react 0.18.0 → 0.18.1
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/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -121,10 +121,33 @@ function PersonaProvider({
|
|
|
121
121
|
ok: res.ok
|
|
122
122
|
});
|
|
123
123
|
if (!res.ok) {
|
|
124
|
+
const parsedResult = { isJson: false };
|
|
125
|
+
try {
|
|
126
|
+
const body = await res.clone().json();
|
|
127
|
+
if (body && typeof body === "object") {
|
|
128
|
+
const message = body.error?.message ?? body.message ?? void 0;
|
|
129
|
+
if (body.error?.code ?? message) {
|
|
130
|
+
parsedResult.isJson = true;
|
|
131
|
+
parsedResult.info = {
|
|
132
|
+
status: res.status,
|
|
133
|
+
code: body.error?.code,
|
|
134
|
+
message
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
124
140
|
logger.warn("fetchWithAuth non-ok", {
|
|
125
141
|
path: cleanPath,
|
|
126
|
-
status: res.status
|
|
142
|
+
status: res.status,
|
|
143
|
+
...parsedResult.info ?? {}
|
|
127
144
|
});
|
|
145
|
+
if (parsedResult.info) {
|
|
146
|
+
try {
|
|
147
|
+
res.personaError = parsedResult.info;
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
128
151
|
} else {
|
|
129
152
|
logger.info("fetchWithAuth succeeded", {
|
|
130
153
|
path: cleanPath,
|
|
@@ -420,6 +443,14 @@ function normalizePendingInterrupt(pending) {
|
|
|
420
443
|
}
|
|
421
444
|
|
|
422
445
|
// src/hooks/useChat.ts
|
|
446
|
+
function httpFailure(res, what) {
|
|
447
|
+
const info = res.personaError;
|
|
448
|
+
if (!info || !info.code && !info.message) {
|
|
449
|
+
return new Error(`Failed to ${what}: ${res.statusText || res.status}`);
|
|
450
|
+
}
|
|
451
|
+
const parts = [info.status, info.code, info.message].filter(Boolean).join(", ");
|
|
452
|
+
return new Error(`Failed to ${what}: ${parts}`);
|
|
453
|
+
}
|
|
423
454
|
function parseSandboxCommand(tc) {
|
|
424
455
|
let command = tc.args ?? "";
|
|
425
456
|
try {
|
|
@@ -552,8 +583,7 @@ function useChat(options = {}) {
|
|
|
552
583
|
setError(null);
|
|
553
584
|
try {
|
|
554
585
|
const res = await fetchWithAuth(`/threads/${id}/messages`);
|
|
555
|
-
if (!res.ok)
|
|
556
|
-
throw new Error(`Failed to load thread history: ${res.statusText}`);
|
|
586
|
+
if (!res.ok) throw httpFailure(res, "load thread history");
|
|
557
587
|
const body = await res.json();
|
|
558
588
|
const data = body?.data ?? body;
|
|
559
589
|
const raw = data?.messages ?? [];
|
|
@@ -813,7 +843,7 @@ function useChat(options = {}) {
|
|
|
813
843
|
headers: { "Content-Type": "application/json" },
|
|
814
844
|
body: JSON.stringify({ agentId: targetAgentId })
|
|
815
845
|
});
|
|
816
|
-
if (!createRes.ok) throw
|
|
846
|
+
if (!createRes.ok) throw httpFailure(createRes, "create thread");
|
|
817
847
|
const createBody = await createRes.json();
|
|
818
848
|
const created = createBody?.data ?? createBody;
|
|
819
849
|
resolvedThreadId = created._id ?? created.id;
|
|
@@ -4422,7 +4452,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4422
4452
|
|
|
4423
4453
|
// src/index.ts
|
|
4424
4454
|
var import_logger2 = require("@personaai/logger");
|
|
4425
|
-
var VERSION = "0.18.
|
|
4455
|
+
var VERSION = "0.18.1";
|
|
4426
4456
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4427
4457
|
0 && (module.exports = {
|
|
4428
4458
|
ARCHITECT_AGENT_ID,
|