wechat-clawbot 1.2.0 → 1.3.0
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/assets/icon.svg +7 -0
- package/cordis.patch.yml +4 -0
- package/lib/backlog.d.ts +14 -0
- package/lib/backlog.d.ts.map +1 -1
- package/lib/backlog.js +65 -4
- package/lib/backlog.js.map +1 -1
- package/lib/bridge.d.ts +6 -3
- package/lib/bridge.d.ts.map +1 -1
- package/lib/bridge.js +44 -11
- package/lib/bridge.js.map +1 -1
- package/lib/claude-peer.js +11 -11
- package/lib/claude-peer.js.map +1 -1
- package/lib/client.js +197 -75
- package/lib/config.d.ts +30 -7
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +17 -3
- package/lib/config.js.map +1 -1
- package/lib/idle-compact.d.ts +5 -0
- package/lib/idle-compact.d.ts.map +1 -1
- package/lib/idle-compact.js +10 -8
- package/lib/idle-compact.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +75 -28
- package/lib/index.js.map +1 -1
- package/lib/localtime.d.ts +4 -3
- package/lib/localtime.d.ts.map +1 -1
- package/lib/localtime.js +7 -6
- package/lib/localtime.js.map +1 -1
- package/lib/mac-alarms.d.ts +168 -0
- package/lib/mac-alarms.d.ts.map +1 -0
- package/lib/mac-alarms.js +610 -0
- package/lib/mac-alarms.js.map +1 -0
- package/lib/mac-calendar.d.ts +126 -11
- package/lib/mac-calendar.d.ts.map +1 -1
- package/lib/mac-calendar.js +415 -97
- package/lib/mac-calendar.js.map +1 -1
- package/lib/mcp-route.d.ts.map +1 -1
- package/lib/mcp-route.js +8 -2
- package/lib/mcp-route.js.map +1 -1
- package/lib/memory-auto.js +4 -4
- package/lib/memory-auto.js.map +1 -1
- package/lib/models-route.d.ts +1 -1
- package/lib/pending.d.ts +9 -1
- package/lib/pending.d.ts.map +1 -1
- package/lib/pending.js +18 -1
- package/lib/pending.js.map +1 -1
- package/lib/prompt.d.ts.map +1 -1
- package/lib/prompt.js +12 -11
- package/lib/prompt.js.map +1 -1
- package/lib/secretary.d.ts +42 -9
- package/lib/secretary.d.ts.map +1 -1
- package/lib/secretary.js +142 -36
- package/lib/secretary.js.map +1 -1
- package/lib/time-context.d.ts +57 -0
- package/lib/time-context.d.ts.map +1 -0
- package/lib/time-context.js +90 -0
- package/lib/time-context.js.map +1 -0
- package/lib/tool.js +1 -1
- package/lib/typing.d.ts +0 -1
- package/lib/typing.d.ts.map +1 -1
- package/lib/typing.js +7 -1
- package/lib/typing.js.map +1 -1
- package/native/macos-calendar/main.swift +476 -13
- package/package.json +3 -1
- package/wechat-clawbot-INSTALL.md +52 -32
package/lib/secretary.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
export declare const SECRETARY_HEADING = "## \
|
|
4
|
-
/**
|
|
3
|
+
export declare const SECRETARY_HEADING = "## \u5168\u5929\u5019\u79D8\u4E66";
|
|
4
|
+
/**
|
|
5
|
+
* The default rules (written with the first owner who used them). How alarms
|
|
6
|
+
* get planned each day is not in here on purpose: the owner sets that up with
|
|
7
|
+
* the bot in chat, as a daily 「任务」 reminder holding their own rules.
|
|
8
|
+
*/
|
|
5
9
|
export declare const SECRETARY_RULES: string;
|
|
10
|
+
/**
|
|
11
|
+
* Earlier defaults, word for word. A section still exactly like one of them
|
|
12
|
+
* was never edited, so it is brought up to date; an edited one is the owner's
|
|
13
|
+
* and is left alone.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EARLIER_RULES: readonly string[];
|
|
6
16
|
export declare function hasSecretaryRules(): boolean;
|
|
7
17
|
/** Put the rules at the end of memory.md: the owner's own last version if there is one. */
|
|
8
18
|
export declare function addSecretaryRules(): "added" | "present";
|
|
9
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Bring an untouched section up to the current default (EARLIER_RULES). Runs
|
|
21
|
+
* when the rules go in and at start-up while the switch is on; a section the
|
|
22
|
+
* owner edited, even by a character, stays as it is.
|
|
23
|
+
*/
|
|
24
|
+
export declare function upgradeSecretaryRules(): "upgraded" | "kept" | "absent";
|
|
25
|
+
/** Take the section out of memory.md (every copy of it), keeping it for the next time the switch goes on. */
|
|
10
26
|
export declare function removeSecretaryRules(): "removed" | "absent";
|
|
11
27
|
export declare const MEMORY_OPEN_PATH = "/plugins/clawbot/memory/open";
|
|
12
28
|
/** Opens a file with the desktop's own app. */
|
|
@@ -14,13 +30,30 @@ export type Opener = (file: string) => Promise<void>;
|
|
|
14
30
|
/** macOS: the app set for .md files, else the text editor; Linux: xdg-open; Windows: start. */
|
|
15
31
|
export declare const openOnDesktop: Opener;
|
|
16
32
|
/**
|
|
17
|
-
*
|
|
33
|
+
* Whether a request comes from this machine's DSH page: its Host names this
|
|
34
|
+
* machine (see cardRequestAllowed on DNS rebinding) and the browser does not
|
|
35
|
+
* mark it cross-site. Also for the card's GET routes, which answer without a
|
|
36
|
+
* login too.
|
|
37
|
+
*/
|
|
38
|
+
export declare function localRequest(req: IncomingMessage): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a POST is what the settings card itself sends: JSON, from the DSH
|
|
41
|
+
* page. Plugin routes are not behind DSH's login cookie; a page on another site
|
|
42
|
+
* cannot send that content type without a preflight these routes never answer,
|
|
43
|
+
* and a browser names the page a request came from in Origin.
|
|
18
44
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
45
|
+
* The Host must be this machine too. A page whose domain is rebound to
|
|
46
|
+
* 127.0.0.1 (DNS rebinding) sends a same-origin request, so its Origin matches
|
|
47
|
+
* its Host — only the Host still names the attacker's domain. DSH fences its
|
|
48
|
+
* own /api the same way, but not plugin routes. (A reverse proxy in front of
|
|
49
|
+
* DSH has to pass a loopback Host such as 127.0.0.1:3080, or these buttons
|
|
50
|
+
* refuse its requests.)
|
|
51
|
+
*/
|
|
52
|
+
export declare function cardRequestAllowed(req: IncomingMessage): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* POST /plugins/clawbot/memory/open — the settings card's "打开 memory.md". It
|
|
55
|
+
* takes only the card's own request (cardRequestAllowed), and opens a file the
|
|
56
|
+
* bot already reads every turn; nothing is sent back but its path.
|
|
24
57
|
*/
|
|
25
58
|
export declare function handleMemoryOpen(req: IncomingMessage, res: ServerResponse, opener?: Opener): Promise<void>;
|
|
26
59
|
export declare function registerMemoryOpenRoute(ctx: Context): void;
|
package/lib/secretary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretary.d.ts","sourceRoot":"","sources":["../src/secretary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"secretary.d.ts","sourceRoot":"","sources":["../src/secretary.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAMnD,eAAO,MAAM,iBAAiB,sCAAa,CAAC;AAsB5C;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAMhB,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAU1C,CAAC;AA0CF,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,SAAS,CAkBvD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,GAAG,MAAM,GAAG,QAAQ,CAkBtE;AAED,6GAA6G;AAC7G,wBAAgB,oBAAoB,IAAI,SAAS,GAAG,QAAQ,CAY3D;AAID,eAAO,MAAM,gBAAgB,iCAAiC,CAAC;AAE/D,+CAA+C;AAC/C,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErD,+FAA+F;AAC/F,eAAO,MAAM,aAAa,EAAE,MAYxB,CAAC;AAcL;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAE1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAOhE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB/H;AAUD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAQ1D"}
|
package/lib/secretary.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
2
|
+
* The rules of 全天候秘书 (the all-day secretary: the Mac calendar, alarms and
|
|
3
|
+
* these rules behind one switch), until 2026-10-21 called 日程秘书: a short set
|
|
4
|
+
* of planning rules the owner switches on in the settings card.
|
|
4
5
|
*
|
|
5
6
|
* The rules go into the long-term memory file (memory.md), not into this
|
|
6
7
|
* plugin's prompt. Like a persona they belong to one owner, and in the memory
|
|
@@ -20,20 +21,54 @@ import path from "node:path";
|
|
|
20
21
|
import { resolveStateDir } from "./ilink/storage/state-dir.js";
|
|
21
22
|
import { logger } from "./ilink/util/logger.js";
|
|
22
23
|
import { ensureMemoryFile, memoryFilePath } from "./memory.js";
|
|
23
|
-
export const SECRETARY_HEADING = "##
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export const SECRETARY_HEADING = "## 全天候秘书";
|
|
25
|
+
/**
|
|
26
|
+
* The owner may retitle it ("## 全天候秘书(我的版本)", "## 日程秘书规则",
|
|
27
|
+
* "## 全天候秘书v2"); it is still the same section. The name it had before the
|
|
28
|
+
* merge counts too, so a memory file written then is not given a second copy.
|
|
29
|
+
* Only notes named after it are the owner's own, not these rules:
|
|
30
|
+
* "## 日程秘书工作日志", "…日志", "…记录", "…笔记".
|
|
31
|
+
*/
|
|
32
|
+
const HEADING = /^##\s*(全天候秘书|日程秘书)(?!工作日志|日志|工作记录|记录|笔记)/u;
|
|
33
|
+
const PLANNING_RULES = [
|
|
29
34
|
"- 用户问接下来做什么,或补充待办、截止时间,就直接排进日历再汇报,不反问;只说了哪天、没说几点的,看那天已有的日程找空档先排上;闲聊不硬排。",
|
|
30
35
|
"- 排之前先查日历,先保住课程、会议、硬截止,不凭记忆说有空。",
|
|
31
36
|
"- 一天一条主线、最多三个关键交付,其余写明延后;用户没明确选的叫“建议主线”。",
|
|
32
37
|
"- 深度工作 60–90 分钟一块,零碎事合并,只排满 70–80%,不默认熬夜;没有外部截止就标“暂排”。",
|
|
33
38
|
"- 只说「提醒我…」、到点叫一下就行的事(吃药、出门、打电话),只设微信提醒,不进日历;要占一段时间的事(写东西、开会、约饭、出差)才排进日历,并照样设微信提醒,和日历自带的提醒重复也没关系。",
|
|
39
|
+
];
|
|
40
|
+
const CLOSING_RULES = [
|
|
34
41
|
"- 插单或进度落后时重算,直接说保留什么、挪走什么、今天能交付什么。",
|
|
35
42
|
"- 回复要短:用几行编号说清今天主要做什么、几点做什么、哪些挪到以后、哪里有冲突;用户只报了一件事的进度,就只说这件事带来的调整,不把整天安排再发一遍。",
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The default rules (written with the first owner who used them). How alarms
|
|
46
|
+
* get planned each day is not in here on purpose: the owner sets that up with
|
|
47
|
+
* the bot in chat, as a daily 「任务」 reminder holding their own rules.
|
|
48
|
+
*/
|
|
49
|
+
export const SECRETARY_RULES = [
|
|
50
|
+
SECRETARY_HEADING,
|
|
51
|
+
...PLANNING_RULES,
|
|
52
|
+
"- 要闹钟、叫醒,或某个时刻一定要响的事(赶飞机、考试),用闹钟(alarm_set:紧急提醒,到点像闹钟一样响,不靠微信)。"
|
|
53
|
+
+ "想让你每天自己排闹钟(比如每晚看第二天的行程定好),先和用户说好规则,再建一个每天定时的「任务」提醒(见定时提醒的规则),到点照规则做。",
|
|
54
|
+
...CLOSING_RULES,
|
|
36
55
|
].join("\n");
|
|
56
|
+
/**
|
|
57
|
+
* Earlier defaults, word for word. A section still exactly like one of them
|
|
58
|
+
* was never edited, so it is brought up to date; an edited one is the owner's
|
|
59
|
+
* and is left alone.
|
|
60
|
+
*/
|
|
61
|
+
export const EARLIER_RULES = [
|
|
62
|
+
// 1.2.0, 日程秘书 (before alarms).
|
|
63
|
+
["## 日程秘书", ...PLANNING_RULES, ...CLOSING_RULES].join("\n"),
|
|
64
|
+
// The first alarm version (2026-10-22, never released).
|
|
65
|
+
[
|
|
66
|
+
SECRETARY_HEADING,
|
|
67
|
+
...PLANNING_RULES,
|
|
68
|
+
"- 要闹钟、叫醒,或某个时刻一定要响的事(赶飞机、考试),用闹钟(alarm_set,会在 iPhone 上像闹钟一样响,不靠微信);用户让你每天定起床闹钟,就每晚看第二天的日历定好,再说一声定在几点。",
|
|
69
|
+
...CLOSING_RULES,
|
|
70
|
+
].join("\n"),
|
|
71
|
+
];
|
|
37
72
|
/** Where the section waits while the switch is off. */
|
|
38
73
|
function savedCopyPath() {
|
|
39
74
|
return path.join(resolveStateDir(), "secretary-rules.md");
|
|
@@ -60,19 +95,23 @@ function writeMemory(text) {
|
|
|
60
95
|
fs.writeFileSync(tmp, text, "utf-8");
|
|
61
96
|
fs.renameSync(tmp, p);
|
|
62
97
|
}
|
|
63
|
-
/**
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
71
|
-
|
|
98
|
+
/** Every such section's [start, end) line range: its heading up to the next heading. */
|
|
99
|
+
function sectionRanges(lines) {
|
|
100
|
+
const ranges = [];
|
|
101
|
+
for (let start = 0; start < lines.length; start += 1) {
|
|
102
|
+
if (!HEADING.test(lines[start].trim()))
|
|
103
|
+
continue;
|
|
104
|
+
let end = start + 1;
|
|
105
|
+
while (end < lines.length && !/^#{1,2} /.test(lines[end]))
|
|
106
|
+
end += 1;
|
|
107
|
+
ranges.push([start, end]);
|
|
108
|
+
start = end - 1;
|
|
109
|
+
}
|
|
110
|
+
return ranges;
|
|
72
111
|
}
|
|
73
112
|
export function hasSecretaryRules() {
|
|
74
113
|
try {
|
|
75
|
-
return
|
|
114
|
+
return sectionRanges(readMemory().split("\n")).length > 0;
|
|
76
115
|
}
|
|
77
116
|
catch {
|
|
78
117
|
return false;
|
|
@@ -82,8 +121,10 @@ export function hasSecretaryRules() {
|
|
|
82
121
|
export function addSecretaryRules() {
|
|
83
122
|
ensureMemoryFile();
|
|
84
123
|
const text = readMemory();
|
|
85
|
-
if (
|
|
124
|
+
if (sectionRanges(text.split("\n")).length > 0) {
|
|
125
|
+
upgradeSecretaryRules();
|
|
86
126
|
return "present";
|
|
127
|
+
}
|
|
87
128
|
let block = SECRETARY_RULES;
|
|
88
129
|
try {
|
|
89
130
|
const saved = fs.readFileSync(savedCopyPath(), "utf-8").trim();
|
|
@@ -95,18 +136,47 @@ export function addSecretaryRules() {
|
|
|
95
136
|
}
|
|
96
137
|
writeMemory(`${text.replace(/\s*$/, "")}\n\n${block}\n`);
|
|
97
138
|
logger.info("secretary: scheduling rules added to memory.md");
|
|
139
|
+
upgradeSecretaryRules();
|
|
98
140
|
return "added";
|
|
99
141
|
}
|
|
100
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Bring an untouched section up to the current default (EARLIER_RULES). Runs
|
|
144
|
+
* when the rules go in and at start-up while the switch is on; a section the
|
|
145
|
+
* owner edited, even by a character, stays as it is.
|
|
146
|
+
*/
|
|
147
|
+
export function upgradeSecretaryRules() {
|
|
148
|
+
const lines = readMemory().split("\n");
|
|
149
|
+
const ranges = sectionRanges(lines);
|
|
150
|
+
if (ranges.length === 0)
|
|
151
|
+
return "absent";
|
|
152
|
+
const earlier = new Set(EARLIER_RULES.map((rules) => rules.trim()));
|
|
153
|
+
let changed = false;
|
|
154
|
+
// From the last one back, so the earlier ranges stay where they are.
|
|
155
|
+
for (const [start, end] of [...ranges].reverse()) {
|
|
156
|
+
const section = lines.slice(start, end).join("\n").trim();
|
|
157
|
+
if (!earlier.has(section))
|
|
158
|
+
continue;
|
|
159
|
+
const trailing = lines.slice(start, end).length - section.split("\n").length;
|
|
160
|
+
lines.splice(start, end - start, ...SECRETARY_RULES.split("\n"), ...Array(trailing).fill(""));
|
|
161
|
+
changed = true;
|
|
162
|
+
}
|
|
163
|
+
if (!changed)
|
|
164
|
+
return "kept";
|
|
165
|
+
writeMemory(lines.join("\n"));
|
|
166
|
+
logger.info("secretary: rules in memory.md brought up to the current default (they were never edited)");
|
|
167
|
+
return "upgraded";
|
|
168
|
+
}
|
|
169
|
+
/** Take the section out of memory.md (every copy of it), keeping it for the next time the switch goes on. */
|
|
101
170
|
export function removeSecretaryRules() {
|
|
102
171
|
const lines = readMemory().split("\n");
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
172
|
+
const ranges = sectionRanges(lines);
|
|
173
|
+
if (ranges.length === 0)
|
|
105
174
|
return "absent";
|
|
106
|
-
const [start, end]
|
|
175
|
+
const kept = ranges.map(([start, end]) => lines.slice(start, end).join("\n").trim());
|
|
107
176
|
fs.mkdirSync(path.dirname(savedCopyPath()), { recursive: true });
|
|
108
|
-
fs.writeFileSync(savedCopyPath(), `${
|
|
109
|
-
const
|
|
177
|
+
fs.writeFileSync(savedCopyPath(), `${kept.join("\n\n")}\n`, { mode: 0o600 });
|
|
178
|
+
const inside = new Set(ranges.flatMap(([start, end]) => Array.from({ length: end - start }, (_, i) => start + i)));
|
|
179
|
+
const rest = lines.filter((_, i) => !inside.has(i)).join("\n").replace(/\n{3,}/g, "\n\n");
|
|
110
180
|
writeMemory(`${rest.replace(/\s*$/, "")}\n`);
|
|
111
181
|
logger.info("secretary: scheduling rules moved out of memory.md (kept for the next time)");
|
|
112
182
|
return "removed";
|
|
@@ -132,14 +202,54 @@ export const openOnDesktop = (file) => new Promise((resolve, reject) => {
|
|
|
132
202
|
else
|
|
133
203
|
run("xdg-open", [file]);
|
|
134
204
|
});
|
|
205
|
+
/** Whether a Host header names this machine: 127.x, localhost, [::1] — the same fence DSH keeps around /api. */
|
|
206
|
+
function loopbackHost(host) {
|
|
207
|
+
if (host === undefined)
|
|
208
|
+
return false;
|
|
209
|
+
let hostname;
|
|
210
|
+
try {
|
|
211
|
+
hostname = new URL(`http://${host}`).hostname;
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return hostname === "localhost" || hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
217
|
+
}
|
|
135
218
|
/**
|
|
136
|
-
*
|
|
219
|
+
* Whether a request comes from this machine's DSH page: its Host names this
|
|
220
|
+
* machine (see cardRequestAllowed on DNS rebinding) and the browser does not
|
|
221
|
+
* mark it cross-site. Also for the card's GET routes, which answer without a
|
|
222
|
+
* login too.
|
|
223
|
+
*/
|
|
224
|
+
export function localRequest(req) {
|
|
225
|
+
return loopbackHost(req.headers.host) && req.headers["sec-fetch-site"] !== "cross-site";
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Whether a POST is what the settings card itself sends: JSON, from the DSH
|
|
229
|
+
* page. Plugin routes are not behind DSH's login cookie; a page on another site
|
|
230
|
+
* cannot send that content type without a preflight these routes never answer,
|
|
231
|
+
* and a browser names the page a request came from in Origin.
|
|
137
232
|
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
233
|
+
* The Host must be this machine too. A page whose domain is rebound to
|
|
234
|
+
* 127.0.0.1 (DNS rebinding) sends a same-origin request, so its Origin matches
|
|
235
|
+
* its Host — only the Host still names the attacker's domain. DSH fences its
|
|
236
|
+
* own /api the same way, but not plugin routes. (A reverse proxy in front of
|
|
237
|
+
* DSH has to pass a loopback Host such as 127.0.0.1:3080, or these buttons
|
|
238
|
+
* refuse its requests.)
|
|
239
|
+
*/
|
|
240
|
+
export function cardRequestAllowed(req) {
|
|
241
|
+
const type = String(req.headers["content-type"] ?? "");
|
|
242
|
+
const origin = req.headers.origin;
|
|
243
|
+
const host = req.headers.host;
|
|
244
|
+
if (!localRequest(req))
|
|
245
|
+
return false;
|
|
246
|
+
const sameSite = origin === undefined || origin === `http://${host}` || origin === `https://${host}`;
|
|
247
|
+
return type.startsWith("application/json") && sameSite;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* POST /plugins/clawbot/memory/open — the settings card's "打开 memory.md". It
|
|
251
|
+
* takes only the card's own request (cardRequestAllowed), and opens a file the
|
|
252
|
+
* bot already reads every turn; nothing is sent back but its path.
|
|
143
253
|
*/
|
|
144
254
|
export async function handleMemoryOpen(req, res, opener = openOnDesktop) {
|
|
145
255
|
const reply = (status, body) => {
|
|
@@ -148,11 +258,7 @@ export async function handleMemoryOpen(req, res, opener = openOnDesktop) {
|
|
|
148
258
|
};
|
|
149
259
|
if ((req.method ?? "GET") !== "POST")
|
|
150
260
|
return reply(405, { ok: false, message: "use POST" });
|
|
151
|
-
|
|
152
|
-
const origin = req.headers.origin;
|
|
153
|
-
const host = req.headers.host;
|
|
154
|
-
const sameSite = origin === undefined || (host !== undefined && (origin === `http://${host}` || origin === `https://${host}`));
|
|
155
|
-
if (!type.startsWith("application/json") || !sameSite) {
|
|
261
|
+
if (!cardRequestAllowed(req)) {
|
|
156
262
|
return reply(403, { ok: false, message: "只接受设置卡片发来的请求" });
|
|
157
263
|
}
|
|
158
264
|
ensureMemoryFile();
|
package/lib/secretary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretary.js","sourceRoot":"","sources":["../src/secretary.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"secretary.js","sourceRoot":"","sources":["../src/secretary.ts"],"names":[],"mapp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AAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACnH,4BAA4B,CAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep the host's clock readings out of the WeChat session (DSH 0.2.1+).
|
|
3
|
+
*
|
|
4
|
+
* DSH 0.2.1 put `dsh-time-context` into the standard agent preset, which this
|
|
5
|
+
* plugin mounts for the WeChat agent. At most every ten minutes it appends a
|
|
6
|
+
* user-role reading: the current time, the browser time zone of the request,
|
|
7
|
+
* and the time since the last message. A WeChat message has no browser time
|
|
8
|
+
* zone, so the reading always says "Browser time zone for this request:
|
|
9
|
+
* unavailable. Ask the user to clarify otherwise-unqualified dates and times."
|
|
10
|
+
* The bot would start asking which zone "明天下午三点" means — right where it
|
|
11
|
+
* sets reminders and calendar events. The WeChat session already has its
|
|
12
|
+
* clock: every inbound message carries [微信消息 MM-DD HH:mm], and the prompt
|
|
13
|
+
* has today's date. Web sessions keep the readings.
|
|
14
|
+
*
|
|
15
|
+
* The reading is added by a `prepend` pre-step listener that the preset mounts
|
|
16
|
+
* in the agent's scope. Listeners run outermost-first and `prepend` puts a
|
|
17
|
+
* listener at the front, so the one registered last is outermost: a filter
|
|
18
|
+
* registered when this plugin starts would run inside the clock and never see
|
|
19
|
+
* the reading. This one is registered on the WeChat agent's scope after its
|
|
20
|
+
* preset is mounted (bridge.ts ensureTools), which puts it outside.
|
|
21
|
+
*/
|
|
22
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
23
|
+
/** The source kind dsh-time-context gives its readings. */
|
|
24
|
+
export declare const TIME_CONTEXT_KIND = "time-context";
|
|
25
|
+
type Decision = {
|
|
26
|
+
kind?: unknown;
|
|
27
|
+
messages?: unknown;
|
|
28
|
+
};
|
|
29
|
+
export declare function isClockReading(message: unknown): boolean;
|
|
30
|
+
/** One pre-step decision without clock readings, and how many it had. */
|
|
31
|
+
export declare function stripClockReadings(decision: Decision): {
|
|
32
|
+
decision: Decision;
|
|
33
|
+
dropped: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Register the filter on the WeChat agent's scope; call it after the agent's
|
|
37
|
+
* preset is mounted. Returns the listener's disposer (or whatever the host
|
|
38
|
+
* returns). Best effort: any surprise leaves the host's decision as it was.
|
|
39
|
+
*/
|
|
40
|
+
export declare function registerClockReadingFilter(agentCtx: Context, isWechat: (agentId: string) => boolean): unknown;
|
|
41
|
+
/**
|
|
42
|
+
* One pre-step decision with a line after each scheduled message that came on
|
|
43
|
+
* a later day than it was due (backlog.ts lateScheduleNote). In the same step,
|
|
44
|
+
* so the model has the dates before its first call; `make` builds the message.
|
|
45
|
+
*/
|
|
46
|
+
export declare function withLateScheduleNotes(decision: Decision, make: (text: string) => unknown, now?: Date): {
|
|
47
|
+
decision: Decision;
|
|
48
|
+
added: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Register the late-delivery line on the WeChat agent's scope (next to the clock
|
|
52
|
+
* filter). Returns the listener's disposer. Best effort: any surprise leaves the
|
|
53
|
+
* host's decision as it was.
|
|
54
|
+
*/
|
|
55
|
+
export declare function registerLateScheduleNotes(agentCtx: Context, isWechat: (agentId: string) => boolean, make: (text: string) => unknown): unknown;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=time-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-context.d.ts","sourceRoot":"","sources":["../src/time-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAGhD,KAAK,QAAQ,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAGvD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAExD;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAK9F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAuB7G;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EAAE,GAAG,GAAE,IAAiB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAcxJ;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAmB7I"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { lateScheduleNote } from "./backlog.js";
|
|
2
|
+
import { logger } from "./ilink/util/logger.js";
|
|
3
|
+
/** The source kind dsh-time-context gives its readings. */
|
|
4
|
+
export const TIME_CONTEXT_KIND = "time-context";
|
|
5
|
+
export function isClockReading(message) {
|
|
6
|
+
return message?.source?.kind === TIME_CONTEXT_KIND;
|
|
7
|
+
}
|
|
8
|
+
/** One pre-step decision without clock readings, and how many it had. */
|
|
9
|
+
export function stripClockReadings(decision) {
|
|
10
|
+
if (decision.kind === "reject" || !Array.isArray(decision.messages))
|
|
11
|
+
return { decision, dropped: 0 };
|
|
12
|
+
const kept = decision.messages.filter((message) => !isClockReading(message));
|
|
13
|
+
const dropped = decision.messages.length - kept.length;
|
|
14
|
+
return dropped === 0 ? { decision, dropped } : { decision: { ...decision, messages: kept }, dropped };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register the filter on the WeChat agent's scope; call it after the agent's
|
|
18
|
+
* preset is mounted. Returns the listener's disposer (or whatever the host
|
|
19
|
+
* returns). Best effort: any surprise leaves the host's decision as it was.
|
|
20
|
+
*/
|
|
21
|
+
export function registerClockReadingFilter(agentCtx, isWechat) {
|
|
22
|
+
const on = agentCtx.on;
|
|
23
|
+
let logged = false;
|
|
24
|
+
return on.call(agentCtx, "agent/pre-step", async (args, next) => {
|
|
25
|
+
const decision = await next();
|
|
26
|
+
try {
|
|
27
|
+
const id = args?.agent?.id;
|
|
28
|
+
if (typeof id !== "string" || !isWechat(id))
|
|
29
|
+
return decision;
|
|
30
|
+
const result = stripClockReadings(decision);
|
|
31
|
+
if (result.dropped > 0 && !logged) {
|
|
32
|
+
logged = true;
|
|
33
|
+
logger.info("time-context: kept the host's clock reading out of the WeChat session (no browser time zone there; messages carry their own time)");
|
|
34
|
+
}
|
|
35
|
+
return result.decision;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
logger.warn(`time-context: filter skipped: ${String(err)}`);
|
|
39
|
+
return decision;
|
|
40
|
+
}
|
|
41
|
+
}, { prepend: true });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One pre-step decision with a line after each scheduled message that came on
|
|
45
|
+
* a later day than it was due (backlog.ts lateScheduleNote). In the same step,
|
|
46
|
+
* so the model has the dates before its first call; `make` builds the message.
|
|
47
|
+
*/
|
|
48
|
+
export function withLateScheduleNotes(decision, make, now = new Date()) {
|
|
49
|
+
if (decision.kind === "reject" || !Array.isArray(decision.messages))
|
|
50
|
+
return { decision, added: 0 };
|
|
51
|
+
const out = [];
|
|
52
|
+
let added = 0;
|
|
53
|
+
for (const message of decision.messages) {
|
|
54
|
+
out.push(message);
|
|
55
|
+
if (message?.source?.kind !== "schedule" && message?.source?.plugin !== "schedule")
|
|
56
|
+
continue;
|
|
57
|
+
const text = (message.content ?? []).map((b) => (b.type === "text" ? b.text ?? "" : "")).join("\n");
|
|
58
|
+
const note = lateScheduleNote(text, now);
|
|
59
|
+
if (note === undefined)
|
|
60
|
+
continue;
|
|
61
|
+
out.push(make(note));
|
|
62
|
+
added += 1;
|
|
63
|
+
}
|
|
64
|
+
return added === 0 ? { decision, added } : { decision: { ...decision, messages: out }, added };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Register the late-delivery line on the WeChat agent's scope (next to the clock
|
|
68
|
+
* filter). Returns the listener's disposer. Best effort: any surprise leaves the
|
|
69
|
+
* host's decision as it was.
|
|
70
|
+
*/
|
|
71
|
+
export function registerLateScheduleNotes(agentCtx, isWechat, make) {
|
|
72
|
+
const on = agentCtx.on;
|
|
73
|
+
return on.call(agentCtx, "agent/pre-step", async (args, next) => {
|
|
74
|
+
const decision = await next();
|
|
75
|
+
try {
|
|
76
|
+
const id = args?.agent?.id;
|
|
77
|
+
if (typeof id !== "string" || !isWechat(id))
|
|
78
|
+
return decision;
|
|
79
|
+
const result = withLateScheduleNotes(decision, make);
|
|
80
|
+
if (result.added > 0)
|
|
81
|
+
logger.info("schedule: a scheduled message came on a later day than it was due; told the bot which day it meant");
|
|
82
|
+
return result.decision;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
logger.warn(`schedule: late-delivery line skipped: ${String(err)}`);
|
|
86
|
+
return decision;
|
|
87
|
+
}
|
|
88
|
+
}, { prepend: true });
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=time-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-context.js","sourceRoot":"","sources":["../src/time-context.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,g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I,MAAM,CAAC,KAAK,GAAG,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,oGAAoG,CAAC,CAAC;YACxI,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,yCAAyC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpE,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACxB,CAAC"}
|
package/lib/tool.js
CHANGED
|
@@ -442,7 +442,7 @@ function registerMemoryTool(agentCtx) {
|
|
|
442
442
|
name: "remember_user_info",
|
|
443
443
|
description: "Append one durable fact about the user into long-term memory (a Markdown file). " +
|
|
444
444
|
"Use this when the user tells you something worth remembering ACROSS conversations: " +
|
|
445
|
-
"personal background, preferences, habits, recurring needs (\"
|
|
445
|
+
"personal background, preferences, habits, recurring needs (\"每周三下午例会\"). " +
|
|
446
446
|
"Test: will this still be true in a month? If not, do not store it. " +
|
|
447
447
|
"Do NOT use it for one-off reminders or anything tied to a specific time (今天/明天/几点/几分钟后) — " +
|
|
448
448
|
"use schedule_create for those; a stored reminder is wrong the next day and misleads your date math. " +
|
package/lib/typing.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ type TypingAccount = {
|
|
|
22
22
|
};
|
|
23
23
|
export type TypingDeps = {
|
|
24
24
|
getAccount: () => TypingAccount | null | undefined;
|
|
25
|
-
getContextToken: (sender: string) => string;
|
|
26
25
|
/**
|
|
27
26
|
* True while the bot is waiting for this sender to answer (an approval or a
|
|
28
27
|
* question). The bot is not typing then — the user is — so the indicator
|
package/lib/typing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typing.d.ts","sourceRoot":"","sources":["../src/typing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EA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/D,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAK;IACrB,qEAAqE;IACrE,OAAO,CAAC,IAAI,CAAS;IACrB,iFAAiF;IACjF,OAAO,CAAC,KAAK,CAAS;IACtB,kGAAkG;IAClG,OAAO,CAAC,UAAU,CAAK;gBAEX,IAAI,EAAE,UAAU;IAO5B;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAY3B;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAWnC;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMjC,IAAI,IAAI,IAAI;IASZ,OAAO,IAAI,IAAI;IAIf,wEAAwE;IACxE,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,QAAQ;YAOF,IAAI;YAeJ,IAAI;IA2BlB,+DAA+D;YACjD,IAAI;YA0BJ,SAAS;CA+BxB"}
|
package/lib/typing.js
CHANGED
|
@@ -204,14 +204,20 @@ export class TypingIndicator {
|
|
|
204
204
|
if (cached !== undefined && now < cached.nextFetchAt)
|
|
205
205
|
return cached.ticket || undefined;
|
|
206
206
|
try {
|
|
207
|
+
// No context token: since some time after 2026-10-10, getconfig answers
|
|
208
|
+
// `ret=-1 invalid request` (and no ticket) when the message's context
|
|
209
|
+
// token rides along, so typing had silently stopped showing.
|
|
207
210
|
const resp = await this.api.getConfig({
|
|
208
211
|
baseUrl: account.baseUrl,
|
|
209
212
|
token: account.token,
|
|
210
213
|
ilinkUserId: sender,
|
|
211
|
-
contextToken: this.deps.getContextToken(sender) || undefined,
|
|
212
214
|
timeoutMs: 5_000,
|
|
213
215
|
});
|
|
214
216
|
const ticket = resp.ret === undefined || resp.ret === 0 ? resp.typing_ticket ?? "" : "";
|
|
217
|
+
if (!ticket) {
|
|
218
|
+
// Was silent before: typing just never showed. Once per retry window at most.
|
|
219
|
+
logger.info(`typing: no typing ticket from getconfig (ret=${String(resp.ret)} ${String(resp.errmsg ?? "")}); typing stays off for now`);
|
|
220
|
+
}
|
|
215
221
|
// Spread refreshes over the day, like the official channel does.
|
|
216
222
|
this.tickets.set(sender, {
|
|
217
223
|
ticket,
|
package/lib/typing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typing.js","sourceRoot":"","sources":["../src/typing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"typing.js","sourceRoot":"","sources":["../src/typing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAmBhD,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1C,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,4FAA4F;AAC5F,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,MAAM,OAAO,eAAe;IACT,IAAI,CAAa;IACjB,WAAW,CAAS;IACpB,OAAO,CAAS;IAChB,GAAG,CAAiE;IACpE,OAAO,GAAG,IAAI,GAAG,EAAmD,CAAC;IACtF,mDAAmD;IAC3C,MAAM,CAAqB;IAC3B,KAAK,CAA4C;IACzD,+DAA+D;IACvD,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