@crewx/cli 0.8.0-rc.66 → 0.8.0-rc.82

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 (281) hide show
  1. package/bin/crewx +2 -0
  2. package/dist/bootstrap/crewx-cli.d.ts +11 -0
  3. package/dist/bootstrap/crewx-cli.js +31 -0
  4. package/dist/builtin.d.ts +15 -0
  5. package/dist/{cli/builtin.handler.js → builtin.js} +21 -7
  6. package/dist/commands/agent.d.ts +12 -0
  7. package/dist/commands/agent.js +246 -0
  8. package/dist/commands/doctor.d.ts +12 -0
  9. package/dist/commands/doctor.js +190 -0
  10. package/dist/commands/execute.d.ts +21 -0
  11. package/dist/commands/execute.js +117 -0
  12. package/dist/commands/hook/install.d.ts +21 -0
  13. package/dist/commands/hook/install.js +175 -0
  14. package/dist/commands/hook/paths.d.ts +19 -0
  15. package/dist/commands/hook/paths.js +94 -0
  16. package/dist/commands/hook/status.d.ts +7 -0
  17. package/dist/commands/hook/status.js +86 -0
  18. package/dist/commands/hook/uninstall.d.ts +8 -0
  19. package/dist/commands/hook/uninstall.js +71 -0
  20. package/dist/commands/hook-dispatch.d.ts +15 -0
  21. package/dist/commands/hook-dispatch.js +180 -0
  22. package/dist/commands/init.d.ts +24 -0
  23. package/dist/commands/init.js +133 -0
  24. package/dist/commands/kill.d.ts +12 -0
  25. package/dist/commands/kill.js +49 -0
  26. package/dist/commands/log.d.ts +13 -0
  27. package/dist/commands/log.js +97 -0
  28. package/dist/commands/parse-agent-message.d.ts +31 -0
  29. package/dist/commands/parse-agent-message.js +52 -0
  30. package/dist/commands/parse-common-flags.d.ts +36 -0
  31. package/dist/commands/parse-common-flags.js +105 -0
  32. package/dist/commands/ps.d.ts +12 -0
  33. package/dist/commands/ps.js +71 -0
  34. package/dist/commands/query.d.ts +21 -0
  35. package/dist/commands/query.js +117 -0
  36. package/dist/commands/result.d.ts +13 -0
  37. package/dist/commands/result.js +73 -0
  38. package/dist/commands/slack.d.ts +12 -0
  39. package/dist/commands/slack.js +559 -0
  40. package/dist/commands/task-db.d.ts +33 -0
  41. package/dist/commands/task-db.js +107 -0
  42. package/dist/examples/deny-secrets-plugin.d.ts +22 -0
  43. package/dist/examples/deny-secrets-plugin.js +40 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +5 -0
  46. package/dist/logging.d.ts +21 -0
  47. package/dist/logging.js +86 -0
  48. package/dist/main.d.ts +10 -0
  49. package/dist/main.js +246 -256
  50. package/dist/plugins/examples/echo-hook.d.ts +24 -0
  51. package/dist/plugins/examples/echo-hook.js +60 -0
  52. package/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
  53. package/dist/plugins/examples/verify-echo-hook.js +47 -0
  54. package/dist/plugins/sqlite-tracing.d.ts +13 -0
  55. package/dist/plugins/sqlite-tracing.js +20 -0
  56. package/dist/register-builtin-tools.d.ts +5 -0
  57. package/dist/register-builtin-tools.js +9 -0
  58. package/dist/slack/file-download.d.ts +17 -0
  59. package/dist/slack/file-download.js +134 -0
  60. package/dist/slack/markdown.d.ts +5 -0
  61. package/dist/slack/markdown.js +33 -0
  62. package/dist/utils/env-defaults.d.ts +5 -0
  63. package/dist/utils/env-defaults.js +10 -0
  64. package/dist/utils/version.d.ts +1 -0
  65. package/dist/utils/version.js +28 -0
  66. package/package.json +32 -115
  67. package/README.md +0 -663
  68. package/dist/ai-provider.service.d.ts +0 -36
  69. package/dist/ai-provider.service.js +0 -315
  70. package/dist/ai-provider.service.js.map +0 -1
  71. package/dist/ai.service.d.ts +0 -17
  72. package/dist/ai.service.js +0 -51
  73. package/dist/ai.service.js.map +0 -1
  74. package/dist/app.module.d.ts +0 -5
  75. package/dist/app.module.js +0 -165
  76. package/dist/app.module.js.map +0 -1
  77. package/dist/cli/agent.handler.d.ts +0 -2
  78. package/dist/cli/agent.handler.js +0 -186
  79. package/dist/cli/agent.handler.js.map +0 -1
  80. package/dist/cli/builtin.handler.d.ts +0 -3
  81. package/dist/cli/builtin.handler.js.map +0 -1
  82. package/dist/cli/chat.handler.d.ts +0 -20
  83. package/dist/cli/chat.handler.js +0 -446
  84. package/dist/cli/chat.handler.js.map +0 -1
  85. package/dist/cli/cli.handler.d.ts +0 -4
  86. package/dist/cli/cli.handler.js +0 -119
  87. package/dist/cli/cli.handler.js.map +0 -1
  88. package/dist/cli/doctor.handler.d.ts +0 -38
  89. package/dist/cli/doctor.handler.js +0 -495
  90. package/dist/cli/doctor.handler.js.map +0 -1
  91. package/dist/cli/execute.handler.d.ts +0 -2
  92. package/dist/cli/execute.handler.js +0 -376
  93. package/dist/cli/execute.handler.js.map +0 -1
  94. package/dist/cli/help.handler.d.ts +0 -2
  95. package/dist/cli/help.handler.js +0 -10
  96. package/dist/cli/help.handler.js.map +0 -1
  97. package/dist/cli/init.handler.d.ts +0 -26
  98. package/dist/cli/init.handler.js +0 -450
  99. package/dist/cli/init.handler.js.map +0 -1
  100. package/dist/cli/log.handler.d.ts +0 -2
  101. package/dist/cli/log.handler.js +0 -69
  102. package/dist/cli/log.handler.js.map +0 -1
  103. package/dist/cli/mcp.handler.d.ts +0 -3
  104. package/dist/cli/mcp.handler.js +0 -121
  105. package/dist/cli/mcp.handler.js.map +0 -1
  106. package/dist/cli/query.handler.d.ts +0 -2
  107. package/dist/cli/query.handler.js +0 -392
  108. package/dist/cli/query.handler.js.map +0 -1
  109. package/dist/cli/skill.handler.d.ts +0 -2
  110. package/dist/cli/skill.handler.js +0 -252
  111. package/dist/cli/skill.handler.js.map +0 -1
  112. package/dist/cli/slack-files.handler.d.ts +0 -2
  113. package/dist/cli/slack-files.handler.js +0 -291
  114. package/dist/cli/slack-files.handler.js.map +0 -1
  115. package/dist/cli/template.handler.d.ts +0 -2
  116. package/dist/cli/template.handler.js +0 -188
  117. package/dist/cli/template.handler.js.map +0 -1
  118. package/dist/cli/templates.handler.d.ts +0 -2
  119. package/dist/cli/templates.handler.js +0 -100
  120. package/dist/cli/templates.handler.js.map +0 -1
  121. package/dist/cli-options.d.ts +0 -40
  122. package/dist/cli-options.js +0 -371
  123. package/dist/cli-options.js.map +0 -1
  124. package/dist/config/timeout.config.d.ts +0 -14
  125. package/dist/config/timeout.config.js +0 -34
  126. package/dist/config/timeout.config.js.map +0 -1
  127. package/dist/conversation/base-conversation-history.provider.d.ts +0 -12
  128. package/dist/conversation/base-conversation-history.provider.js +0 -45
  129. package/dist/conversation/base-conversation-history.provider.js.map +0 -1
  130. package/dist/conversation/cli-box-reader.adapter.d.ts +0 -6
  131. package/dist/conversation/cli-box-reader.adapter.js +0 -10
  132. package/dist/conversation/cli-box-reader.adapter.js.map +0 -1
  133. package/dist/conversation/cli-conversation-history.provider.d.ts +0 -16
  134. package/dist/conversation/cli-conversation-history.provider.js +0 -112
  135. package/dist/conversation/cli-conversation-history.provider.js.map +0 -1
  136. package/dist/conversation/cli-task-reader.adapter.d.ts +0 -6
  137. package/dist/conversation/cli-task-reader.adapter.js +0 -25
  138. package/dist/conversation/cli-task-reader.adapter.js.map +0 -1
  139. package/dist/conversation/conversation-provider.factory.d.ts +0 -10
  140. package/dist/conversation/conversation-provider.factory.js +0 -50
  141. package/dist/conversation/conversation-provider.factory.js.map +0 -1
  142. package/dist/conversation/index.d.ts +0 -8
  143. package/dist/conversation/index.js +0 -29
  144. package/dist/conversation/index.js.map +0 -1
  145. package/dist/conversation/slack-conversation-history.provider.d.ts +0 -29
  146. package/dist/conversation/slack-conversation-history.provider.js +0 -302
  147. package/dist/conversation/slack-conversation-history.provider.js.map +0 -1
  148. package/dist/crewx.tool.d.ts +0 -360
  149. package/dist/crewx.tool.js +0 -2531
  150. package/dist/crewx.tool.js.map +0 -1
  151. package/dist/crewx.tool.spec.d.ts +0 -1
  152. package/dist/crewx.tool.spec.js +0 -222
  153. package/dist/crewx.tool.spec.js.map +0 -1
  154. package/dist/guards/bearer-auth.guard.d.ts +0 -7
  155. package/dist/guards/bearer-auth.guard.js +0 -44
  156. package/dist/guards/bearer-auth.guard.js.map +0 -1
  157. package/dist/health.controller.d.ts +0 -6
  158. package/dist/health.controller.js +0 -32
  159. package/dist/health.controller.js.map +0 -1
  160. package/dist/main.js.map +0 -1
  161. package/dist/mcp.controller.d.ts +0 -8
  162. package/dist/mcp.controller.js +0 -62
  163. package/dist/mcp.controller.js.map +0 -1
  164. package/dist/package.json +0 -3
  165. package/dist/providers/dynamic-provider.factory.d.ts +0 -17
  166. package/dist/providers/dynamic-provider.factory.js +0 -138
  167. package/dist/providers/dynamic-provider.factory.js.map +0 -1
  168. package/dist/providers/logger.adapter.d.ts +0 -7
  169. package/dist/providers/logger.adapter.js +0 -107
  170. package/dist/providers/logger.adapter.js.map +0 -1
  171. package/dist/services/agent-loader.service.d.ts +0 -35
  172. package/dist/services/agent-loader.service.js +0 -623
  173. package/dist/services/agent-loader.service.js.map +0 -1
  174. package/dist/services/auth.service.d.ts +0 -9
  175. package/dist/services/auth.service.js +0 -47
  176. package/dist/services/auth.service.js.map +0 -1
  177. package/dist/services/config-validator.service.d.ts +0 -29
  178. package/dist/services/config-validator.service.js +0 -483
  179. package/dist/services/config-validator.service.js.map +0 -1
  180. package/dist/services/config.service.d.ts +0 -45
  181. package/dist/services/config.service.js +0 -352
  182. package/dist/services/config.service.js.map +0 -1
  183. package/dist/services/document-loader.service.d.ts +0 -26
  184. package/dist/services/document-loader.service.js +0 -186
  185. package/dist/services/document-loader.service.js.map +0 -1
  186. package/dist/services/help.service.d.ts +0 -5
  187. package/dist/services/help.service.js +0 -139
  188. package/dist/services/help.service.js.map +0 -1
  189. package/dist/services/intelligent-compression.service.d.ts +0 -20
  190. package/dist/services/intelligent-compression.service.js +0 -179
  191. package/dist/services/intelligent-compression.service.js.map +0 -1
  192. package/dist/services/mcp-client.service.d.ts +0 -26
  193. package/dist/services/mcp-client.service.js +0 -81
  194. package/dist/services/mcp-client.service.js.map +0 -1
  195. package/dist/services/parallel-processing.service.d.ts +0 -108
  196. package/dist/services/parallel-processing.service.js +0 -333
  197. package/dist/services/parallel-processing.service.js.map +0 -1
  198. package/dist/services/provider-bridge.service.d.ts +0 -35
  199. package/dist/services/provider-bridge.service.js +0 -224
  200. package/dist/services/provider-bridge.service.js.map +0 -1
  201. package/dist/services/remote-agent.service.d.ts +0 -50
  202. package/dist/services/remote-agent.service.js +0 -171
  203. package/dist/services/remote-agent.service.js.map +0 -1
  204. package/dist/services/result-formatter.service.d.ts +0 -27
  205. package/dist/services/result-formatter.service.js +0 -126
  206. package/dist/services/result-formatter.service.js.map +0 -1
  207. package/dist/services/skill-loader.service.d.ts +0 -15
  208. package/dist/services/skill-loader.service.js +0 -278
  209. package/dist/services/skill-loader.service.js.map +0 -1
  210. package/dist/services/skill.service.d.ts +0 -69
  211. package/dist/services/skill.service.js +0 -779
  212. package/dist/services/skill.service.js.map +0 -1
  213. package/dist/services/skill.service.spec.d.ts +0 -1
  214. package/dist/services/skill.service.spec.js +0 -168
  215. package/dist/services/skill.service.spec.js.map +0 -1
  216. package/dist/services/task-management.service.d.ts +0 -71
  217. package/dist/services/task-management.service.js +0 -324
  218. package/dist/services/task-management.service.js.map +0 -1
  219. package/dist/services/template.service.d.ts +0 -61
  220. package/dist/services/template.service.js +0 -416
  221. package/dist/services/template.service.js.map +0 -1
  222. package/dist/services/tool-call.service.d.ts +0 -16
  223. package/dist/services/tool-call.service.js +0 -302
  224. package/dist/services/tool-call.service.js.map +0 -1
  225. package/dist/services/tracing.service.d.ts +0 -197
  226. package/dist/services/tracing.service.js +0 -1267
  227. package/dist/services/tracing.service.js.map +0 -1
  228. package/dist/slack/formatters/message.formatter.d.ts +0 -43
  229. package/dist/slack/formatters/message.formatter.js +0 -505
  230. package/dist/slack/formatters/message.formatter.js.map +0 -1
  231. package/dist/slack/services/slack-file-download.service.d.ts +0 -58
  232. package/dist/slack/services/slack-file-download.service.js +0 -558
  233. package/dist/slack/services/slack-file-download.service.js.map +0 -1
  234. package/dist/slack/slack-bot.d.ts +0 -33
  235. package/dist/slack/slack-bot.js +0 -568
  236. package/dist/slack/slack-bot.js.map +0 -1
  237. package/dist/stderr.logger.d.ts +0 -8
  238. package/dist/stderr.logger.js +0 -26
  239. package/dist/stderr.logger.js.map +0 -1
  240. package/dist/types/usage.types.d.ts +0 -107
  241. package/dist/types/usage.types.js +0 -3
  242. package/dist/types/usage.types.js.map +0 -1
  243. package/dist/utils/config-utils.d.ts +0 -15
  244. package/dist/utils/config-utils.js +0 -69
  245. package/dist/utils/config-utils.js.map +0 -1
  246. package/dist/utils/extract-text.d.ts +0 -1
  247. package/dist/utils/extract-text.js +0 -15
  248. package/dist/utils/extract-text.js.map +0 -1
  249. package/dist/utils/mcp-installer.d.ts +0 -20
  250. package/dist/utils/mcp-installer.js +0 -199
  251. package/dist/utils/mcp-installer.js.map +0 -1
  252. package/dist/utils/project-hash.d.ts +0 -6
  253. package/dist/utils/project-hash.js +0 -70
  254. package/dist/utils/project-hash.js.map +0 -1
  255. package/dist/utils/simple-security.d.ts +0 -3
  256. package/dist/utils/simple-security.js +0 -20
  257. package/dist/utils/simple-security.js.map +0 -1
  258. package/dist/utils/stdin-utils.d.ts +0 -6
  259. package/dist/utils/stdin-utils.js +0 -109
  260. package/dist/utils/stdin-utils.js.map +0 -1
  261. package/dist/utils/template-processor.d.ts +0 -27
  262. package/dist/utils/template-processor.js +0 -395
  263. package/dist/utils/template-processor.js.map +0 -1
  264. package/dist/utils/terminal-message-formatter.d.ts +0 -23
  265. package/dist/utils/terminal-message-formatter.js +0 -136
  266. package/dist/utils/terminal-message-formatter.js.map +0 -1
  267. package/dist/version.d.ts +0 -1
  268. package/dist/version.js +0 -17
  269. package/dist/version.js.map +0 -1
  270. package/dist/workspace.service.d.ts +0 -44
  271. package/dist/workspace.service.js +0 -299
  272. package/dist/workspace.service.js.map +0 -1
  273. package/scripts/backfill-tokens.js +0 -218
  274. package/scripts/postbuild-cli.mjs +0 -88
  275. package/scripts/postinstall-cli.mjs +0 -30
  276. package/templates/agents/default.yaml +0 -490
  277. package/templates/agents/minimal.yaml +0 -16
  278. package/templates/documents/conversation-history-default.hbs +0 -17
  279. package/templates/documents/crewx-manual.md +0 -2278
  280. package/templates/documents/crewx-quick-guide.md +0 -147
  281. package/templates/versions.json +0 -19
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ /**
3
+ * Shared SQLite helper for ps/kill/result CLI commands.
4
+ * Reads from (or writes to) the global ~/.crewx/crewx.db
5
+ * populated by SqliteTracingPlugin.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getDbPath = getDbPath;
12
+ exports.openDb = openDb;
13
+ exports.getRunningTasks = getRunningTasks;
14
+ exports.getAllTasks = getAllTasks;
15
+ exports.getTask = getTask;
16
+ exports.killTask = killTask;
17
+ const fs_1 = require("fs");
18
+ const path_1 = require("path");
19
+ const os_1 = require("os");
20
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
21
+ function getDbPath(dbRoot) {
22
+ return (0, path_1.join)(dbRoot ?? (0, os_1.homedir)(), '.crewx', 'crewx.db');
23
+ }
24
+ function openDb(readonly = true, dbRoot) {
25
+ const dbPath = getDbPath(dbRoot);
26
+ if (!(0, fs_1.existsSync)(dbPath))
27
+ return null;
28
+ return new better_sqlite3_1.default(dbPath, { readonly });
29
+ }
30
+ /** Return all tasks with status='running'. */
31
+ function getRunningTasks(dbRoot) {
32
+ const db = openDb(true, dbRoot);
33
+ if (!db)
34
+ return [];
35
+ try {
36
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
37
+ result, error, duration_ms
38
+ FROM tasks WHERE status = 'running' ORDER BY started_at DESC`).all();
39
+ }
40
+ finally {
41
+ db.close();
42
+ }
43
+ }
44
+ /** Return all tasks ordered by started_at desc. */
45
+ function getAllTasks(dbRoot) {
46
+ const db = openDb(true, dbRoot);
47
+ if (!db)
48
+ return [];
49
+ try {
50
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
51
+ result, error, duration_ms
52
+ FROM tasks ORDER BY started_at DESC`).all();
53
+ }
54
+ finally {
55
+ db.close();
56
+ }
57
+ }
58
+ /** Return a single task by id, or undefined if not found. */
59
+ function getTask(id, dbRoot) {
60
+ const db = openDb(true, dbRoot);
61
+ if (!db)
62
+ return undefined;
63
+ try {
64
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
65
+ result, error, duration_ms
66
+ FROM tasks WHERE id = ?`).get(id);
67
+ }
68
+ finally {
69
+ db.close();
70
+ }
71
+ }
72
+ /** Send SIGTERM to the task's pid and mark it failed. Returns ok/message. */
73
+ function killTask(id, dbRoot) {
74
+ const db = openDb(false, dbRoot);
75
+ if (!db)
76
+ return { ok: false, message: `crewx.db not found — no running tasks.` };
77
+ try {
78
+ const task = db.prepare(`SELECT id, status, pid FROM tasks WHERE id = ?`).get(id);
79
+ if (!task) {
80
+ return { ok: false, message: `Task not found: ${id}` };
81
+ }
82
+ if (task.status !== 'running') {
83
+ return { ok: false, message: `Task ${id} is not running (status: ${task.status})` };
84
+ }
85
+ if (task.pid) {
86
+ try {
87
+ process.kill(task.pid, 'SIGTERM');
88
+ }
89
+ catch (err) {
90
+ const code = err.code;
91
+ if (code !== 'ESRCH') {
92
+ return {
93
+ ok: false,
94
+ message: `Failed to kill PID ${task.pid}: ${err instanceof Error ? err.message : String(err)}`,
95
+ };
96
+ }
97
+ // ESRCH = process already gone — still clean up the record
98
+ }
99
+ }
100
+ db.prepare(`UPDATE tasks SET status='failed', error='killed by user',
101
+ completed_at=?, pid=NULL WHERE id=?`).run(new Date().toISOString(), id);
102
+ return { ok: true, message: `Killed task ${id}${task.pid ? ` (PID: ${task.pid})` : ''}` };
103
+ }
104
+ finally {
105
+ db.close();
106
+ }
107
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
3
+ *
4
+ * Denies Bash tool calls whose command string contains ".env".
5
+ * Pure string matching — trivially bypassable (see README).
6
+ *
7
+ * SECURITY NOTE:
8
+ * Do NOT include tool.input content in deny reasons.
9
+ * Use static messages only to prevent prompt injection.
10
+ * ✅ return ctx.deny('Secrets-related command');
11
+ * ❌ return ctx.deny(`Blocked: ${cmd}`);
12
+ */
13
+ import { HookPlugin } from '@crewx/sdk/hooks';
14
+ import type { HookContext, HookResult } from '@crewx/sdk/hooks';
15
+ export declare class DenyIfTouchesSecretsPlugin extends HookPlugin {
16
+ readonly name = "deny-secrets";
17
+ readonly version = "0.1.0";
18
+ readonly capabilities: {
19
+ required: readonly ["deny"];
20
+ };
21
+ run(ctx: HookContext): Promise<HookResult>;
22
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
4
+ *
5
+ * Denies Bash tool calls whose command string contains ".env".
6
+ * Pure string matching — trivially bypassable (see README).
7
+ *
8
+ * SECURITY NOTE:
9
+ * Do NOT include tool.input content in deny reasons.
10
+ * Use static messages only to prevent prompt injection.
11
+ * ✅ return ctx.deny('Secrets-related command');
12
+ * ❌ return ctx.deny(`Blocked: ${cmd}`);
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DenyIfTouchesSecretsPlugin = void 0;
16
+ const hooks_1 = require("@crewx/sdk/hooks");
17
+ const SECRET_PATTERNS = ['.env', 'credentials.json', 'service-account-key.json'];
18
+ const SHELL_TOOL_NAMES = new Set(['Bash', 'shell', 'local_shell']);
19
+ class DenyIfTouchesSecretsPlugin extends hooks_1.HookPlugin {
20
+ name = 'deny-secrets';
21
+ version = '0.1.0';
22
+ capabilities = { required: ['deny'] };
23
+ async run(ctx) {
24
+ if (!SHELL_TOOL_NAMES.has(ctx.tool.rawName) && ctx.tool.name !== 'shell') {
25
+ return ctx.pass();
26
+ }
27
+ const input = ctx.tool.input;
28
+ const command = input?.command;
29
+ if (typeof command !== 'string') {
30
+ return ctx.pass();
31
+ }
32
+ for (const pattern of SECRET_PATTERNS) {
33
+ if (command.includes(pattern)) {
34
+ return ctx.deny('Secrets-related command');
35
+ }
36
+ }
37
+ return ctx.pass();
38
+ }
39
+ }
40
+ exports.DenyIfTouchesSecretsPlugin = DenyIfTouchesSecretsPlugin;
@@ -0,0 +1 @@
1
+ export { handleInit, type InitResult } from './commands/init';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleInit = void 0;
4
+ var init_1 = require("./commands/init");
5
+ Object.defineProperty(exports, "handleInit", { enumerable: true, get: function () { return init_1.handleInit; } });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * CLI file-based logging for CrewX SDK events.
3
+ *
4
+ * Subscribe to task:start / task:end events from a Crewx instance
5
+ * and write structured log files to .crewx/logs/ in the workspace root.
6
+ *
7
+ * File name format: {YYYYMMDDTHHmmss}_{traceId}.log
8
+ * e.g. 20260412T145044_tsk_AbCdEfGh.log
9
+ *
10
+ * Format mirrors cli-bak TaskManagementService for backward compatibility.
11
+ */
12
+ import type { Crewx } from '@crewx/sdk';
13
+ /**
14
+ * Attach file-based logging to a Crewx instance.
15
+ * Subscribes to task:start and task:end events and writes log files.
16
+ *
17
+ * @param crewx - The Crewx instance to attach logging to
18
+ * @param workspaceRoot - Root directory for .crewx/logs/ (default: process.cwd())
19
+ * @returns Cleanup function that removes all event listeners
20
+ */
21
+ export declare function attachFileLogger(crewx: Crewx, workspaceRoot?: string): () => void;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * CLI file-based logging for CrewX SDK events.
4
+ *
5
+ * Subscribe to task:start / task:end events from a Crewx instance
6
+ * and write structured log files to .crewx/logs/ in the workspace root.
7
+ *
8
+ * File name format: {YYYYMMDDTHHmmss}_{traceId}.log
9
+ * e.g. 20260412T145044_tsk_AbCdEfGh.log
10
+ *
11
+ * Format mirrors cli-bak TaskManagementService for backward compatibility.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.attachFileLogger = attachFileLogger;
15
+ const fs_1 = require("fs");
16
+ const path_1 = require("path");
17
+ const CREWX_VERSION = '0.9.0-alpha.1';
18
+ /** Format Date as YYYYMMDDTHHmmss (local time) */
19
+ function formatTimestamp(date) {
20
+ const pad = (n) => String(n).padStart(2, '0');
21
+ return (`${date.getFullYear()}` +
22
+ `${pad(date.getMonth() + 1)}` +
23
+ `${pad(date.getDate())}` +
24
+ `T${pad(date.getHours())}` +
25
+ `${pad(date.getMinutes())}` +
26
+ `${pad(date.getSeconds())}`);
27
+ }
28
+ function ensureLogsDir(logsDir) {
29
+ if (!(0, fs_1.existsSync)(logsDir)) {
30
+ (0, fs_1.mkdirSync)(logsDir, { recursive: true });
31
+ }
32
+ }
33
+ /**
34
+ * Attach file-based logging to a Crewx instance.
35
+ * Subscribes to task:start and task:end events and writes log files.
36
+ *
37
+ * @param crewx - The Crewx instance to attach logging to
38
+ * @param workspaceRoot - Root directory for .crewx/logs/ (default: process.cwd())
39
+ * @returns Cleanup function that removes all event listeners
40
+ */
41
+ function attachFileLogger(crewx, workspaceRoot) {
42
+ const logsDir = (0, path_1.join)(workspaceRoot ?? process.cwd(), '.crewx', 'logs');
43
+ // traceId → absolute log file path (in-memory map for the process lifetime)
44
+ const logFiles = new Map();
45
+ const unsubStart = crewx.on('task:start', (event) => {
46
+ try {
47
+ ensureLogsDir(logsDir);
48
+ const ts = formatTimestamp(event.timestamp);
49
+ const logFile = (0, path_1.join)(logsDir, `${ts}_${event.traceId}.log`);
50
+ logFiles.set(event.traceId, logFile);
51
+ const header = `=== TASK LOG: ${event.traceId} ===\n` +
52
+ `CrewX Version: ${CREWX_VERSION}\n` +
53
+ `Mode: ${event.mode}\n` +
54
+ `Agent: ${event.agentRef}\n` +
55
+ `Started: ${event.timestamp.toLocaleString()}\n` +
56
+ `Message: ${event.message}\n` +
57
+ `\n`;
58
+ (0, fs_1.writeFileSync)(logFile, header, { encoding: 'utf8', mode: 0o600 });
59
+ }
60
+ catch {
61
+ // Non-fatal: CLI logging must never crash the main process
62
+ }
63
+ });
64
+ const unsubEnd = crewx.on('task:end', (event) => {
65
+ try {
66
+ const logFile = logFiles.get(event.traceId);
67
+ if (!logFile)
68
+ return;
69
+ const ts = new Date().toLocaleString();
70
+ const status = event.error
71
+ ? `failed: ${event.error.message}`
72
+ : 'completed successfully';
73
+ const completion = `[${ts}] INFO: Task ${status} in ${event.durationMs}ms\n` +
74
+ `[${ts}] INFO: Process closed with exit code: ${event.error ? 1 : 0}\n`;
75
+ (0, fs_1.appendFileSync)(logFile, completion, 'utf8');
76
+ logFiles.delete(event.traceId);
77
+ }
78
+ catch {
79
+ // Non-fatal
80
+ }
81
+ });
82
+ return () => {
83
+ unsubStart();
84
+ unsubEnd();
85
+ };
86
+ }
package/dist/main.d.ts CHANGED
@@ -1 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CrewX CLI entry point.
4
+ * Dispatches commands to the appropriate handler.
5
+ *
6
+ * Boot sequence:
7
+ * 1. Inject CREWX_CLI / CREWX_WORKSPACE env defaults (must be first)
8
+ * 2. Parse command
9
+ * 3. Dispatch to handler
10
+ */
1
11
  export {};