@yoooclaw/phone-notifications 1.11.4-beta.2 → 1.11.4-beta.3
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.cjs +28 -143
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5480,7 +5480,7 @@ function readBuildInjectedVersion() {
|
|
|
5480
5480
|
if (false) {
|
|
5481
5481
|
return void 0;
|
|
5482
5482
|
}
|
|
5483
|
-
const version = "1.11.4-beta.
|
|
5483
|
+
const version = "1.11.4-beta.3".trim();
|
|
5484
5484
|
return version || void 0;
|
|
5485
5485
|
}
|
|
5486
5486
|
function readPluginVersionFromPackageJson() {
|
|
@@ -7097,109 +7097,6 @@ function resolveLightTitle(title, reason, segments) {
|
|
|
7097
7097
|
return `Effect: ${modeDesc || "custom"}`;
|
|
7098
7098
|
}
|
|
7099
7099
|
|
|
7100
|
-
// src/light-rules/local-matcher.ts
|
|
7101
|
-
var CONTACT_PREFIXES = ["\u91CD\u8981\u8054\u7CFB\u4EBA", "\u8054\u7CFB\u4EBA"];
|
|
7102
|
-
var CONTACT_ACTION_RE = /(给我)?发(?:来)?消息|(给我)?发信息|来消息|回复(?:我)?|回应(?:我)?|私聊(?:我)?/u;
|
|
7103
|
-
var LEADING_SENDER_RE = /^(.{1,40}?)(?:\s+回应)?\s*[::]/u;
|
|
7104
|
-
function matchNotificationsLocally(notifications, rules) {
|
|
7105
|
-
const parsedRules = rules.map((rule) => parseContactRule(rule)).filter((item) => item !== null);
|
|
7106
|
-
if (parsedRules.length === 0) {
|
|
7107
|
-
return [];
|
|
7108
|
-
}
|
|
7109
|
-
const results = [];
|
|
7110
|
-
notifications.forEach((notification, notificationIndex) => {
|
|
7111
|
-
const senders = collectSenderCandidates(notification);
|
|
7112
|
-
if (senders.length === 0) {
|
|
7113
|
-
return;
|
|
7114
|
-
}
|
|
7115
|
-
parsedRules.forEach((rule) => {
|
|
7116
|
-
if (senders.some((sender) => senderMatchesContact(sender, rule.contactName))) {
|
|
7117
|
-
results.push({ notificationIndex, ruleName: rule.ruleName });
|
|
7118
|
-
}
|
|
7119
|
-
});
|
|
7120
|
-
});
|
|
7121
|
-
return results;
|
|
7122
|
-
}
|
|
7123
|
-
function parseContactRule(rule) {
|
|
7124
|
-
const contactName = extractImportantContact(rule.description);
|
|
7125
|
-
if (!contactName) {
|
|
7126
|
-
return null;
|
|
7127
|
-
}
|
|
7128
|
-
return {
|
|
7129
|
-
ruleName: rule.name,
|
|
7130
|
-
contactName
|
|
7131
|
-
};
|
|
7132
|
-
}
|
|
7133
|
-
function extractImportantContact(description) {
|
|
7134
|
-
const text = description.trim();
|
|
7135
|
-
if (!text) {
|
|
7136
|
-
return null;
|
|
7137
|
-
}
|
|
7138
|
-
for (const prefix of CONTACT_PREFIXES) {
|
|
7139
|
-
const start = text.indexOf(prefix);
|
|
7140
|
-
if (start < 0) {
|
|
7141
|
-
continue;
|
|
7142
|
-
}
|
|
7143
|
-
const tail = text.slice(start + prefix.length);
|
|
7144
|
-
const actionMatch = CONTACT_ACTION_RE.exec(tail);
|
|
7145
|
-
if (!actionMatch || actionMatch.index === 0) {
|
|
7146
|
-
continue;
|
|
7147
|
-
}
|
|
7148
|
-
const rawName = tail.slice(0, actionMatch.index).trim();
|
|
7149
|
-
const cleaned = trimContactName(rawName);
|
|
7150
|
-
if (cleaned) {
|
|
7151
|
-
return cleaned;
|
|
7152
|
-
}
|
|
7153
|
-
}
|
|
7154
|
-
return null;
|
|
7155
|
-
}
|
|
7156
|
-
function trimContactName(value) {
|
|
7157
|
-
const cleaned = value.replace(/^[是为叫做名为\s]+/u, "").replace(/[,。,.;;].*$/u, "").trim();
|
|
7158
|
-
return cleaned || null;
|
|
7159
|
-
}
|
|
7160
|
-
function collectSenderCandidates(notification) {
|
|
7161
|
-
const candidates = [
|
|
7162
|
-
notification.senderName,
|
|
7163
|
-
notification.title,
|
|
7164
|
-
notification.conversationName,
|
|
7165
|
-
extractLeadingSender(notification.content)
|
|
7166
|
-
];
|
|
7167
|
-
const deduped = /* @__PURE__ */ new Map();
|
|
7168
|
-
for (const candidate of candidates) {
|
|
7169
|
-
if (!candidate) {
|
|
7170
|
-
continue;
|
|
7171
|
-
}
|
|
7172
|
-
const normalized = normalizeComparableName(candidate);
|
|
7173
|
-
if (normalized.length < 2) {
|
|
7174
|
-
continue;
|
|
7175
|
-
}
|
|
7176
|
-
deduped.set(normalized, candidate);
|
|
7177
|
-
}
|
|
7178
|
-
return Array.from(deduped.values());
|
|
7179
|
-
}
|
|
7180
|
-
function extractLeadingSender(content) {
|
|
7181
|
-
const text = content.trim();
|
|
7182
|
-
if (!text) {
|
|
7183
|
-
return null;
|
|
7184
|
-
}
|
|
7185
|
-
const match = LEADING_SENDER_RE.exec(text);
|
|
7186
|
-
if (!match) {
|
|
7187
|
-
return null;
|
|
7188
|
-
}
|
|
7189
|
-
return match[1]?.trim() || null;
|
|
7190
|
-
}
|
|
7191
|
-
function senderMatchesContact(sender, contactName) {
|
|
7192
|
-
const normalizedSender = normalizeComparableName(sender);
|
|
7193
|
-
const normalizedContact = normalizeComparableName(contactName);
|
|
7194
|
-
if (!normalizedSender || !normalizedContact) {
|
|
7195
|
-
return false;
|
|
7196
|
-
}
|
|
7197
|
-
return normalizedSender.includes(normalizedContact) || normalizedContact.includes(normalizedSender);
|
|
7198
|
-
}
|
|
7199
|
-
function normalizeComparableName(value) {
|
|
7200
|
-
return value.normalize("NFKC").replace(new RegExp("\\p{Extended_Pictographic}", "gu"), "").replace(/\s+/gu, "").replace(/[^\p{L}\p{N}]/gu, "");
|
|
7201
|
-
}
|
|
7202
|
-
|
|
7203
7100
|
// src/light-rules/inline-evaluator.ts
|
|
7204
7101
|
var InlineLightRuleEvaluator = class {
|
|
7205
7102
|
logger;
|
|
@@ -7219,40 +7116,8 @@ var InlineLightRuleEvaluator = class {
|
|
|
7219
7116
|
if (notifications.length === 0) return true;
|
|
7220
7117
|
const rules = this.registry.getEnabled();
|
|
7221
7118
|
if (rules.length === 0) return true;
|
|
7222
|
-
const
|
|
7223
|
-
|
|
7224
|
-
const llmCandidateRules = rules.filter((rule) => !localMatchedRuleNames.has(rule.name));
|
|
7225
|
-
const combinedMatches = /* @__PURE__ */ new Map();
|
|
7226
|
-
for (const match of localMatches) {
|
|
7227
|
-
combinedMatches.set(
|
|
7228
|
-
`${match.notificationIndex}:${match.ruleName}`,
|
|
7229
|
-
match
|
|
7230
|
-
);
|
|
7231
|
-
}
|
|
7232
|
-
if (localMatches.length > 0) {
|
|
7233
|
-
this.logger.info(
|
|
7234
|
-
`lightrules: local matched ${localMatchedRuleNames.size} rule(s) (notifications=${notifications.length}, remainingRules=${llmCandidateRules.length})`
|
|
7235
|
-
);
|
|
7236
|
-
}
|
|
7237
|
-
if (llmCandidateRules.length > 0) {
|
|
7238
|
-
const llmMatches = await this.invoker.matchNotifications(notifications, llmCandidateRules);
|
|
7239
|
-
if (llmMatches === null) {
|
|
7240
|
-
if (combinedMatches.size === 0) {
|
|
7241
|
-
return false;
|
|
7242
|
-
}
|
|
7243
|
-
this.logger.warn(
|
|
7244
|
-
`lightrules: invoker failed; using ${combinedMatches.size} local fallback match(es)`
|
|
7245
|
-
);
|
|
7246
|
-
} else {
|
|
7247
|
-
for (const match of llmMatches) {
|
|
7248
|
-
combinedMatches.set(
|
|
7249
|
-
`${match.notificationIndex}:${match.ruleName}`,
|
|
7250
|
-
match
|
|
7251
|
-
);
|
|
7252
|
-
}
|
|
7253
|
-
}
|
|
7254
|
-
}
|
|
7255
|
-
const matches = Array.from(combinedMatches.values());
|
|
7119
|
+
const matches = await this.invoker.matchNotifications(notifications, rules);
|
|
7120
|
+
if (matches === null) return false;
|
|
7256
7121
|
if (matches.length === 0) {
|
|
7257
7122
|
this.logger.info(
|
|
7258
7123
|
`lightrules: 0 matches (notifications=${notifications.length}, rules=${rules.length})`
|
|
@@ -7465,15 +7330,35 @@ function buildSystemPrompt(rules) {
|
|
|
7465
7330
|
lines.push("");
|
|
7466
7331
|
});
|
|
7467
7332
|
lines.push(
|
|
7468
|
-
"\
|
|
7333
|
+
"\u5DE5\u4F5C\u6B65\u9AA4\uFF08\u5FC5\u987B\u6309\u987A\u5E8F\u6267\u884C\uFF09\uFF1A",
|
|
7469
7334
|
"",
|
|
7470
|
-
"\
|
|
7335
|
+
"1. \u5148\u628A\u6BCF\u6761\u89C4\u5219\u6309 description \u5F52\u7C7B\uFF1A",
|
|
7336
|
+
' - \u53D1\u4EF6\u4EBA\u578B\uFF1A\u63CF\u8FF0\u91CC\u51FA\u73B0\u5177\u4F53\u4EBA\u540D/\u79F0\u8C13\uFF08\u542B"\u91CD\u8981\u8054\u7CFB\u4EBA X""\u8001\u5A46""\u5F20\u67D0\u67D0"\u7B49\uFF09+ "\u53D1\u6D88\u606F/\u6765\u6D88\u606F/\u56DE\u590D/\u79C1\u804A"\u7B49\u52A8\u4F5C',
|
|
7337
|
+
" - \u5173\u952E\u8BCD\u578B\uFF1A\u63CF\u8FF0\u8981\u6C42\u6D88\u606F\u4E2D\u5305\u542B\u7279\u5B9A\u5B57\u773C/\u8BDD\u9898",
|
|
7338
|
+
" - \u8BED\u4E49\u578B\uFF1A\u9700\u8981\u7406\u89E3\u6D88\u606F\u542B\u4E49\u624D\u80FD\u5224\u65AD\uFF08\u60C5\u7EEA\u3001\u610F\u56FE\u3001\u573A\u666F\u7B49\uFF09",
|
|
7339
|
+
"",
|
|
7340
|
+
"2. \u6309\u7C7B\u578B\u5224\u65AD\u6BCF\u6761\u901A\u77E5\u662F\u5426\u547D\u4E2D\uFF1A",
|
|
7341
|
+
' - \u53D1\u4EF6\u4EBA\u578B\uFF1A\u4F9D\u6B21\u6BD4\u5BF9 sender \u2192 conversation_name \u2192 title \u2192 content \u5F00\u5934\u7684 "X:"/"X\uFF1A" \u524D\u7F00\u3002',
|
|
7342
|
+
" \u6BD4\u8F83\u524D\u5148\u5F52\u4E00\u5316\uFF08NFKC\u3001\u53BB\u7A7A\u767D\u3001\u53BB emoji\u3001\u5FFD\u7565\u4E2D\u82F1\u6587\u6807\u70B9\u5DEE\u5F02\uFF09\u3002",
|
|
7343
|
+
" \u4EFB\u4E00\u5B57\u6BB5\u4E0E\u63CF\u8FF0\u4E2D\u7684\u4EBA\u540D\u4E92\u76F8\u5305\u542B\uFF08A \u662F B \u7684\u5B50\u4E32\u6216\u53CD\u4E4B\uFF09\u5373\u89C6\u4E3A\u547D\u4E2D\u3002",
|
|
7344
|
+
' \u4E0D\u8981\u6C42\u901A\u77E5\u91CC\u51FA\u73B0"\u91CD\u8981\u8054\u7CFB\u4EBA"\u7B49\u4FEE\u9970\u8BCD\uFF0C\u53EA\u8981\u540D\u5B57\u5BF9\u5F97\u4E0A\u5C31\u89E6\u53D1\u3002',
|
|
7345
|
+
" - \u5173\u952E\u8BCD\u578B\uFF1A\u5728 title + content \u4E2D\u67E5\u627E\u5173\u952E\u8BCD\uFF08\u540C\u6837\u5F52\u4E00\u5316\u540E\u6BD4\u8F83\uFF0C\u652F\u6301\u540C\u4E49/\u8FD1\u4E49\u5339\u914D\uFF09",
|
|
7346
|
+
" - \u8BED\u4E49\u578B\uFF1A\u7EFC\u5408\u7406\u89E3 title + content \u540E\u5224\u65AD\uFF1B\u8FD9\u4E00\u7C7B\u62FF\u4E0D\u51C6\u65F6\u503E\u5411\u4E8E\u4E0D\u89E6\u53D1",
|
|
7347
|
+
"",
|
|
7348
|
+
"3. \u8F93\u51FA JSON\u3002",
|
|
7349
|
+
"",
|
|
7350
|
+
"\u8F93\u51FA\u683C\u5F0F\uFF08\u7EAF JSON\uFF0C\u4E0D\u8981 Markdown \u4EE3\u7801\u5757\u3001\u4E0D\u8981\u4EFB\u4F55\u89E3\u91CA\u6587\u5B57\uFF09\uFF1A",
|
|
7471
7351
|
'{"matches":[{"i":<\u901A\u77E5\u4E0B\u6807>,"rule":"<\u89C4\u5219name>"}]}',
|
|
7472
7352
|
"",
|
|
7473
7353
|
'- \u547D\u4E2D 0 \u6761 \u2192 \u8F93\u51FA {"matches":[]}',
|
|
7474
|
-
"- \u4E00\u6761\u901A\u77E5\u53EF\
|
|
7475
|
-
|
|
7476
|
-
"
|
|
7354
|
+
"- \u4E00\u6761\u901A\u77E5\u53EF\u547D\u4E2D\u591A\u6761\u89C4\u5219 \u2192 \u6BCF\u4E2A\u7EC4\u5408\u4E00\u4E2A\u6761\u76EE",
|
|
7355
|
+
"- rule \u5FC5\u987B\u7CBE\u786E\u7B49\u4E8E\u4E0A\u9762\u5217\u51FA\u7684 name \u5B57\u7B26\u4E32",
|
|
7356
|
+
"",
|
|
7357
|
+
"\u793A\u4F8B\uFF08\u4EC5\u4F9B\u53C2\u8003\u5339\u914D\u7B56\u7565\uFF0C\u4E0D\u4EE3\u8868\u5F53\u524D\u89C4\u5219\uFF09\uFF1A",
|
|
7358
|
+
' \u89C4\u5219 description: "\u91CD\u8981\u8054\u7CFB\u4EBA \u7814\u53D1\u5C0F\u52A9\u7406 \u53D1\u6D88\u606F\u65F6\u63D0\u9192"',
|
|
7359
|
+
' \u901A\u77E5 sender="\u7814\u53D1\u5C0F\u52A9\u7406\u{1F990}" \u2192 \u547D\u4E2D\uFF08\u53BB emoji \u540E\u540D\u5B57\u76F8\u540C\uFF09',
|
|
7360
|
+
' \u901A\u77E5 sender="\u674E\u56DB", content="\u7814\u53D1\u5C0F\u52A9\u7406 \u56DE\u5E94: \u6536\u5230" \u2192 \u547D\u4E2D\uFF08content \u5934\u90E8\u524D\u7F00\u5339\u914D\uFF09',
|
|
7361
|
+
' \u901A\u77E5 sender="\u738B\u4E94", content="\u7814\u53D1\u5C0F\u52A9\u7406\u8FD9\u4E2A\u4EA7\u54C1\u633A\u597D" \u2192 \u4E0D\u547D\u4E2D\uFF08\u540D\u5B57\u51FA\u73B0\u5728\u6B63\u6587\u4F46\u4E0D\u662F\u53D1\u4EF6\u4EBA\uFF09'
|
|
7477
7362
|
);
|
|
7478
7363
|
return lines.join("\n");
|
|
7479
7364
|
}
|