feat(session): add cross-session references

This commit is contained in:
Yichen Jiang
2026-07-21 16:46:48 +08:00
parent 9a5c81f9e5
commit 32d786c439
81 changed files with 2837 additions and 160 deletions

View File

@@ -0,0 +1,12 @@
/** Tag-safe JSON serialization for the model-visible reference envelope. */
/**
* Serialize JSON while preventing source data from spelling an XML-like opening tag.
* @param value - JSON-compatible reference data.
* @returns JSON whose parse result is unchanged and whose data contains no literal `<`.
*/
export function stringifyTagSafeJson(value: unknown): string {
const serialized: unknown = JSON.stringify(value)
if (typeof serialized !== 'string') throw new TypeError('session-reference data is not JSON-serializable')
return serialized.replaceAll('<', '\\u003c')
}