engine7 7.1.132 → 7.1.136
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/README.md +1 -0
- package/dist/auth-server.mjs +632 -0
- package/dist/bg-worker.mjs +32198 -28733
- package/dist/cc-desktop.mjs +951 -0
- package/dist/cli.mjs +41391 -29912
- package/dist/engine-startup.mjs +68176 -54684
- package/dist/main.mjs +54090 -40596
- package/dist/recall-worker.mjs +20443 -0
- package/dist/sqlite-maintenance-worker.mjs +1163 -124
- package/dist/stop-history-worker.mjs +180 -0
- package/dist/topics-worker.mjs +3350 -1078
- package/dist/travel-authority.mjs +1068 -0
- package/dist/travel-console.mjs +2205 -0
- package/dist/travel-controller.mjs +1883 -0
- package/dist/travel-data.mjs +7250 -0
- package/dist/travel-gateway.mjs +3258 -0
- package/dist/travel-key-service.mjs +483 -0
- package/dist/travel-node-data.mjs +4930 -0
- package/dist/travel-node.mjs +21233 -0
- package/dist/travel-retire.mjs +1094 -0
- package/dist/web-console.mjs +2425 -0
- package/package.json +32 -17
- package/templates/config.template.json +45 -0
- package/templates/skills/auth-connect/SKILL.md +22 -0
- package/templates/skills/email/SKILL.md +119 -115
- package/templates/skills/email/scripts/email-config-path.test.js +52 -0
- package/templates/skills/email/scripts/email-config.d.ts +4 -0
- package/templates/skills/email/scripts/email-config.js +6 -3
- package/templates/skills/pptx/SKILL.md +5 -0
- package/templates/skills/pptx/assets/engine7-aurora/field.png +0 -0
- package/templates/skills/pptx/assets/engine7-aurora/hero.png +0 -0
- package/templates/skills/pptx/assets/engine7-aurora/wordmark.png +0 -0
- package/templates/skills/pptx/examples/engine7-aurora.cjs +190 -0
- package/templates/skills/pptx/package-lock.json +171 -0
- package/templates/skills/pptx/package.json +12 -0
- package/templates/skills/pptx/scripts/engine7-aurora.cjs +132 -0
- package/templates/skills/pptx/styles/engine7-aurora.md +136 -0
- package/templates/skills/pptx/tests/engine7-aurora.test.cjs +116 -0
- package/templates/workspace/AGENTS.md +2 -9
- package/templates/workspace/RULES.md +22 -0
- package/templates/workspace/hooks/loop-detector.mjs +37 -0
- package/templates/workspace/souls/unnamed.md +10 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
const require=(await import('node:module')).createRequire(import.meta.url)
|
|
2
|
+
|
|
3
|
+
// src/nudge/stop-history-worker.ts
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { parentPort } from "node:worker_threads";
|
|
6
|
+
|
|
7
|
+
// src/time/wall-parts.ts
|
|
8
|
+
var EN_WEEKDAY = {
|
|
9
|
+
Sun: 0,
|
|
10
|
+
Mon: 1,
|
|
11
|
+
Tue: 2,
|
|
12
|
+
Wed: 3,
|
|
13
|
+
Thu: 4,
|
|
14
|
+
Fri: 5,
|
|
15
|
+
Sat: 6
|
|
16
|
+
};
|
|
17
|
+
var fmtCache = /* @__PURE__ */ new Map();
|
|
18
|
+
function partsFmt(zone) {
|
|
19
|
+
let f = fmtCache.get(zone);
|
|
20
|
+
if (!f) {
|
|
21
|
+
f = new Intl.DateTimeFormat("en-US", {
|
|
22
|
+
timeZone: zone,
|
|
23
|
+
year: "numeric",
|
|
24
|
+
month: "2-digit",
|
|
25
|
+
day: "2-digit",
|
|
26
|
+
hour: "2-digit",
|
|
27
|
+
minute: "2-digit",
|
|
28
|
+
second: "2-digit",
|
|
29
|
+
hourCycle: "h23",
|
|
30
|
+
weekday: "short"
|
|
31
|
+
});
|
|
32
|
+
fmtCache.set(zone, f);
|
|
33
|
+
}
|
|
34
|
+
return f;
|
|
35
|
+
}
|
|
36
|
+
function wallPartsInZone(i, zone) {
|
|
37
|
+
const d = i instanceof Date ? i : new Date(i);
|
|
38
|
+
const parts = partsFmt(zone).formatToParts(d);
|
|
39
|
+
const get = (t) => parts.find((p) => p.type === t)?.value ?? "";
|
|
40
|
+
return {
|
|
41
|
+
y: Number(get("year")),
|
|
42
|
+
mo: Number(get("month")),
|
|
43
|
+
d: Number(get("day")),
|
|
44
|
+
hh: Number(get("hour")),
|
|
45
|
+
mm: Number(get("minute")),
|
|
46
|
+
ss: Number(get("second")),
|
|
47
|
+
weekday: EN_WEEKDAY[get("weekday")] ?? 0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/session/history-selector.ts
|
|
52
|
+
var INJECTED_CONTENT_PATTERNS = [
|
|
53
|
+
/【定时心跳】/,
|
|
54
|
+
/\[内心对话测试\]/,
|
|
55
|
+
/\[inner-voice\]/,
|
|
56
|
+
/\[微信巡检\]/,
|
|
57
|
+
/\[plugin\]/,
|
|
58
|
+
/<nudge-notification>/,
|
|
59
|
+
/<task-notification>/,
|
|
60
|
+
/<calendar-notification>/,
|
|
61
|
+
/## Actions \(\d+\s*个\)/,
|
|
62
|
+
// proactive sweep 注入(block[0] 固定格式,sweep.ts 拼的)
|
|
63
|
+
/\[系统通知\]/,
|
|
64
|
+
// 群聊敏感词拦截回执(group.sensitiveWords),role:user 注入但非真实用户
|
|
65
|
+
/\[onboarding\]/,
|
|
66
|
+
// 1029 装机欢迎/tips 的补记(onboarding/plugin.ts recordInHistory),role:user 注入但非真实用户
|
|
67
|
+
/^<relationship-notification>/
|
|
68
|
+
];
|
|
69
|
+
function parseJsonlEntries(lines) {
|
|
70
|
+
const entries = [];
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
const trimmed = line.trim();
|
|
73
|
+
if (!trimmed) continue;
|
|
74
|
+
try {
|
|
75
|
+
entries.push(JSON.parse(trimmed));
|
|
76
|
+
} catch {
|
|
77
|
+
entries.push(null);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return entries;
|
|
81
|
+
}
|
|
82
|
+
function isRuntimeContextInjected(entry, nextEntry) {
|
|
83
|
+
if (!nextEntry || typeof nextEntry !== "object") return false;
|
|
84
|
+
if (nextEntry.type !== "custom_message") return false;
|
|
85
|
+
if (nextEntry.customType !== "openclaw.runtime-context") return false;
|
|
86
|
+
const content = nextEntry.content;
|
|
87
|
+
if (typeof content !== "string") return false;
|
|
88
|
+
const labels = content.match(/"label"\s*:\s*"([^"]+)"/g) || [];
|
|
89
|
+
for (const l of labels) {
|
|
90
|
+
if (l.includes("gateway-client")) return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
function isSystemSender(text) {
|
|
95
|
+
const body = text.replace(/<system-reminder>.*?<\/system-reminder>/gs, "").trimStart();
|
|
96
|
+
return INJECTED_CONTENT_PATTERNS.some((p) => p.test(text) || p.test(body));
|
|
97
|
+
}
|
|
98
|
+
function cleanText(rawText) {
|
|
99
|
+
let clean = rawText.replace(/<system-reminder>.*?<\/system-reminder>/gs, "").replace(/^\s*\[meta:[^\]\n]*\]\s*/, "").replace(/(?:Sender|Conversation info|Replied message) \(untrusted[^)]*\):\s*```json\s*\{[^}]*\}\s*```/g, "").replace(/\[\w{3} \d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})? GMT[+-]\d+\]/g, "").replace(/\[message_id:\s*\S+\]/g, "").replace(/\[\[reply_to_current\]\]/g, "").replace(/\[\[reply_to:\S+\]\]/g, "").replace(/<@\d+>/g, "").replace(/^System:.*$/gm, "").replace(/Reply target.*?```json\s*\{[^}]*\}\s*```/gs, "").replace(/\[media attached:.*?\]/g, "[\u56FE\u7247]");
|
|
100
|
+
return clean.trim();
|
|
101
|
+
}
|
|
102
|
+
function extractText(content) {
|
|
103
|
+
if (typeof content === "string") return content;
|
|
104
|
+
if (Array.isArray(content)) return content.filter((b) => b.type === "text").map((b) => b.text || "").join("\n");
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
function selectRecentMessages(entries, nowMs, hours, limit, zone) {
|
|
108
|
+
const cutoffMs = nowMs - hours * 36e5;
|
|
109
|
+
const results = [];
|
|
110
|
+
for (let i = 0; i < entries.length; i++) {
|
|
111
|
+
const entry = entries[i];
|
|
112
|
+
if (!entry || typeof entry !== "object") continue;
|
|
113
|
+
if (entry.type !== "message") continue;
|
|
114
|
+
const msg = entry.message;
|
|
115
|
+
if (!msg) continue;
|
|
116
|
+
const role = msg.role;
|
|
117
|
+
if (role !== "user" && role !== "assistant") continue;
|
|
118
|
+
const text = extractText(msg.content);
|
|
119
|
+
if (role === "user") {
|
|
120
|
+
if (isSystemSender(text)) continue;
|
|
121
|
+
const nextEntry = i + 1 < entries.length ? entries[i + 1] : null;
|
|
122
|
+
if (isRuntimeContextInjected(entry, nextEntry)) continue;
|
|
123
|
+
}
|
|
124
|
+
if (role === "assistant") {
|
|
125
|
+
if (text.startsWith("HEARTBEAT_OK")) continue;
|
|
126
|
+
let isInjectedResponse = false;
|
|
127
|
+
for (let j = i - 1; j >= Math.max(i - 5, -1); j--) {
|
|
128
|
+
const prevE = entries[j];
|
|
129
|
+
if (!prevE || typeof prevE !== "object" || prevE.type !== "message") continue;
|
|
130
|
+
const prevMsg = prevE.message;
|
|
131
|
+
if (!prevMsg || prevMsg.role !== "user") continue;
|
|
132
|
+
const prevText = extractText(prevMsg.content);
|
|
133
|
+
if (isSystemSender(prevText)) isInjectedResponse = true;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (isInjectedResponse) continue;
|
|
137
|
+
}
|
|
138
|
+
const ts = entry.timestamp || "";
|
|
139
|
+
const dtMs = new Date(ts).getTime();
|
|
140
|
+
if (Number.isNaN(dtMs)) continue;
|
|
141
|
+
if (dtMs < cutoffMs) continue;
|
|
142
|
+
if (/^HEARTBEAT_OK\b/.test(text.trim())) continue;
|
|
143
|
+
const clean = cleanText(text);
|
|
144
|
+
if (!clean) continue;
|
|
145
|
+
const bj = wallPartsInZone(dtMs, zone);
|
|
146
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
147
|
+
results.push({
|
|
148
|
+
time: `${p(bj.hh)}:${p(bj.mm)}`,
|
|
149
|
+
role,
|
|
150
|
+
text: clean.slice(0, 80),
|
|
151
|
+
timestamp: dtMs,
|
|
152
|
+
_utc: dtMs
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
results.sort((a, b) => a._utc - b._utc);
|
|
156
|
+
return results.slice(-limit);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/nudge/stop-history-worker.ts
|
|
160
|
+
if (!parentPort) throw new Error("Stop history entry requires a worker thread");
|
|
161
|
+
parentPort.on("message", ({ id, fd, size, mtimeMs, nowMs, zone, hours, limit }) => {
|
|
162
|
+
try {
|
|
163
|
+
const before = fs.fstatSync(fd);
|
|
164
|
+
if (before.size < size || before.size === size && before.mtimeMs !== mtimeMs) throw new Error("Stop history snapshot changed or truncated");
|
|
165
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
166
|
+
let offset = 0;
|
|
167
|
+
while (offset < size) {
|
|
168
|
+
const read = fs.readSync(fd, bytes, offset, Math.min(64 * 1024, size - offset), offset);
|
|
169
|
+
if (!read) throw new Error("Stop history snapshot truncated while reading");
|
|
170
|
+
offset += read;
|
|
171
|
+
}
|
|
172
|
+
const after = fs.fstatSync(fd);
|
|
173
|
+
if (after.size < size || after.size === size && after.mtimeMs !== mtimeMs) throw new Error("Stop history snapshot changed or truncated");
|
|
174
|
+
const entries = parseJsonlEntries(bytes.toString("utf8").split("\n"));
|
|
175
|
+
const result = selectRecentMessages(entries, nowMs, hours, limit, zone);
|
|
176
|
+
parentPort.postMessage({ id, result });
|
|
177
|
+
} catch (error) {
|
|
178
|
+
parentPort.postMessage({ id, error: error?.message ?? String(error) });
|
|
179
|
+
}
|
|
180
|
+
});
|