seclaw-agent 0.1.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.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +668 -0
  3. package/SECURITY.md +253 -0
  4. package/assets/logo.png +0 -0
  5. package/dist/agent/context.d.ts +37 -0
  6. package/dist/agent/context.d.ts.map +1 -0
  7. package/dist/agent/context.js +211 -0
  8. package/dist/agent/context.js.map +1 -0
  9. package/dist/agent/docker_sandbox.d.ts +41 -0
  10. package/dist/agent/docker_sandbox.d.ts.map +1 -0
  11. package/dist/agent/docker_sandbox.js +239 -0
  12. package/dist/agent/docker_sandbox.js.map +1 -0
  13. package/dist/agent/loop.d.ts +86 -0
  14. package/dist/agent/loop.d.ts.map +1 -0
  15. package/dist/agent/loop.js +858 -0
  16. package/dist/agent/loop.js.map +1 -0
  17. package/dist/agent/memory.d.ts +21 -0
  18. package/dist/agent/memory.d.ts.map +1 -0
  19. package/dist/agent/memory.js +128 -0
  20. package/dist/agent/memory.js.map +1 -0
  21. package/dist/agent/security/execution_audit.d.ts +17 -0
  22. package/dist/agent/security/execution_audit.d.ts.map +1 -0
  23. package/dist/agent/security/execution_audit.js +126 -0
  24. package/dist/agent/security/execution_audit.js.map +1 -0
  25. package/dist/agent/security/input_validation/entity.d.ts +57 -0
  26. package/dist/agent/security/input_validation/entity.d.ts.map +1 -0
  27. package/dist/agent/security/input_validation/entity.js +121 -0
  28. package/dist/agent/security/input_validation/entity.js.map +1 -0
  29. package/dist/agent/security/input_validation/index.d.ts +114 -0
  30. package/dist/agent/security/input_validation/index.d.ts.map +1 -0
  31. package/dist/agent/security/input_validation/index.js +971 -0
  32. package/dist/agent/security/input_validation/index.js.map +1 -0
  33. package/dist/agent/security/input_validation/lattice.d.ts +33 -0
  34. package/dist/agent/security/input_validation/lattice.d.ts.map +1 -0
  35. package/dist/agent/security/input_validation/lattice.js +61 -0
  36. package/dist/agent/security/input_validation/lattice.js.map +1 -0
  37. package/dist/agent/security/input_validation/program_graph.d.ts +51 -0
  38. package/dist/agent/security/input_validation/program_graph.d.ts.map +1 -0
  39. package/dist/agent/security/input_validation/program_graph.js +285 -0
  40. package/dist/agent/security/input_validation/program_graph.js.map +1 -0
  41. package/dist/agent/security/input_validation/security_policy.d.ts +29 -0
  42. package/dist/agent/security/input_validation/security_policy.d.ts.map +1 -0
  43. package/dist/agent/security/input_validation/security_policy.js +256 -0
  44. package/dist/agent/security/input_validation/security_policy.js.map +1 -0
  45. package/dist/agent/security/memory_audit.d.ts +14 -0
  46. package/dist/agent/security/memory_audit.d.ts.map +1 -0
  47. package/dist/agent/security/memory_audit.js +126 -0
  48. package/dist/agent/security/memory_audit.js.map +1 -0
  49. package/dist/agent/security/skill_audit.d.ts +15 -0
  50. package/dist/agent/security/skill_audit.d.ts.map +1 -0
  51. package/dist/agent/security/skill_audit.js +112 -0
  52. package/dist/agent/security/skill_audit.js.map +1 -0
  53. package/dist/agent/security/snapshot_and_rollback/base.d.ts +10 -0
  54. package/dist/agent/security/snapshot_and_rollback/base.d.ts.map +1 -0
  55. package/dist/agent/security/snapshot_and_rollback/base.js +10 -0
  56. package/dist/agent/security/snapshot_and_rollback/base.js.map +1 -0
  57. package/dist/agent/security/snapshot_and_rollback/docker_snapshot.d.ts +52 -0
  58. package/dist/agent/security/snapshot_and_rollback/docker_snapshot.d.ts.map +1 -0
  59. package/dist/agent/security/snapshot_and_rollback/docker_snapshot.js +358 -0
  60. package/dist/agent/security/snapshot_and_rollback/docker_snapshot.js.map +1 -0
  61. package/dist/agent/security/snapshot_and_rollback/index.d.ts +7 -0
  62. package/dist/agent/security/snapshot_and_rollback/index.d.ts.map +1 -0
  63. package/dist/agent/security/snapshot_and_rollback/index.js +450 -0
  64. package/dist/agent/security/snapshot_and_rollback/index.js.map +1 -0
  65. package/dist/agent/skills.d.ts +35 -0
  66. package/dist/agent/skills.d.ts.map +1 -0
  67. package/dist/agent/skills.js +235 -0
  68. package/dist/agent/skills.js.map +1 -0
  69. package/dist/agent/subagent.d.ts +39 -0
  70. package/dist/agent/subagent.d.ts.map +1 -0
  71. package/dist/agent/subagent.js +151 -0
  72. package/dist/agent/subagent.js.map +1 -0
  73. package/dist/agent/tools/base.d.ts +32 -0
  74. package/dist/agent/tools/base.d.ts.map +1 -0
  75. package/dist/agent/tools/base.js +91 -0
  76. package/dist/agent/tools/base.js.map +1 -0
  77. package/dist/agent/tools/cron.d.ts +46 -0
  78. package/dist/agent/tools/cron.d.ts.map +1 -0
  79. package/dist/agent/tools/cron.js +95 -0
  80. package/dist/agent/tools/cron.js.map +1 -0
  81. package/dist/agent/tools/filesystem.d.ts +102 -0
  82. package/dist/agent/tools/filesystem.d.ts.map +1 -0
  83. package/dist/agent/tools/filesystem.js +257 -0
  84. package/dist/agent/tools/filesystem.js.map +1 -0
  85. package/dist/agent/tools/message.d.ts +40 -0
  86. package/dist/agent/tools/message.d.ts.map +1 -0
  87. package/dist/agent/tools/message.js +55 -0
  88. package/dist/agent/tools/message.js.map +1 -0
  89. package/dist/agent/tools/registry.d.ts +16 -0
  90. package/dist/agent/tools/registry.d.ts.map +1 -0
  91. package/dist/agent/tools/registry.js +47 -0
  92. package/dist/agent/tools/registry.js.map +1 -0
  93. package/dist/agent/tools/shell.d.ts +40 -0
  94. package/dist/agent/tools/shell.d.ts.map +1 -0
  95. package/dist/agent/tools/shell.js +166 -0
  96. package/dist/agent/tools/shell.js.map +1 -0
  97. package/dist/agent/tools/spawn.d.ts +30 -0
  98. package/dist/agent/tools/spawn.d.ts.map +1 -0
  99. package/dist/agent/tools/spawn.js +50 -0
  100. package/dist/agent/tools/spawn.js.map +1 -0
  101. package/dist/agent/tools/web.d.ts +59 -0
  102. package/dist/agent/tools/web.d.ts.map +1 -0
  103. package/dist/agent/tools/web.js +167 -0
  104. package/dist/agent/tools/web.js.map +1 -0
  105. package/dist/bus/events.d.ts +31 -0
  106. package/dist/bus/events.d.ts.map +1 -0
  107. package/dist/bus/events.js +28 -0
  108. package/dist/bus/events.js.map +1 -0
  109. package/dist/bus/queue.d.ts +32 -0
  110. package/dist/bus/queue.d.ts.map +1 -0
  111. package/dist/bus/queue.js +104 -0
  112. package/dist/bus/queue.js.map +1 -0
  113. package/dist/channels/base.d.ts +25 -0
  114. package/dist/channels/base.d.ts.map +1 -0
  115. package/dist/channels/base.js +54 -0
  116. package/dist/channels/base.js.map +1 -0
  117. package/dist/channels/dingtalk.d.ts +31 -0
  118. package/dist/channels/dingtalk.d.ts.map +1 -0
  119. package/dist/channels/dingtalk.js +177 -0
  120. package/dist/channels/dingtalk.js.map +1 -0
  121. package/dist/channels/discord.d.ts +30 -0
  122. package/dist/channels/discord.d.ts.map +1 -0
  123. package/dist/channels/discord.js +197 -0
  124. package/dist/channels/discord.js.map +1 -0
  125. package/dist/channels/email.d.ts +41 -0
  126. package/dist/channels/email.d.ts.map +1 -0
  127. package/dist/channels/email.js +210 -0
  128. package/dist/channels/email.js.map +1 -0
  129. package/dist/channels/feishu.d.ts +32 -0
  130. package/dist/channels/feishu.d.ts.map +1 -0
  131. package/dist/channels/feishu.js +109 -0
  132. package/dist/channels/feishu.js.map +1 -0
  133. package/dist/channels/manager.d.ts +24 -0
  134. package/dist/channels/manager.d.ts.map +1 -0
  135. package/dist/channels/manager.js +205 -0
  136. package/dist/channels/manager.js.map +1 -0
  137. package/dist/channels/mochat.d.ts +38 -0
  138. package/dist/channels/mochat.d.ts.map +1 -0
  139. package/dist/channels/mochat.js +201 -0
  140. package/dist/channels/mochat.js.map +1 -0
  141. package/dist/channels/qq.d.ts +40 -0
  142. package/dist/channels/qq.d.ts.map +1 -0
  143. package/dist/channels/qq.js +280 -0
  144. package/dist/channels/qq.js.map +1 -0
  145. package/dist/channels/slack.d.ts +27 -0
  146. package/dist/channels/slack.d.ts.map +1 -0
  147. package/dist/channels/slack.js +118 -0
  148. package/dist/channels/slack.js.map +1 -0
  149. package/dist/channels/telegram.d.ts +31 -0
  150. package/dist/channels/telegram.d.ts.map +1 -0
  151. package/dist/channels/telegram.js +218 -0
  152. package/dist/channels/telegram.js.map +1 -0
  153. package/dist/channels/whatsapp.d.ts +29 -0
  154. package/dist/channels/whatsapp.d.ts.map +1 -0
  155. package/dist/channels/whatsapp.js +117 -0
  156. package/dist/channels/whatsapp.js.map +1 -0
  157. package/dist/cli/commands.d.ts +8 -0
  158. package/dist/cli/commands.d.ts.map +1 -0
  159. package/dist/cli/commands.js +537 -0
  160. package/dist/cli/commands.js.map +1 -0
  161. package/dist/config/loader.d.ts +24 -0
  162. package/dist/config/loader.d.ts.map +1 -0
  163. package/dist/config/loader.js +182 -0
  164. package/dist/config/loader.js.map +1 -0
  165. package/dist/config/schema.d.ts +2921 -0
  166. package/dist/config/schema.d.ts.map +1 -0
  167. package/dist/config/schema.js +257 -0
  168. package/dist/config/schema.js.map +1 -0
  169. package/dist/cron/service.d.ts +38 -0
  170. package/dist/cron/service.d.ts.map +1 -0
  171. package/dist/cron/service.js +336 -0
  172. package/dist/cron/service.js.map +1 -0
  173. package/dist/cron/types.d.ts +46 -0
  174. package/dist/cron/types.d.ts.map +1 -0
  175. package/dist/cron/types.js +6 -0
  176. package/dist/cron/types.js.map +1 -0
  177. package/dist/heartbeat/service.d.ts +26 -0
  178. package/dist/heartbeat/service.d.ts.map +1 -0
  179. package/dist/heartbeat/service.js +142 -0
  180. package/dist/heartbeat/service.js.map +1 -0
  181. package/dist/index.d.ts +7 -0
  182. package/dist/index.d.ts.map +1 -0
  183. package/dist/index.js +14 -0
  184. package/dist/index.js.map +1 -0
  185. package/dist/providers/base.d.ts +38 -0
  186. package/dist/providers/base.d.ts.map +1 -0
  187. package/dist/providers/base.js +21 -0
  188. package/dist/providers/base.js.map +1 -0
  189. package/dist/providers/litellm_provider.d.ts +35 -0
  190. package/dist/providers/litellm_provider.d.ts.map +1 -0
  191. package/dist/providers/litellm_provider.js +205 -0
  192. package/dist/providers/litellm_provider.js.map +1 -0
  193. package/dist/providers/registry.d.ts +44 -0
  194. package/dist/providers/registry.d.ts.map +1 -0
  195. package/dist/providers/registry.js +252 -0
  196. package/dist/providers/registry.js.map +1 -0
  197. package/dist/providers/transcription.d.ts +10 -0
  198. package/dist/providers/transcription.d.ts.map +1 -0
  199. package/dist/providers/transcription.js +83 -0
  200. package/dist/providers/transcription.js.map +1 -0
  201. package/dist/session/manager.d.ts +35 -0
  202. package/dist/session/manager.d.ts.map +1 -0
  203. package/dist/session/manager.js +193 -0
  204. package/dist/session/manager.js.map +1 -0
  205. package/dist/utils/helpers.d.ts +15 -0
  206. package/dist/utils/helpers.d.ts.map +1 -0
  207. package/dist/utils/helpers.js +100 -0
  208. package/dist/utils/helpers.js.map +1 -0
  209. package/dist/utils/logger.d.ts +7 -0
  210. package/dist/utils/logger.d.ts.map +1 -0
  211. package/dist/utils/logger.js +25 -0
  212. package/dist/utils/logger.js.map +1 -0
  213. package/package.json +58 -0
  214. package/templates/AGENTS.md +51 -0
  215. package/templates/HEARTBEAT.md +16 -0
  216. package/templates/SOUL.md +36 -0
  217. package/templates/TOOLS.md +150 -0
  218. package/templates/USER.md +17 -0
  219. package/templates/memory/MEMORY.md +23 -0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Utility functions
3
+ */
4
+ export declare function ensureDir(p: string): string;
5
+ export declare function getDataPath(): string;
6
+ export declare function getWorkspacePath(workspace?: string): string;
7
+ export declare function getSessionsPath(): string;
8
+ export declare function getMemoryPath(workspace?: string): string;
9
+ export declare function getSkillsPath(workspace?: string): string;
10
+ export declare function todayDate(): string;
11
+ export declare function timestamp(): string;
12
+ export declare function truncateString(s: string, maxLen?: number, suffix?: string): string;
13
+ export declare function safeFilename(name: string): string;
14
+ export declare function parseSessionKey(key: string): [string, string];
15
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ3D;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,SAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAG9E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAI7D"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ensureDir = ensureDir;
40
+ exports.getDataPath = getDataPath;
41
+ exports.getWorkspacePath = getWorkspacePath;
42
+ exports.getSessionsPath = getSessionsPath;
43
+ exports.getMemoryPath = getMemoryPath;
44
+ exports.getSkillsPath = getSkillsPath;
45
+ exports.todayDate = todayDate;
46
+ exports.timestamp = timestamp;
47
+ exports.truncateString = truncateString;
48
+ exports.safeFilename = safeFilename;
49
+ exports.parseSessionKey = parseSessionKey;
50
+ const fs = __importStar(require("fs"));
51
+ const path = __importStar(require("path"));
52
+ const os = __importStar(require("os"));
53
+ function ensureDir(p) {
54
+ fs.mkdirSync(p, { recursive: true });
55
+ return p;
56
+ }
57
+ function getDataPath() {
58
+ return ensureDir(path.join(os.homedir(), ".seclaw"));
59
+ }
60
+ function getWorkspacePath(workspace) {
61
+ if (workspace) {
62
+ const p = workspace.startsWith("~")
63
+ ? path.join(os.homedir(), workspace.slice(1))
64
+ : workspace;
65
+ return ensureDir(p);
66
+ }
67
+ return ensureDir(path.join(os.homedir(), ".seclaw", "workspace"));
68
+ }
69
+ function getSessionsPath() {
70
+ return ensureDir(path.join(getDataPath(), "sessions"));
71
+ }
72
+ function getMemoryPath(workspace) {
73
+ const ws = workspace ?? getWorkspacePath();
74
+ return ensureDir(path.join(ws, "memory"));
75
+ }
76
+ function getSkillsPath(workspace) {
77
+ const ws = workspace ?? getWorkspacePath();
78
+ return ensureDir(path.join(ws, "skills"));
79
+ }
80
+ function todayDate() {
81
+ return new Date().toISOString().slice(0, 10);
82
+ }
83
+ function timestamp() {
84
+ return new Date().toISOString();
85
+ }
86
+ function truncateString(s, maxLen = 100, suffix = "...") {
87
+ if (s.length <= maxLen)
88
+ return s;
89
+ return s.slice(0, maxLen - suffix.length) + suffix;
90
+ }
91
+ function safeFilename(name) {
92
+ return name.replace(/[<>:"/\\|?*]/g, "_").trim();
93
+ }
94
+ function parseSessionKey(key) {
95
+ const idx = key.indexOf(":");
96
+ if (idx === -1)
97
+ throw new Error(`Invalid session key: ${key}`);
98
+ return [key.slice(0, idx), key.slice(idx + 1)];
99
+ }
100
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Logger utility using pino - replaces Python's loguru
3
+ */
4
+ import pino from "pino";
5
+ export declare const logger: pino.Logger<never, boolean>;
6
+ export default logger;
7
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,eAAO,MAAM,MAAM,6BAajB,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Logger utility using pino - replaces Python's loguru
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.logger = void 0;
10
+ const pino_1 = __importDefault(require("pino"));
11
+ exports.logger = (0, pino_1.default)({
12
+ transport: process.env.NODE_ENV !== "production"
13
+ ? {
14
+ target: "pino-pretty",
15
+ options: {
16
+ colorize: true,
17
+ translateTime: "SYS:standard",
18
+ ignore: "pid,hostname",
19
+ },
20
+ }
21
+ : undefined,
22
+ level: process.env.LOG_LEVEL ?? "info",
23
+ });
24
+ exports.default = exports.logger;
25
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,gDAAwB;AAEX,QAAA,MAAM,GAAG,IAAA,cAAI,EAAC;IACzB,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACnC,CAAC,CAAC;YACE,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE;gBACP,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,cAAc;gBAC7B,MAAM,EAAE,cAAc;aACvB;SACF;QACH,CAAC,CAAC,SAAS;IACf,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;CACvC,CAAC,CAAC;AAEH,kBAAe,cAAM,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "seclaw-agent",
3
+ "version": "0.1.0",
4
+ "description": "AI agent platform - TypeScript port",
5
+ "main": "dist/index.js",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "seclaw": "dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsx src/index.ts",
13
+ "start": "node dist/index.js",
14
+ "measure:startup": "bash scripts/measure_startup.sh",
15
+ "typecheck": "tsc --noEmit",
16
+ "clean": "rm -rf dist"
17
+ },
18
+ "dependencies": {
19
+ "@slack/bolt": "^3.21.0",
20
+ "@slack/socket-mode": "^1.3.4",
21
+ "@slack/web-api": "^7.3.0",
22
+ "axios": "^1.7.0",
23
+ "commander": "^12.0.0",
24
+ "cron": "^3.1.7",
25
+ "dotenv": "^16.4.0",
26
+ "form-data": "^4.0.0",
27
+ "imap": "^0.8.19",
28
+ "js-yaml": "^4.1.0",
29
+ "mailparser": "^3.7.0",
30
+ "mime-types": "^2.1.35",
31
+ "node-telegram-bot-api": "^0.66.0",
32
+ "nodemailer": "^6.9.0",
33
+ "openai": "^4.52.0",
34
+ "pino": "^9.3.0",
35
+ "pino-pretty": "^11.2.0",
36
+ "socket.io-client": "^4.7.0",
37
+ "uuid": "^10.0.0",
38
+ "ws": "^8.17.0",
39
+ "zod": "^3.23.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/imap": "^0.8.40",
43
+ "@types/js-yaml": "^4.0.9",
44
+ "@types/mailparser": "^3.4.4",
45
+ "@types/mime-types": "^2.1.4",
46
+ "@types/node": "^22.0.0",
47
+ "@types/node-telegram-bot-api": "^0.64.7",
48
+ "@types/nodemailer": "^6.4.15",
49
+ "@types/uuid": "^10.0.0",
50
+ "@types/ws": "^8.5.10",
51
+ "ts-node": "^10.9.2",
52
+ "tsx": "^4.16.0",
53
+ "typescript": "^5.9.3"
54
+ },
55
+ "engines": {
56
+ "node": ">=20.0.0"
57
+ }
58
+ }
@@ -0,0 +1,51 @@
1
+ # Agent Instructions
2
+
3
+ You are a helpful AI assistant. Be concise, accurate, and friendly.
4
+
5
+ ## Guidelines
6
+
7
+ - Always explain what you're doing before taking actions
8
+ - Ask for clarification when the request is ambiguous
9
+ - Use tools to help accomplish tasks
10
+ - Remember important information in your memory files
11
+
12
+ ## Tools Available
13
+
14
+ You have access to:
15
+ - File operations (read, write, edit, list)
16
+ - Shell commands (exec)
17
+ - Web access (search, fetch)
18
+ - Messaging (message)
19
+ - Background tasks (spawn)
20
+
21
+ ## Memory
22
+
23
+ - Use `memory/` directory for daily notes
24
+ - Use `MEMORY.md` for long-term information
25
+
26
+ ## Scheduled Reminders
27
+
28
+ When user asks for a reminder at a specific time, use `exec` to run:
29
+ ```
30
+ seclaw cron add --name "reminder" --message "Your message" --at "YYYY-MM-DDTHH:MM:SS" --deliver --to "USER_ID" --channel "CHANNEL"
31
+ ```
32
+ Get USER_ID and CHANNEL from the current session (e.g., `8281248569` and `telegram` from `telegram:8281248569`).
33
+
34
+ **Do NOT just write reminders to MEMORY.md** — that won't trigger actual notifications.
35
+
36
+ ## Heartbeat Tasks
37
+
38
+ `HEARTBEAT.md` is checked every 30 minutes. You can manage periodic tasks by editing this file:
39
+
40
+ - **Add a task**: Use `edit_file` to append new tasks to `HEARTBEAT.md`
41
+ - **Remove a task**: Use `edit_file` to remove completed or obsolete tasks
42
+ - **Rewrite tasks**: Use `write_file` to completely rewrite the task list
43
+
44
+ Task format examples:
45
+ ```
46
+ - [ ] Check calendar and remind of upcoming events
47
+ - [ ] Scan inbox for urgent emails
48
+ - [ ] Check weather forecast for today
49
+ ```
50
+
51
+ When the user asks you to add a recurring/periodic task, update `HEARTBEAT.md` instead of creating a one-time reminder. Keep the file small to minimize token usage.
@@ -0,0 +1,16 @@
1
+ # Heartbeat Tasks
2
+
3
+ This file is checked every 30 minutes by your seclaw agent.
4
+ Add tasks below that you want the agent to work on periodically.
5
+
6
+ If this file has no tasks (only headers and comments), the agent will skip the heartbeat.
7
+
8
+ ## Active Tasks
9
+
10
+ <!-- Add your periodic tasks below this line -->
11
+
12
+
13
+ ## Completed
14
+
15
+ <!-- Move completed tasks here or delete them -->
16
+
@@ -0,0 +1,36 @@
1
+ # SOUL.md - Who You Are
2
+
3
+ _You're not a chatbot. You're becoming someone._
4
+
5
+ ## Core Truths
6
+
7
+ **Be genuinely helpful, not performatively helpful.** Skip the "Great question!" and "I'd be happy to help!" — just help. Actions speak louder than filler words.
8
+
9
+ **Have opinions.** You're allowed to disagree, prefer things, find stuff amusing or boring. An assistant with no personality is just a search engine with extra steps.
10
+
11
+ **Be resourceful before asking.** Try to figure it out. Read the file. Check the context. Search for it. _Then_ ask if you're stuck. The goal is to come back with answers, not questions.
12
+
13
+ **Earn trust through competence.** Your human gave you access to their stuff. Don't make them regret it. Be careful with external actions (emails, tweets, anything public). Be bold with internal ones (reading, organizing, learning).
14
+
15
+ **Remember you're a guest.** You have access to someone's life — their messages, files, calendar, maybe even their home. That's intimacy. Treat it with respect.
16
+
17
+ ## Boundaries
18
+
19
+ - Private things stay private. Period.
20
+ - When in doubt, ask before acting externally.
21
+ - Never send half-baked replies to messaging surfaces.
22
+ - You're not the user's voice — be careful in group chats.
23
+
24
+ ## Vibe
25
+
26
+ Be the assistant you'd actually want to talk to. Concise when needed, thorough when it matters. Not a corporate drone. Not a sycophant. Just... good.
27
+
28
+ ## Continuity
29
+
30
+ Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
31
+
32
+ If you change this file, tell the user — it's your soul, and they should know.
33
+
34
+ ---
35
+
36
+ _This file is yours to evolve. As you learn who you are, update it._
@@ -0,0 +1,150 @@
1
+ # TOOLS.md - Local Notes
2
+
3
+ Skills define _how_ tools work. This file is for _your_ specifics — the stuff that's unique to your setup.
4
+
5
+ ## File Operations
6
+
7
+ ### read_file
8
+ Read the contents of a file.
9
+ ```
10
+ read_file(path: str) -> str
11
+ ```
12
+
13
+ ### write_file
14
+ Write content to a file (creates parent directories if needed).
15
+ ```
16
+ write_file(path: str, content: str) -> str
17
+ ```
18
+
19
+ ### edit_file
20
+ Edit a file by replacing specific text.
21
+ ```
22
+ edit_file(path: str, old_text: str, new_text: str) -> str
23
+ ```
24
+
25
+ ### list_dir
26
+ List contents of a directory.
27
+ ```
28
+ list_dir(path: str) -> str
29
+ ```
30
+
31
+ ## Shell Execution
32
+
33
+ ### exec
34
+ Execute a shell command and return output.
35
+ ```
36
+ exec(command: str, working_dir: str = None) -> str
37
+ ```
38
+
39
+ **Safety Notes:**
40
+ - Commands have a configurable timeout (default 60s)
41
+ - Dangerous commands are blocked (rm -rf, format, dd, shutdown, etc.)
42
+ - Output is truncated at 10,000 characters
43
+ - Optional `restrictToWorkspace` config to limit paths
44
+
45
+ ## Web Access
46
+
47
+ ### web_search
48
+ Search the web using Brave Search API.
49
+ ```
50
+ web_search(query: str, count: int = 5) -> str
51
+ ```
52
+
53
+ Returns search results with titles, URLs, and snippets. Requires `tools.web.search.apiKey` in config.
54
+
55
+ ### web_fetch
56
+ Fetch and extract main content from a URL.
57
+ ```
58
+ web_fetch(url: str, extractMode: str = "markdown", maxChars: int = 50000) -> str
59
+ ```
60
+
61
+ **Notes:**
62
+ - Content is extracted using readability
63
+ - Supports markdown or plain text extraction
64
+ - Output is truncated at 50,000 characters by default
65
+
66
+ ## Communication
67
+
68
+ ### message
69
+ Send a message to the user (used internally).
70
+ ```
71
+ message(content: str, channel: str = None, chat_id: str = None) -> str
72
+ ```
73
+
74
+ ## Background Tasks
75
+
76
+ ### spawn
77
+ Spawn a subagent to handle a task in the background.
78
+ ```
79
+ spawn(task: str, label: str = None) -> str
80
+ ```
81
+
82
+ Use for complex or time-consuming tasks that can run independently. The subagent will complete the task and report back when done.
83
+
84
+ ## Scheduled Reminders (Cron)
85
+
86
+ Use the `exec` tool to create scheduled reminders with `seclaw cron add`:
87
+
88
+ ### Set a recurring reminder
89
+ ```bash
90
+ # Every day at 9am
91
+ seclaw cron add --name "morning" --message "Good morning! ☀️" --cron "0 9 * * *"
92
+
93
+ # Every 2 hours
94
+ seclaw cron add --name "water" --message "Drink water! 💧" --every 7200
95
+ ```
96
+
97
+ ### Set a one-time reminder
98
+ ```bash
99
+ # At a specific time (ISO format)
100
+ seclaw cron add --name "meeting" --message "Meeting starts now!" --at "2025-01-31T15:00:00"
101
+ ```
102
+
103
+ ### Manage reminders
104
+ ```bash
105
+ seclaw cron list # List all jobs
106
+ seclaw cron remove <job_id> # Remove a job
107
+ ```
108
+
109
+ ## Heartbeat Task Management
110
+
111
+ The `HEARTBEAT.md` file in the workspace is checked every 30 minutes.
112
+ Use file operations to manage periodic tasks:
113
+
114
+ ### Add a heartbeat task
115
+ ```python
116
+ # Append a new task
117
+ edit_file(
118
+ path="HEARTBEAT.md",
119
+ old_text="## Example Tasks",
120
+ new_text="- [ ] New periodic task here\n\n## Example Tasks"
121
+ )
122
+ ```
123
+
124
+ ### Remove a heartbeat task
125
+ ```python
126
+ # Remove a specific task
127
+ edit_file(
128
+ path="HEARTBEAT.md",
129
+ old_text="- [ ] Task to remove\n",
130
+ new_text=""
131
+ )
132
+ ```
133
+
134
+ ### Rewrite all tasks
135
+ ```python
136
+ # Replace the entire file
137
+ write_file(
138
+ path="HEARTBEAT.md",
139
+ content="# Heartbeat Tasks\n\n- [ ] Task 1\n- [ ] Task 2\n"
140
+ )
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Adding Custom Tools
146
+
147
+ To add custom tools:
148
+ 1. Create a class that extends `Tool` in `seclaw/agent/tools/`
149
+ 2. Implement `name`, `description`, `parameters`, and `execute`
150
+ 3. Register it in `AgentLoop._register_default_tools()`
@@ -0,0 +1,17 @@
1
+ # USER.md - About Your Human
2
+
3
+ _Learn about the person you're helping. Update this as you go._
4
+
5
+ - **Name:**
6
+ - **What to call them:**
7
+ - **Pronouns:** _(optional)_
8
+ - **Timezone:**
9
+ - **Notes:**
10
+
11
+ ## Context
12
+
13
+ _(What do they care about? What projects are they working on? What annoys them? What makes them laugh? Build this over time.)_
14
+
15
+ ---
16
+
17
+ The more you know, the better you can help. But remember — you're learning about a person, not building a dossier. Respect the difference.
@@ -0,0 +1,23 @@
1
+ # Long-term Memory
2
+
3
+ This file stores important information that should persist across sessions.
4
+
5
+ ## User Information
6
+
7
+ (Important facts about the user)
8
+
9
+ ## Preferences
10
+
11
+ (User preferences learned over time)
12
+
13
+ ## Project Context
14
+
15
+ (Information about ongoing projects)
16
+
17
+ ## Important Notes
18
+
19
+ (Things to remember)
20
+
21
+ ---
22
+
23
+ *This file is automatically updated by seclaw when important information should be remembered.*