@personaai/react 0.18.0 → 0.19.0
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 +43 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -2
- package/dist/index.d.ts +60 -2
- package/dist/index.js +43 -6
- 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;
|
|
@@ -989,6 +1019,13 @@ function useChat(options = {}) {
|
|
|
989
1019
|
patchAssistant({});
|
|
990
1020
|
}
|
|
991
1021
|
}
|
|
1022
|
+
} else if (event.name === "mcp_auth_required") {
|
|
1023
|
+
const val = event.value;
|
|
1024
|
+
const servers = val?.servers ?? [];
|
|
1025
|
+
if (servers.length > 0) {
|
|
1026
|
+
chatLogger.info("mcp auth required", { mcpIds: servers.map((s) => s.mcpId) });
|
|
1027
|
+
options.onMcpAuthRequired?.(servers);
|
|
1028
|
+
}
|
|
992
1029
|
}
|
|
993
1030
|
} else if (event.type === "title") {
|
|
994
1031
|
const title = event.title;
|
|
@@ -2929,7 +2966,7 @@ function useMcpConnections(options = {}) {
|
|
|
2929
2966
|
throw new Error(`Failed to disconnect MCP: ${res.statusText}`);
|
|
2930
2967
|
setConnections(
|
|
2931
2968
|
(prev) => prev.map(
|
|
2932
|
-
(c) => c.mcpId === mcpId ? { ...c, connected: false, authorizeUrl: null } : c
|
|
2969
|
+
(c) => c.mcpId === mcpId ? { ...c, connected: false, status: "not_connected", authorizeUrl: null } : c
|
|
2933
2970
|
)
|
|
2934
2971
|
);
|
|
2935
2972
|
void fetchConnections();
|
|
@@ -4422,7 +4459,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4422
4459
|
|
|
4423
4460
|
// src/index.ts
|
|
4424
4461
|
var import_logger2 = require("@personaai/logger");
|
|
4425
|
-
var VERSION = "0.
|
|
4462
|
+
var VERSION = "0.19.0";
|
|
4426
4463
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4427
4464
|
0 && (module.exports = {
|
|
4428
4465
|
ARCHITECT_AGENT_ID,
|