pi-anthropic-oauth 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/prompt.ts +9 -1
package/package.json
CHANGED
package/src/prompt.ts
CHANGED
|
@@ -32,7 +32,15 @@ type MessageContentBlock = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export function sanitizeSurrogates(text: string): string {
|
|
35
|
-
|
|
35
|
+
// Replace only *unpaired* surrogates: a high surrogate not followed by a low
|
|
36
|
+
// surrogate, or a low surrogate not preceded by a high surrogate. Valid
|
|
37
|
+
// surrogate pairs (non-BMP characters such as emoji) must pass through
|
|
38
|
+
// untouched. Equivalent to String.prototype.toWellFormed(), which requires
|
|
39
|
+
// Node 20+ while this package supports Node >=18.
|
|
40
|
+
return text.replace(
|
|
41
|
+
/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,
|
|
42
|
+
"\uFFFD",
|
|
43
|
+
);
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
export function buildAnthropicSystemPrompt(
|