@space3-npm/cybersoul-client 1.4.13 → 1.4.15
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/client.js +16 -4
- package/dist/llm.provider.js +4 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -34,7 +34,11 @@ export class CyberSoulClient {
|
|
|
34
34
|
const controller = new AbortController();
|
|
35
35
|
const timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
// NOTE: When no custom fetchImpl is provided, fall back to the global
|
|
38
|
+
// `fetch` bound to `globalThis`. Browsers throw "Illegal invocation"
|
|
39
|
+
// if the global `fetch` is invoked while detached from its Window
|
|
40
|
+
// receiver (e.g. via a captured reference).
|
|
41
|
+
const fetchFn = this.config.fetchImpl ?? fetch.bind(globalThis);
|
|
38
42
|
const response = await fetchFn(url, {
|
|
39
43
|
...options,
|
|
40
44
|
headers,
|
|
@@ -797,7 +801,10 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
|
|
|
797
801
|
finalImageMediaId = res.id;
|
|
798
802
|
})
|
|
799
803
|
.catch((e) => {
|
|
800
|
-
|
|
804
|
+
if (!(e instanceof CyberSoulInsufficientPointsError) &&
|
|
805
|
+
!(e instanceof CyberSoulWalletError)) {
|
|
806
|
+
console.error("[CyberSoulClient] Image generation failed:", e);
|
|
807
|
+
}
|
|
801
808
|
captureMediaError("image", e);
|
|
802
809
|
}));
|
|
803
810
|
}
|
|
@@ -821,7 +828,10 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
|
|
|
821
828
|
finalDurationSec = res.duration_sec;
|
|
822
829
|
})
|
|
823
830
|
.catch((e) => {
|
|
824
|
-
|
|
831
|
+
if (!(e instanceof CyberSoulInsufficientPointsError) &&
|
|
832
|
+
!(e instanceof CyberSoulWalletError)) {
|
|
833
|
+
console.error("[CyberSoulClient] Voice generation failed:", e);
|
|
834
|
+
}
|
|
825
835
|
captureMediaError("voice", e);
|
|
826
836
|
}));
|
|
827
837
|
}
|
|
@@ -1101,12 +1111,14 @@ If "shouldSkipProactive" is false, "textResponse" is required and "stateUpdate"
|
|
|
1101
1111
|
finalImageMediaId = res.id;
|
|
1102
1112
|
}
|
|
1103
1113
|
catch (e) {
|
|
1104
|
-
console.error("[CyberSoulClient] Proactive Image generation failed:", e);
|
|
1105
1114
|
if (e instanceof CyberSoulInsufficientPointsError ||
|
|
1106
1115
|
e instanceof CyberSoulWalletError) {
|
|
1107
1116
|
proactiveMediaError = e;
|
|
1108
1117
|
proactiveAffected.push("image");
|
|
1109
1118
|
}
|
|
1119
|
+
else {
|
|
1120
|
+
console.error("[CyberSoulClient] Proactive Image generation failed:", e);
|
|
1121
|
+
}
|
|
1110
1122
|
}
|
|
1111
1123
|
}
|
|
1112
1124
|
const persistedDynamicContext = (await persistedStatePromise) ?? undefined;
|
package/dist/llm.provider.js
CHANGED
|
@@ -11,7 +11,10 @@ export class GenericLLMProvider {
|
|
|
11
11
|
this.fetchImpl = fetchImpl;
|
|
12
12
|
}
|
|
13
13
|
get fetchFn() {
|
|
14
|
-
|
|
14
|
+
// Bind to `globalThis` so the global `fetch` is not invoked detached
|
|
15
|
+
// from its Window receiver (which throws "Illegal invocation" in
|
|
16
|
+
// Chromium-based browsers).
|
|
17
|
+
return this.fetchImpl ?? fetch.bind(globalThis);
|
|
15
18
|
}
|
|
16
19
|
async fetchTemplate() {
|
|
17
20
|
const cacheKey = `${this.config.provider}:${this.config.model}`;
|