wechat-clawbot 1.2.0 → 1.3.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.
Files changed (73) hide show
  1. package/README.md +26 -13
  2. package/README.zh.md +26 -13
  3. package/assets/icon.svg +7 -0
  4. package/cordis.patch.yml +4 -0
  5. package/lib/backlog.d.ts +14 -0
  6. package/lib/backlog.d.ts.map +1 -1
  7. package/lib/backlog.js +65 -4
  8. package/lib/backlog.js.map +1 -1
  9. package/lib/bridge.d.ts +6 -3
  10. package/lib/bridge.d.ts.map +1 -1
  11. package/lib/bridge.js +44 -11
  12. package/lib/bridge.js.map +1 -1
  13. package/lib/claude-peer.js +11 -11
  14. package/lib/claude-peer.js.map +1 -1
  15. package/lib/client.js +461 -85
  16. package/lib/codex-rpc.js +1 -1
  17. package/lib/config.d.ts +30 -7
  18. package/lib/config.d.ts.map +1 -1
  19. package/lib/config.js +17 -3
  20. package/lib/config.js.map +1 -1
  21. package/lib/idle-compact.d.ts +5 -0
  22. package/lib/idle-compact.d.ts.map +1 -1
  23. package/lib/idle-compact.js +10 -8
  24. package/lib/idle-compact.js.map +1 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js +78 -28
  27. package/lib/index.js.map +1 -1
  28. package/lib/localtime.d.ts +4 -3
  29. package/lib/localtime.d.ts.map +1 -1
  30. package/lib/localtime.js +7 -6
  31. package/lib/localtime.js.map +1 -1
  32. package/lib/mac-alarms.d.ts +168 -0
  33. package/lib/mac-alarms.d.ts.map +1 -0
  34. package/lib/mac-alarms.js +612 -0
  35. package/lib/mac-alarms.js.map +1 -0
  36. package/lib/mac-calendar.d.ts +126 -11
  37. package/lib/mac-calendar.d.ts.map +1 -1
  38. package/lib/mac-calendar.js +418 -99
  39. package/lib/mac-calendar.js.map +1 -1
  40. package/lib/mcp-route.d.ts.map +1 -1
  41. package/lib/mcp-route.js +8 -2
  42. package/lib/mcp-route.js.map +1 -1
  43. package/lib/mcp-server.js +1 -1
  44. package/lib/memory-auto.js +4 -4
  45. package/lib/memory-auto.js.map +1 -1
  46. package/lib/models-route.d.ts +1 -1
  47. package/lib/pending.d.ts +9 -1
  48. package/lib/pending.d.ts.map +1 -1
  49. package/lib/pending.js +18 -1
  50. package/lib/pending.js.map +1 -1
  51. package/lib/permissions.d.ts +164 -0
  52. package/lib/permissions.d.ts.map +1 -0
  53. package/lib/permissions.js +549 -0
  54. package/lib/permissions.js.map +1 -0
  55. package/lib/prompt.d.ts.map +1 -1
  56. package/lib/prompt.js +12 -11
  57. package/lib/prompt.js.map +1 -1
  58. package/lib/secretary.d.ts +42 -9
  59. package/lib/secretary.d.ts.map +1 -1
  60. package/lib/secretary.js +142 -36
  61. package/lib/secretary.js.map +1 -1
  62. package/lib/time-context.d.ts +57 -0
  63. package/lib/time-context.d.ts.map +1 -0
  64. package/lib/time-context.js +90 -0
  65. package/lib/time-context.js.map +1 -0
  66. package/lib/tool.js +1 -1
  67. package/lib/typing.d.ts +0 -1
  68. package/lib/typing.d.ts.map +1 -1
  69. package/lib/typing.js +7 -1
  70. package/lib/typing.js.map +1 -1
  71. package/native/macos-calendar/main.swift +476 -13
  72. package/package.json +7 -6
  73. package/wechat-clawbot-INSTALL.md +64 -40
@@ -0,0 +1,164 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { Context } from "@deepseek-ai/cordis";
3
+ export declare const PERMISSIONS_PATH = "/plugins/clawbot/permissions";
4
+ export declare const PERMISSIONS_SETTINGS_PATH = "/plugins/clawbot/permissions/open-settings";
5
+ export declare const PERMISSIONS_REVEAL_PATH = "/plugins/clawbot/permissions/reveal";
6
+ export type RunResult = {
7
+ code: number;
8
+ stdout: string;
9
+ stderr: string;
10
+ };
11
+ /** Runs a program with an argument list (never a shell), in DSH's environment unless given one. A program that could not start answers code -1. */
12
+ export type Runner = (cmd: string, args: string[], timeoutMs?: number, env?: NodeJS.ProcessEnv) => Promise<RunResult>;
13
+ export declare const runProgram: Runner;
14
+ /** DSH's own program, the way the system names it (symlinks resolved: Homebrew's bin/node is a link into its Cellar). */
15
+ export declare function ownProgram(): string;
16
+ export type Found = {
17
+ kind: "app";
18
+ path: string;
19
+ } | {
20
+ kind: "program";
21
+ path: string;
22
+ } | {
23
+ kind: "unknown";
24
+ reason: string;
25
+ };
26
+ /** The app a program belongs to: the OUTERMOST bundle, so an app's helpers (Code Helper.app …) count as the app. */
27
+ export declare function appBundleOf(program: string): string | undefined;
28
+ /** What the Ruby above prints: `<responsible pid>\t<its program>`. */
29
+ export declare function parseResponsible(out: string): {
30
+ pid: number;
31
+ path: string;
32
+ } | undefined;
33
+ /**
34
+ * DSH's environment without the owner's Ruby settings. A shell set up for a
35
+ * newer Ruby hands DSH options the system's Ruby 2.6 refuses to start with
36
+ * (RUBYOPT=-W:no-deprecated, --yjit) or that print ahead of the answer (-v),
37
+ * and RUBYLIB can put another fiddle in front of the system's.
38
+ */
39
+ export declare function rubyEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
40
+ /** `why` hears what went wrong when there is no answer: the reason the walk is used instead. */
41
+ export declare function askResponsible(run: Runner, self: number, why?: (reason: string) => void): Promise<{
42
+ pid: number;
43
+ path: string;
44
+ } | undefined>;
45
+ /** The system's answer as the card names it: the app whose program it is, or the program itself. */
46
+ export declare function fromResponsible(program: string): Found;
47
+ export type Proc = {
48
+ pid: number;
49
+ ppid: number;
50
+ command: string;
51
+ };
52
+ /** `ps -axo pid=,ppid=,comm=`. On macOS `comm` is argv[0] — usually the full path (spaces and all), a bare `node` when run through `#!/usr/bin/env node`. */
53
+ export declare function parseProcessTable(text: string): Map<number, Proc>;
54
+ /** PIDs launchd runs as this user's jobs (`launchctl list`): LaunchAgents, and each app LaunchServices opened. */
55
+ export declare function parseLaunchdJobs(text: string): Set<number>;
56
+ /**
57
+ * Walk up from DSH to what started it, when the system could not be asked.
58
+ * Right for the usual cases, a guess for the rest — the system's answer is
59
+ * the one to trust (askResponsible).
60
+ *
61
+ * The first app on the way up (Terminal above the shell above `dsh web`, DSH
62
+ * Desktop above its host) is taken for it; DSH's own program is not looked at
63
+ * — node run from inside some app's bundle, typed into Terminal, is still
64
+ * Terminal's. Reaching launchd without an app: a launchd job running DSH (or a
65
+ * shell that runs DSH) leaves the access with DSH's own program; anything else
66
+ * cannot be told from here (tmux, screen, SSH, a restarted DSH, a starter that
67
+ * has exited).
68
+ */
69
+ export declare function findLauncher(table: Map<number, Proc>, self: number, jobs: Set<number>, own?: string): Found;
70
+ export type Signing = "apple" | "developer" | "local" | "adhoc" | "unsigned" | "unknown";
71
+ /**
72
+ * Who signed a program, from what `codesign -dv --verbose=2` prints (on
73
+ * stderr). What matters is whether the system will know the next version as
74
+ * the same program: ad-hoc and unsigned ones are known by their exact bytes,
75
+ * so every update loses the access.
76
+ */
77
+ export declare function parseSigning(text: string): Signing;
78
+ /** "system": macOS said so; "walk": read off the process tree (see findLauncher). */
79
+ export type Via = "system" | "walk";
80
+ export type LauncherInfo =
81
+ /**
82
+ * `name`: the app's own name. `localName`: the one System Settings shows in Chinese, when it differs (终端 for
83
+ * Terminal). `file`: the bundle as Finder lists it (DSHWhale.app for 「DSH小鲸鱼」). `dsh`: the app exists to run DSH.
84
+ */
85
+ {
86
+ kind: "app";
87
+ path: string;
88
+ name: string;
89
+ localName?: string;
90
+ file: string;
91
+ bundleId?: string;
92
+ signing: Signing;
93
+ dsh: boolean;
94
+ via: Via;
95
+ }
96
+ /** `own`: it is DSH's own program (node run by launchd, or started by something that disclaims it). */
97
+ | {
98
+ kind: "program";
99
+ path: string;
100
+ name: string;
101
+ signing: Signing;
102
+ own: boolean;
103
+ via: Via;
104
+ } | {
105
+ kind: "unknown";
106
+ reason: string;
107
+ };
108
+ /**
109
+ * Folders whose files only open once the owner allows it in a dialog, the way
110
+ * the system's own folder checks go (see fullDiskProbes): Desktop, Documents,
111
+ * Downloads, iCloud Drive, the Photos library under Pictures, and other disks.
112
+ */
113
+ export declare function inGuardedFolder(file: string, home?: string): boolean;
114
+ export declare function describeLauncher(found: Found, run: Runner, via?: Via, own?: string): Promise<LauncherInfo>;
115
+ /**
116
+ * Who DSH's access is held against. Asked of the system first; read off the
117
+ * process tree when that fails. Found once per DSH process and kept on
118
+ * globalThis, so the plugin's in-place reloads keep it too: the system's
119
+ * answer cannot change while the process lives. The walk can lose its answer
120
+ * (quit and reopen the whale and DSH carries on under launchd, its starter no
121
+ * longer above it), so the plugin also asks as it starts, and asks again only
122
+ * while the answer is unknown.
123
+ */
124
+ export declare function detectLauncher(run?: Runner, self?: number): Promise<LauncherInfo>;
125
+ export type Access = "granted" | "denied" | "unknown";
126
+ /**
127
+ * Folders only Full Disk Access opens, none of which ever brings up a dialog:
128
+ * without the access they answer "Operation not permitted" and that is all.
129
+ * (Downloads, Desktop, Documents and the Photos library are the opposite —
130
+ * touching one is what puts the dialog on screen — so they are never probed.)
131
+ * The first that answers decides. The system TCC folder is there on every
132
+ * macOS with Full Disk Access (10.14 on); the rest are spares.
133
+ */
134
+ export declare function fullDiskProbes(home?: string): string[];
135
+ /** Through a new process DSH starts — the way the bot's commands reach files. */
136
+ export declare function probeFullDisk(run?: Runner, dirs?: string[]): Promise<Access>;
137
+ /** In DSH's own process — the way its file tools (read, glob, grep) reach files. EPERM is the system's refusal; EACCES is only file modes. */
138
+ export declare function probeFullDiskHere(dirs?: string[]): Access;
139
+ /** The page of System Settings with the Full Disk Access list. System Settings (macOS 13, Darwin 22) names it by its extension. */
140
+ export declare function fullDiskSettingsUrl(release?: string): string;
141
+ export type FolderGuard = "on" | "off" | "audit" | "unknown";
142
+ /**
143
+ * `(Get-MpPreference).EnableControlledFolderAccess`: 1 blocks writes into the
144
+ * protected folders, 2 only records them; 3 and 4 are about raw disk sectors,
145
+ * not folders.
146
+ */
147
+ export declare function parseFolderGuard(out: string): FolderGuard;
148
+ export declare function parseDefender(out: string): FolderGuard;
149
+ /** Asked of Windows Security at most every five minutes, one PowerShell at a time: it takes a second or two to start. */
150
+ export declare function readFolderGuard(run?: Runner, now?: number): Promise<FolderGuard>;
151
+ /** For tests: forget who started DSH and what Windows Security said. */
152
+ export declare function resetPermissionCaches(): void;
153
+ export declare function permissionStatus(run?: Runner, platform?: NodeJS.Platform): Promise<Record<string, unknown>>;
154
+ /** GET /plugins/clawbot/permissions — this machine's page only: it names programs and paths. */
155
+ export declare function handlePermissionStatus(req: IncomingMessage, res: ServerResponse, run?: Runner, platform?: NodeJS.Platform): Promise<void>;
156
+ /**
157
+ * POST …/open-settings and …/reveal — the card's buttons. They open things on
158
+ * the computer DSH runs on, for the card's own request only
159
+ * (cardRequestAllowed). What is shown in Finder is what this process found by
160
+ * itself, never a path from the request.
161
+ */
162
+ export declare function handlePermissionAction(what: "settings" | "reveal", req: IncomingMessage, res: ServerResponse, run?: Runner, platform?: NodeJS.Platform): Promise<void>;
163
+ export declare function registerPermissionRoutes(ctx: Context): void;
164
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,eAAO,MAAM,gBAAgB,iCAAiC,CAAC;AAC/D,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AACtF,eAAO,MAAM,uBAAuB,wCAAwC,CAAC;AAI7E,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,mJAAmJ;AACnJ,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,KAAK,OAAO,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