@dsh-agentic-roleplay/core 0.3.2 → 0.3.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/lib/authoring.js +15 -255
- package/lib/child-CFjnaTZt.js +435 -0
- package/lib/client.js +2852 -586
- package/lib/client.js.map +1 -1
- package/lib/{deliver-BSsDtF6X.js → deliver-CpZOxBX5.js} +145 -1622
- package/lib/doctor-chat-ByDfCMeo.js +17 -0
- package/lib/doctor.js +171 -0
- package/lib/{gallery-DS5-qH9F.js → gallery-CtFDL22W.js} +2 -2
- package/lib/{generator-BzeepLd2.js → generator-B6FxlKOV.js} +2 -378
- package/lib/hooks-KTCR3fNJ.js +1060 -0
- package/lib/images.js +3 -3
- package/lib/index.js +1365 -201
- package/lib/language-DWVwi1R7.js +520 -0
- package/lib/orchestration.js +142 -1146
- package/lib/{documents-B5XAdfo2.js → pack-jail-CybSNzxr.js} +869 -80
- package/lib/{packs-BCGK9KZV.js → packs-BYjrAen6.js} +4 -518
- package/lib/{presenter-agent-Cp-J0onD.js → presenter-agent-CiEVKcjJ.js} +4 -3
- package/lib/reflection-waxFg1x-.js +1843 -0
- package/package.json +3 -2
- package/prompts/en/doctor/persona.md +1 -0
- package/prompts/en/doctor/procedure.md +5 -0
- package/prompts/en/doctor/welcome.md +1 -0
- package/prompts/en/import/character.md +1 -0
- package/prompts/en/roleplay/record-keeper.md +2 -2
- package/prompts/en/roleplay/reflection-check.md +5 -0
- package/prompts/en/roleplay/reflection.md +2 -0
- package/prompts/zh/doctor/persona.md +1 -0
- package/prompts/zh/doctor/procedure.md +5 -0
- package/prompts/zh/doctor/welcome.md +1 -0
- package/prompts/zh/import/character.md +1 -0
- package/prompts/zh/roleplay/record-keeper.md +2 -2
- package/prompts/zh/roleplay/reflection-check.md +5 -0
- package/prompts/zh/roleplay/reflection.md +2 -0
package/lib/authoring.js
CHANGED
|
@@ -1,115 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { C as readWorldEditor, Dt as readWorldPrompt, Et as listWorldPrompts, F as loadWorldParts, H as importHooks, Ht as InvalidEditProblems, J as isReviewing, M as deleteTriggerDocument, N as readTriggerDocuments, Ot as writeWorldPrompt, P as writeTriggerDocument, R as presetTools, Tt as deleteWorldPrompt, U as importTools, V as translateTools, W as authoredWorldOf, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, qt as parseRelationEdit, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation, wt as PROSE_PROMPTS } from "./pack-jail-CybSNzxr.js";
|
|
2
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-BYjrAen6.js";
|
|
3
|
+
import { S as shippedPromptsDirectory, c as parsePlotsFile, p as formatIssue } from "./language-DWVwi1R7.js";
|
|
4
|
+
import { join, relative } from "node:path";
|
|
6
5
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
7
|
-
import {
|
|
8
|
-
import { readTriggerDefinition } from "@dsh-agentic-roleplay/state";
|
|
9
|
-
//#region src/host/triggers/files.ts
|
|
10
|
-
/** The fields of a trigger in the file; any other is a mistake that would otherwise be dropped without a word. */
|
|
11
|
-
const FIELDS = /* @__PURE__ */ new Set([
|
|
12
|
-
"key",
|
|
13
|
-
"name",
|
|
14
|
-
"when",
|
|
15
|
-
"effects",
|
|
16
|
-
"repeat",
|
|
17
|
-
"cooldown_seconds",
|
|
18
|
-
"chance",
|
|
19
|
-
"priority",
|
|
20
|
-
"expires",
|
|
21
|
-
"announce"
|
|
22
|
-
]);
|
|
23
|
-
const isDocument = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
-
/** The documents of `<world>/triggers.json` as written; none when the file is not there. @throws {InvalidEditProblems} when it is not a list of objects. */
|
|
25
|
-
async function readTriggerDocuments(directory) {
|
|
26
|
-
let text;
|
|
27
|
-
try {
|
|
28
|
-
text = await readFile(join(directory, TRIGGERS_FILE_NAME), "utf8");
|
|
29
|
-
} catch (error) {
|
|
30
|
-
if (error.code === "ENOENT") return [];
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
let data;
|
|
34
|
-
try {
|
|
35
|
-
data = JSON.parse(text.replace(/^/, ""));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw new InvalidEditProblems([`triggers.json is not valid JSON: ${error instanceof Error ? error.message : String(error)}`]);
|
|
38
|
-
}
|
|
39
|
-
if (!Array.isArray(data) || !data.every(isDocument)) throw new InvalidEditProblems(["triggers.json is not a list of triggers"]);
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
async function writeDocuments(directory, documents) {
|
|
43
|
-
const file = join(directory, TRIGGERS_FILE_NAME);
|
|
44
|
-
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
45
|
-
try {
|
|
46
|
-
const mode = await stat(file).then((value) => value.mode, () => void 0);
|
|
47
|
-
await writeFile(temporary, `${JSON.stringify(documents, null, 2)}\n`, mode === void 0 ? {} : { mode });
|
|
48
|
-
await rename(temporary, file);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
await rm(temporary, { force: true });
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** The keys of the triggers a condition waits for. */
|
|
55
|
-
function waitsFor(condition) {
|
|
56
|
-
switch (condition.type) {
|
|
57
|
-
case "fired": return [condition.trigger];
|
|
58
|
-
case "all":
|
|
59
|
-
case "any": return condition.conditions.flatMap(waitsFor);
|
|
60
|
-
case "not": return waitsFor(condition.condition);
|
|
61
|
-
default: return [];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Makes or replaces one trigger of the world, by key, from a complete document in the file format. It is read as a session start reads it, and
|
|
66
|
-
* what it names that the world does not have is refused, with every problem; nothing is written then.
|
|
67
|
-
* @throws {InvalidEditProblems}
|
|
68
|
-
*/
|
|
69
|
-
async function writeTriggerDocument(directory, parts, key, document) {
|
|
70
|
-
if (!isDocument(document)) throw new InvalidEditProblems(["document must be a JSON object"]);
|
|
71
|
-
const unknown = Object.keys(document).filter((field) => !FIELDS.has(field));
|
|
72
|
-
if (unknown.length > 0) throw new InvalidEditProblems(unknown.map((field) => `"${field}" is not a field of a trigger (${[...FIELDS].join(", ")})`));
|
|
73
|
-
const written = {
|
|
74
|
-
...document,
|
|
75
|
-
key
|
|
76
|
-
};
|
|
77
|
-
const parsed = readTriggerDefinition(written, "trigger");
|
|
78
|
-
if ("problems" in parsed) throw new InvalidEditProblems(parsed.problems);
|
|
79
|
-
const documents = await readTriggerDocuments(directory);
|
|
80
|
-
const at = documents.findIndex((entry) => entry["key"] === key);
|
|
81
|
-
const others = documents.filter((_, index) => index !== at).flatMap((entry) => {
|
|
82
|
-
const read = readTriggerDefinition(entry, "trigger");
|
|
83
|
-
return "definition" in read ? [read.definition] : [];
|
|
84
|
-
});
|
|
85
|
-
const problems = triggerProblemsOf(parts, [...others, parsed.definition]).get(key) ?? [];
|
|
86
|
-
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
87
|
-
await writeDocuments(directory, at < 0 ? [...documents, written] : documents.map((entry, index) => index === at ? written : entry));
|
|
88
|
-
return at < 0 ? "created" : "replaced";
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Removes one trigger from the world's file, keeping its document in `.trash/triggers` so that it can be put back. A trigger that others wait for
|
|
92
|
-
* cannot be removed.
|
|
93
|
-
* @returns where the document was kept.
|
|
94
|
-
* @throws {InvalidEditProblems}
|
|
95
|
-
*/
|
|
96
|
-
async function deleteTriggerDocument(directory, key) {
|
|
97
|
-
const documents = await readTriggerDocuments(directory);
|
|
98
|
-
const found = documents.find((entry) => entry["key"] === key);
|
|
99
|
-
if (found === void 0) throw new InvalidEditProblems([`there is no trigger "${key}"`]);
|
|
100
|
-
const waiting = documents.flatMap((entry) => {
|
|
101
|
-
const read = readTriggerDefinition(entry, "trigger");
|
|
102
|
-
return "definition" in read && read.definition.key !== key && waitsFor(read.definition.condition).includes(key) ? [read.definition.key] : [];
|
|
103
|
-
});
|
|
104
|
-
if (waiting.length > 0) throw new InvalidEditProblems([`${waiting.join(", ")} wait${waiting.length === 1 ? "s" : ""} for "${key}" to fire; change ${waiting.length === 1 ? "it" : "them"} first`]);
|
|
105
|
-
const trash = join(directory, ".trash", "triggers");
|
|
106
|
-
await mkdir(trash, { recursive: true });
|
|
107
|
-
const kept = join(trash, `${key}-${Date.now()}-${randomUUID()}.json`);
|
|
108
|
-
await writeFile(kept, `${JSON.stringify(found, null, 2)}\n`, { flag: "wx" });
|
|
109
|
-
await writeDocuments(directory, documents.filter((entry) => entry !== found));
|
|
110
|
-
return kept;
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
113
7
|
//#region src/host/authoring/read-tools.ts
|
|
114
8
|
const output$3 = (value) => [{
|
|
115
9
|
type: "text",
|
|
@@ -337,59 +231,6 @@ function authoredWorldReadTools(reader) {
|
|
|
337
231
|
];
|
|
338
232
|
}
|
|
339
233
|
//#endregion
|
|
340
|
-
//#region src/host/interface/world-packs.ts
|
|
341
|
-
/** The kinds of file an assistant may write, as text. */
|
|
342
|
-
const TEXT_EXTENSIONS = [
|
|
343
|
-
"html",
|
|
344
|
-
"css",
|
|
345
|
-
"js",
|
|
346
|
-
"json",
|
|
347
|
-
"txt",
|
|
348
|
-
"svg"
|
|
349
|
-
];
|
|
350
|
-
const folderOf = (directory, pack) => join(directory, "ui", pack);
|
|
351
|
-
function checked(directory, pack) {
|
|
352
|
-
if (!isPackId(pack)) throw new Error(`"${pack}" is not a usable pack name (letters, digits, "-" and "_")`);
|
|
353
|
-
return folderOf(directory, pack);
|
|
354
|
-
}
|
|
355
|
-
/** What every pack the world carries holds and what is wrong with it. */
|
|
356
|
-
function listWorldPacks(directory) {
|
|
357
|
-
return packIds(directory).map((id) => {
|
|
358
|
-
const { pack, problems } = readPack(folderOf(directory, id), id, (file) => file);
|
|
359
|
-
const files = pack === void 0 ? [] : [...pack.files.keys()];
|
|
360
|
-
return {
|
|
361
|
-
id,
|
|
362
|
-
name: pack?.manifest.name ?? id,
|
|
363
|
-
problems,
|
|
364
|
-
files
|
|
365
|
-
};
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
/** What is wrong with a pack (nothing when it can be used). */
|
|
369
|
-
function checkWorldPack(directory, pack) {
|
|
370
|
-
const folder = checked(directory, pack);
|
|
371
|
-
if (!existsSync(folder)) throw new Error(`the world carries no pack "${pack}"`);
|
|
372
|
-
return readPack(folder, pack, (file) => file).problems;
|
|
373
|
-
}
|
|
374
|
-
/** Moves a file of a pack into the world's `.trash`. @returns where it went, and what is wrong with the pack now. */
|
|
375
|
-
async function deleteWorldPackFile(directory, pack, path) {
|
|
376
|
-
const relative = packPath(path);
|
|
377
|
-
if (relative === void 0 || !(extname(relative).slice(1).toLowerCase() in PACK_MEDIA_TYPES)) throw new Error(`"${path}" is not a file of a pack`);
|
|
378
|
-
const folder = checked(directory, pack);
|
|
379
|
-
const file = join(folder, ...relative.split("/"));
|
|
380
|
-
if (!existsSync(file)) throw new Error(`the pack "${pack}" has no file "${path}"`);
|
|
381
|
-
const aside = join(directory, ".trash", "ui", pack, `${relative.replaceAll("/", "__")}.${Date.now()}`);
|
|
382
|
-
await mkdir(dirname(aside), { recursive: true });
|
|
383
|
-
await rename(file, aside);
|
|
384
|
-
return {
|
|
385
|
-
trashPath: aside,
|
|
386
|
-
problems: existsSync(join(folder, "pack.json")) ? readPack(folder, pack, (address) => address).problems : [{
|
|
387
|
-
file: "pack.json",
|
|
388
|
-
message: "the pack has no pack.json"
|
|
389
|
-
}]
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
//#endregion
|
|
393
234
|
//#region src/host/authoring/pack-tools.ts
|
|
394
235
|
const PACK_MUTATION_TOOLS = ["delete_world_pack_file"];
|
|
395
236
|
const output$2 = (value) => [{
|
|
@@ -615,6 +456,7 @@ const keyParameter = {
|
|
|
615
456
|
description: "Stable entity key."
|
|
616
457
|
};
|
|
617
458
|
const AUTHORING_MUTATION_TOOLS = /* @__PURE__ */ new Set([
|
|
459
|
+
"import_preset",
|
|
618
460
|
"create_world_element",
|
|
619
461
|
"replace_world_element",
|
|
620
462
|
"delete_world_element",
|
|
@@ -801,6 +643,14 @@ function authoredWorldWriteTools(reader) {
|
|
|
801
643
|
async function authoringApproval(exec, next, reviewing = () => Promise.resolve(false)) {
|
|
802
644
|
if (!AUTHORING_MUTATION_TOOLS.has(exec.name) || exec.agent === void 0 || authoredWorldOf(exec.agent.session.id) === void 0) return await next();
|
|
803
645
|
const args = exec.arguments;
|
|
646
|
+
if (exec.name === "import_preset" && exec.agent !== void 0) return {
|
|
647
|
+
kind: "ask",
|
|
648
|
+
reason: "replace the authored world's narration and character-style prompts with ones made from the uploaded preset",
|
|
649
|
+
displayReason: {
|
|
650
|
+
en: "Replace the world's narration and character-style prompts with ones made from the uploaded preset?",
|
|
651
|
+
zh: "用上传的预设生成的提示词,替换世界的叙述与角色风格提示词?"
|
|
652
|
+
}
|
|
653
|
+
};
|
|
804
654
|
const prompt = PROMPT_MUTATION_TOOLS.includes(exec.name);
|
|
805
655
|
const pack = PACK_MUTATION_TOOLS.includes(exec.name);
|
|
806
656
|
const importing = await reviewing(exec.agent.session.id);
|
|
@@ -851,97 +701,6 @@ async function authoringApproval(exec, next, reviewing = () => Promise.resolve(f
|
|
|
851
701
|
};
|
|
852
702
|
}
|
|
853
703
|
//#endregion
|
|
854
|
-
//#region src/host/authoring/pack-jail.ts
|
|
855
|
-
/** DSH's own file tools, which the world authoring chat uses on the interface packs and nothing else. */
|
|
856
|
-
const PACK_FILE_TOOLS = [
|
|
857
|
-
"read",
|
|
858
|
-
"write",
|
|
859
|
-
"edit"
|
|
860
|
-
];
|
|
861
|
-
const WRITING = ["write", "edit"];
|
|
862
|
-
/** The most text a call may carry. */
|
|
863
|
-
const MAX_PACK_TEXT = 204800;
|
|
864
|
-
function unsafePath(ui, path) {
|
|
865
|
-
const parts = relative(ui, path).split(sep);
|
|
866
|
-
let current = ui;
|
|
867
|
-
for (const part of ["", ...parts]) {
|
|
868
|
-
if (part !== "") current = join(current, part);
|
|
869
|
-
try {
|
|
870
|
-
if (lstatSync(current).isSymbolicLink()) return `the path passes through the symbolic link ${current}`;
|
|
871
|
-
} catch (error) {
|
|
872
|
-
if (error.code === "ENOENT") break;
|
|
873
|
-
if (error.code === "ENOTDIR") return `${current} cannot be traversed as a folder`;
|
|
874
|
-
throw error;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Why a call of a file tool is not one on an interface pack of the world, or nothing when it is: the file must be a text
|
|
880
|
-
* file of a pack folder `<world>/ui/<pack>/`, and a write must not carry more text than a pack file may hold.
|
|
881
|
-
* @param path - the absolute path asked for.
|
|
882
|
-
* @param world - the world's folder.
|
|
883
|
-
*/
|
|
884
|
-
function packFileProblem(tool, path, world, texts = []) {
|
|
885
|
-
const ui = join(world, "ui");
|
|
886
|
-
const inside = relative(ui, path);
|
|
887
|
-
const segments = inside.split(sep);
|
|
888
|
-
const hint = `in this chat the file tools reach only the text files of the world's interface packs, ${join(ui, "<pack>", "<file>")}. Nothing, not another path and not sandbox_permissions, lifts that: do not try again for this file, tell the person that it cannot be changed from here`;
|
|
889
|
-
if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || segments.length < 2) return `${path} is not a file of an interface pack: ${hint}`;
|
|
890
|
-
if (!isPackId(segments[0])) return `"${segments[0]}" is not a usable pack name (letters, digits, "-" and "_"): ${hint}`;
|
|
891
|
-
if (segments.some((segment) => segment.startsWith("."))) return `${path}: names may not start with a dot`;
|
|
892
|
-
if (!TEXT_EXTENSIONS.includes(extname(path).slice(1).toLowerCase())) return `${path} is not a text file of a pack (${TEXT_EXTENSIONS.join(", ")}); pictures and other files are added by hand`;
|
|
893
|
-
const unsafe = unsafePath(ui, path);
|
|
894
|
-
if (unsafe !== void 0) return `${path}: ${unsafe}; file tools do not follow symbolic links in interface packs`;
|
|
895
|
-
if (WRITING.includes(tool) && texts.some((text) => Buffer.byteLength(text) > 204800)) return `a call may carry at most ${MAX_PACK_TEXT / 1024} KB of text`;
|
|
896
|
-
}
|
|
897
|
-
const textOf = (value) => typeof value === "string" ? [value] : [];
|
|
898
|
-
/**
|
|
899
|
-
* Keeps DSH's `read`, `write` and `edit` on the interface packs of the world in an authoring chat, and asks the person before
|
|
900
|
-
* any change. It stands first in the chain, so that what it refuses cannot be let through by a listener after it; and what a
|
|
901
|
-
* later listener decides still stands: a plugin that denies or asks keeps doing so, and only a plain allow becomes an ask.
|
|
902
|
-
*/
|
|
903
|
-
async function packJail(exec, next, deps) {
|
|
904
|
-
const chat = exec.agent?.session.id;
|
|
905
|
-
if (!PACK_FILE_TOOLS.includes(exec.name) || chat === void 0 || authoredWorldOf(chat) === void 0) return await next();
|
|
906
|
-
const world = await deps.worldDirectory(chat);
|
|
907
|
-
if (world === void 0) return {
|
|
908
|
-
kind: "deny",
|
|
909
|
-
reason: "the world of this chat no longer exists"
|
|
910
|
-
};
|
|
911
|
-
const args = exec.arguments;
|
|
912
|
-
const requested = args["file_path"];
|
|
913
|
-
if (typeof requested !== "string" || requested === "" || requested.startsWith("~")) return {
|
|
914
|
-
kind: "deny",
|
|
915
|
-
reason: "file_path must be a path of an interface pack of this world"
|
|
916
|
-
};
|
|
917
|
-
const path = resolve(exec.agent?.session.header.cwd ?? world, requested);
|
|
918
|
-
const problem = packFileProblem(exec.name, path, world, [...textOf(args["content"]), ...textOf(args["new_string"])]);
|
|
919
|
-
if (problem !== void 0) return {
|
|
920
|
-
kind: "deny",
|
|
921
|
-
reason: problem
|
|
922
|
-
};
|
|
923
|
-
const writing = WRITING.includes(exec.name);
|
|
924
|
-
if (writing && await deps.reviewing(chat)) return {
|
|
925
|
-
kind: "deny",
|
|
926
|
-
reason: "an import does not write interface packs; they are left to the person"
|
|
927
|
-
};
|
|
928
|
-
const decision = await next();
|
|
929
|
-
if (!writing || decision.kind !== "allow") return decision;
|
|
930
|
-
const target = `“${relative(join(world, "ui"), path)}”`;
|
|
931
|
-
return {
|
|
932
|
-
kind: "ask",
|
|
933
|
-
reason: `${exec.name} interface pack file ${target}`,
|
|
934
|
-
displayReason: {
|
|
935
|
-
en: `${exec.name === "write" ? "Write" : "Edit"} ${target} of an interface pack in the world files?`,
|
|
936
|
-
zh: `${exec.name === "write" ? "写入" : "编辑"}世界文件中界面包的文件${target}?`
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
/** Puts the jail first in the chain of `tools/pre-execute`: what it refuses cannot be let through by a listener after it. */
|
|
941
|
-
function registerPackJail(ctx, deps) {
|
|
942
|
-
ctx.on("tools/pre-execute", (exec, next) => packJail(exec, next, deps), { prepend: true });
|
|
943
|
-
}
|
|
944
|
-
//#endregion
|
|
945
704
|
//#region src/authoring.ts
|
|
946
705
|
const name = "@dsh-agentic-roleplay/core/authoring";
|
|
947
706
|
const inject = [
|
|
@@ -968,6 +727,7 @@ function apply(ctx) {
|
|
|
968
727
|
for (const tool of worldPromptTools(reader)) ctx.tools.register(tool);
|
|
969
728
|
for (const tool of worldPackTools(reader)) ctx.tools.register(tool);
|
|
970
729
|
for (const tool of importTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
|
|
730
|
+
for (const tool of presetTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
|
|
971
731
|
for (const tool of translateTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
|
|
972
732
|
importHooks(ctx, ctx.roleplayWorlds, prompting);
|
|
973
733
|
const reviewing = async (chat) => {
|