@sparkelf/dsh-group-chat 0.3.0 → 0.4.1
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/client.js +146 -133
- package/lib/client.js.map +1 -1
- package/lib/index.js +30 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8880,14 +8880,6 @@ const name = "group-chat";
|
|
|
8880
8880
|
* everyone. Recognized by id because that survives the round trip through the session.
|
|
8881
8881
|
*/
|
|
8882
8882
|
const WARM_UP_PREFIX = "warm-up-";
|
|
8883
|
-
/**
|
|
8884
|
-
* The block type a reply uses to carry the message it answers.
|
|
8885
|
-
*
|
|
8886
|
-
* The host bundle and the client bundle are evaluated separately, so this string is written
|
|
8887
|
-
* here as well as in the renderer that reads it. `quote-block-type.test.ts` holds the two
|
|
8888
|
-
* together: a silent divergence would publish quotes nothing draws.
|
|
8889
|
-
*/
|
|
8890
|
-
const QUOTE_BLOCK_TYPE = "group-chat-quote";
|
|
8891
8883
|
/** Host services this plugin needs beyond the room runtime. */
|
|
8892
8884
|
const inject = [
|
|
8893
8885
|
"agents",
|
|
@@ -9064,6 +9056,35 @@ const writePreferences = async (preferences, env = process.env) => {
|
|
|
9064
9056
|
}
|
|
9065
9057
|
return normalised;
|
|
9066
9058
|
};
|
|
9059
|
+
/**
|
|
9060
|
+
* Puts a pending quote at the head of a message's text.
|
|
9061
|
+
*
|
|
9062
|
+
* As a blockquote line rather than as a block of its own. A block type the model side does not
|
|
9063
|
+
* know is dropped on the way into the prompt — the reply would be published with a quote only
|
|
9064
|
+
* people could see — and the official bubble draws such a block as a collapsed "extra content"
|
|
9065
|
+
* row underneath. Text is read by both: the model gets the quote as context, and the renderer
|
|
9066
|
+
* shows it as a quote.
|
|
9067
|
+
*
|
|
9068
|
+
* @param content - the message the member typed.
|
|
9069
|
+
* @param quote - the reply target the browser registered.
|
|
9070
|
+
* @returns the content with the quote line prepended.
|
|
9071
|
+
*/
|
|
9072
|
+
const withQuote = (content, quote) => {
|
|
9073
|
+
const line = `> ${quote.authorName === void 0 ? "" : `${quote.authorName}:`}${quote.preview}`;
|
|
9074
|
+
const blocks = [...content];
|
|
9075
|
+
const at = blocks.findIndex((block) => block.type === "text");
|
|
9076
|
+
if (at < 0) return [{
|
|
9077
|
+
type: "text",
|
|
9078
|
+
text: line
|
|
9079
|
+
}, ...blocks];
|
|
9080
|
+
const target = blocks[at];
|
|
9081
|
+
const text = typeof target.text === "string" ? target.text : "";
|
|
9082
|
+
blocks[at] = {
|
|
9083
|
+
...target,
|
|
9084
|
+
text: `${line}\n\n${text}`
|
|
9085
|
+
};
|
|
9086
|
+
return blocks;
|
|
9087
|
+
};
|
|
9067
9088
|
/** True when `data` looks like a `user/message` payload this workspace composed itself. */
|
|
9068
9089
|
/**
|
|
9069
9090
|
* True when a `user/message` carries runtime bookkeeping rather than something a member typed.
|
|
@@ -9396,12 +9417,7 @@ const activate = (ctx, target) => {
|
|
|
9396
9417
|
const mentions = mentionedMemberIds(textOfContent(content), runtimes.get(roomId)?.members ?? []);
|
|
9397
9418
|
const quote = pendingQuotes.get(roomId);
|
|
9398
9419
|
pendingQuotes.delete(roomId);
|
|
9399
|
-
const outgoing = quote === void 0 ? content :
|
|
9400
|
-
type: QUOTE_BLOCK_TYPE,
|
|
9401
|
-
messageId: quote.messageId,
|
|
9402
|
-
preview: quote.preview,
|
|
9403
|
-
...quote.authorName === void 0 ? {} : { authorName: quote.authorName }
|
|
9404
|
-
}];
|
|
9420
|
+
const outgoing = quote === void 0 ? content : withQuote(content, quote);
|
|
9405
9421
|
backend.sendMessage(roomId, {
|
|
9406
9422
|
content: outgoing,
|
|
9407
9423
|
rpcId: typeof messageId === "string" && messageId.length > 0 ? messageId : `local-${String(Date.now())}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkelf/dsh-group-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Human-agent group chat for DataOps-managed DSH workspaces: rooms broadcast to every member, and only a member's own @mention wakes that member's agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|