@primusclaw/personal-agent-teams 0.15.0 → 0.15.2
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/index.js +28 -3
- package/dist/main.js +28 -3
- package/dist/types/activity/inbound/mentions.d.ts +12 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5013,6 +5013,23 @@ function toBotPattern(botName) {
|
|
|
5013
5013
|
function addressedToBot(activity, botName = DEFAULT_BOT_NAME) {
|
|
5014
5014
|
return toBotPattern(botName).test(written(activity));
|
|
5015
5015
|
}
|
|
5016
|
+
var typedName = /* @__PURE__ */ new Map();
|
|
5017
|
+
function typedNamePattern(botName) {
|
|
5018
|
+
let pattern = typedName.get(botName);
|
|
5019
|
+
if (pattern === void 0) {
|
|
5020
|
+
pattern = new RegExp(
|
|
5021
|
+
`^${SPACE}*@?${caseless(botName)}(?![\\p{L}\\p{N}_-])${SPACE}+(?=/\\p{L}[\\p{L}\\p{N}_-]*(?:${SPACE}|$))`,
|
|
5022
|
+
"u"
|
|
5023
|
+
);
|
|
5024
|
+
typedName.set(botName, pattern);
|
|
5025
|
+
}
|
|
5026
|
+
return pattern;
|
|
5027
|
+
}
|
|
5028
|
+
function withoutTypedBotName(text4, botName) {
|
|
5029
|
+
const named = typedNamePattern(botName).exec(text4);
|
|
5030
|
+
if (named === null) return { text: text4, removed: 0 };
|
|
5031
|
+
return { text: text4.slice(named[0].length), removed: cpLength7(named[0]) };
|
|
5032
|
+
}
|
|
5016
5033
|
function messageText(activity) {
|
|
5017
5034
|
let text4 = written(activity);
|
|
5018
5035
|
const botId = botIdOf(activity);
|
|
@@ -5129,15 +5146,23 @@ function messageOf(activity, sender, options) {
|
|
|
5129
5146
|
logPlaceholderQuotes(activity, found, logger);
|
|
5130
5147
|
logUnreadKinds(activity, logger);
|
|
5131
5148
|
const bot = partOf(activity, "recipient");
|
|
5149
|
+
const botName = options.botName ?? DEFAULT_BOT_NAME;
|
|
5150
|
+
const said = withoutTypedBotName(
|
|
5151
|
+
forwarded.forwards.length && !forwardsInText(activity) ? ownWords(messageText(activity), forwarded.forwards, /<attachment\b/iu.test(pyStr14(activity.text))) : messageText(activity),
|
|
5152
|
+
botName
|
|
5153
|
+
);
|
|
5132
5154
|
return {
|
|
5133
5155
|
type: "message",
|
|
5134
5156
|
...base(activity, sender),
|
|
5135
|
-
text:
|
|
5157
|
+
text: said.text,
|
|
5136
5158
|
mentioned: isMentioned(activity),
|
|
5137
5159
|
targeted: isTargeted(activity),
|
|
5138
|
-
|
|
5160
|
+
// (a name taken off the text, with its @ or without, is the person naming the bot: an attached chat keeps those words for the bot, so
|
|
5161
|
+
// "<name> /clear" is not sent bare as "/clear" to the agent while "@<name> /clear" stays with the bot)
|
|
5162
|
+
namesBotFirst: said.removed > 0 || addressedToBot(activity, botName),
|
|
5139
5163
|
conversationName: personal ? "" : pyStr14(partOf(activity, "conversation")["name"]),
|
|
5140
|
-
|
|
5164
|
+
// (the offsets are in the text: where the name typed ahead stood is not there any more)
|
|
5165
|
+
mentions: mentionsOf(activity).filter((m) => m.offset >= said.removed).map((m) => ({ ...m, offset: m.offset - said.removed })),
|
|
5141
5166
|
links: inboundLinksOf(activity),
|
|
5142
5167
|
quotes: found.map((q) => ({
|
|
5143
5168
|
author: q.sender,
|
package/dist/main.js
CHANGED
|
@@ -1208,6 +1208,23 @@ function toBotPattern(botName) {
|
|
|
1208
1208
|
function addressedToBot(activity, botName = DEFAULT_BOT_NAME) {
|
|
1209
1209
|
return toBotPattern(botName).test(written(activity));
|
|
1210
1210
|
}
|
|
1211
|
+
var typedName = /* @__PURE__ */ new Map();
|
|
1212
|
+
function typedNamePattern(botName) {
|
|
1213
|
+
let pattern = typedName.get(botName);
|
|
1214
|
+
if (pattern === void 0) {
|
|
1215
|
+
pattern = new RegExp(
|
|
1216
|
+
`^${SPACE}*@?${caseless(botName)}(?![\\p{L}\\p{N}_-])${SPACE}+(?=/\\p{L}[\\p{L}\\p{N}_-]*(?:${SPACE}|$))`,
|
|
1217
|
+
"u"
|
|
1218
|
+
);
|
|
1219
|
+
typedName.set(botName, pattern);
|
|
1220
|
+
}
|
|
1221
|
+
return pattern;
|
|
1222
|
+
}
|
|
1223
|
+
function withoutTypedBotName(text4, botName) {
|
|
1224
|
+
const named = typedNamePattern(botName).exec(text4);
|
|
1225
|
+
if (named === null) return { text: text4, removed: 0 };
|
|
1226
|
+
return { text: text4.slice(named[0].length), removed: cpLength2(named[0]) };
|
|
1227
|
+
}
|
|
1211
1228
|
function messageText(activity) {
|
|
1212
1229
|
let text4 = written(activity);
|
|
1213
1230
|
const botId = botIdOf(activity);
|
|
@@ -1324,15 +1341,23 @@ function messageOf(activity, sender, options) {
|
|
|
1324
1341
|
logPlaceholderQuotes(activity, found, logger);
|
|
1325
1342
|
logUnreadKinds(activity, logger);
|
|
1326
1343
|
const bot = partOf(activity, "recipient");
|
|
1344
|
+
const botName = options.botName ?? DEFAULT_BOT_NAME;
|
|
1345
|
+
const said = withoutTypedBotName(
|
|
1346
|
+
forwarded.forwards.length && !forwardsInText(activity) ? ownWords(messageText(activity), forwarded.forwards, /<attachment\b/iu.test(pyStr11(activity.text))) : messageText(activity),
|
|
1347
|
+
botName
|
|
1348
|
+
);
|
|
1327
1349
|
return {
|
|
1328
1350
|
type: "message",
|
|
1329
1351
|
...base(activity, sender),
|
|
1330
|
-
text:
|
|
1352
|
+
text: said.text,
|
|
1331
1353
|
mentioned: isMentioned(activity),
|
|
1332
1354
|
targeted: isTargeted(activity),
|
|
1333
|
-
|
|
1355
|
+
// (a name taken off the text, with its @ or without, is the person naming the bot: an attached chat keeps those words for the bot, so
|
|
1356
|
+
// "<name> /clear" is not sent bare as "/clear" to the agent while "@<name> /clear" stays with the bot)
|
|
1357
|
+
namesBotFirst: said.removed > 0 || addressedToBot(activity, botName),
|
|
1334
1358
|
conversationName: personal ? "" : pyStr11(partOf(activity, "conversation")["name"]),
|
|
1335
|
-
|
|
1359
|
+
// (the offsets are in the text: where the name typed ahead stood is not there any more)
|
|
1360
|
+
mentions: mentionsOf(activity).filter((m) => m.offset >= said.removed).map((m) => ({ ...m, offset: m.offset - said.removed })),
|
|
1336
1361
|
links: inboundLinksOf(activity),
|
|
1337
1362
|
quotes: found.map((q) => ({
|
|
1338
1363
|
author: q.sender,
|
|
@@ -22,6 +22,18 @@ export declare function isTargeted(activity: Activity): boolean;
|
|
|
22
22
|
* the person says these words are for the bot and not for the session.
|
|
23
23
|
*/
|
|
24
24
|
export declare function addressedToBot(activity: Activity, botName?: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* `text` without the bot's name typed as words ahead of a command (`@<name> /approvals`, `<name> /approvals`), and how many code points
|
|
27
|
+
* that took off its start. A mention a person picks is an entity, which `messageText` drops; one Teams on a phone sends as plain words
|
|
28
|
+
* (2026-11-26 03:24: "@<name> /approvals") has none, so it stayed in the text and `/approvals` was read as a sentence, not as the
|
|
29
|
+
* command. Only the name first and a command word after it: any other words, the name alone, a word that merely starts with the name
|
|
30
|
+
* and a path (`/tmp/app.log`) stay as they were typed, so no ordinary chat becomes a command. A name taken off here, with its @ or without,
|
|
31
|
+
* is the person naming the bot, so the caller also reads the message as naming the bot first (`addressedToBot` reads only the @ form).
|
|
32
|
+
*/
|
|
33
|
+
export declare function withoutTypedBotName(text: string, botName: string): {
|
|
34
|
+
readonly text: string;
|
|
35
|
+
readonly removed: number;
|
|
36
|
+
};
|
|
25
37
|
/**
|
|
26
38
|
* The person's text without the bot's @mention markup and without what Teams adds for a quote: the words the commands
|
|
27
39
|
* are read from. With no recipient id every mention is removed (the 1:1 behaviour); in a group chat a mention of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-teams",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "The personal agent on Microsoft Teams: activities, Adaptive Cards, streams, Bot Connector, inbound queue, and the worker's Teams surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@azure/core-auth": "^1.11.0",
|
|
37
37
|
"@azure/service-bus": "^7.10.0",
|
|
38
|
-
"@primusclaw/personal-agent": "0.15.
|
|
39
|
-
"@primusclaw/personal-agent-runtime": "0.15.
|
|
38
|
+
"@primusclaw/personal-agent": "0.15.2",
|
|
39
|
+
"@primusclaw/personal-agent-runtime": "0.15.2",
|
|
40
40
|
"zod": "^4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|